Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gar::geo::seg::SegmentationMultiGridStripXYAlg Class Reference

#include <SegmentationMultiGridStripXYAlg.h>

Inheritance diagram for gar::geo::seg::SegmentationMultiGridStripXYAlg:
gar::geo::seg::SegmentationAlg

Public Member Functions

 SegmentationMultiGridStripXYAlg (fhicl::ParameterSet const &pset)
 Default constructor used by derived classes passing the encoding string. More...
 
 SegmentationMultiGridStripXYAlg (const BitFieldCoder *decoder, fhicl::ParameterSet const &pset)
 Default constructor used by derived classes passing an existing decoder. More...
 
 ~SegmentationMultiGridStripXYAlg ()
 
void reconfigure (fhicl::ParameterSet const &pset) override
 
void Initialize (const gar::geo::GeometryCore &geo) override
 
std::array< double, 3 > GetPosition (const gar::geo::GeometryCore &geo, const gar::raw::CellID_t &cID) const override
 
gar::raw::CellID_t GetCellID (const gar::geo::GeometryCore &geo, const unsigned int &det_id, const unsigned int &stave, const unsigned int &module, const unsigned int &layer, const unsigned int &slice, const std::array< double, 3 > &localPosition) const override
 determine the cell ID based on the position More...
 
bool isTile (const gar::raw::CellID_t &cID) const override
 
bool isBarrel (const gar::raw::CellID_t &cID) const override
 
double getStripLength (const gar::geo::GeometryCore &geo, const std::array< double, 3 > &local, const gar::raw::CellID_t &cID) const override
 
std::pair< TVector3, TVector3 > getStripEnds (const gar::geo::GeometryCore &geo, const std::array< double, 3 > &local, const gar::raw::CellID_t &cID) const override
 
std::pair< float, float > CalculateLightPropagation (const gar::geo::GeometryCore &geo, const std::array< double, 3 > &local, const gar::raw::CellID_t &cID) const override
 
std::array< double, 3 > ReconstructStripHitPosition (const gar::geo::GeometryCore &geo, const std::array< double, 3 > &local, const float &xlocal, const gar::raw::CellID_t &cID) const override
 
const double & gridSizeX () const override
 
const double & gridSizeY () const
 
const double & stripSizeX () const override
 
const double & stripSizeY () const
 
const double & offsetX () const
 
const double & offsetY () const
 
const double & layerDimX () const
 
const double & layerDimY () const
 
const std::stringfieldNameX () const
 
const std::stringfieldNameY () const
 
const std::stringfieldNameLayer () const
 
const std::stringfieldNameSlice () const
 
const unsigned int & nLayers () const override
 
void setGridSizeX (double cellSize)
 
void setGridSizeY (double cellSize)
 
void setStripSizeX (double stripSize)
 
void setStripSizeY (double stripSize)
 
void setOffsetX (double offset)
 
void setOffsetY (double offset)
 
void setFieldNameX (const std::string &fieldName)
 
void setFieldNameY (const std::string &fieldName)
 
void setFieldNameLayer (const std::string &fieldName)
 
void setFieldNameSlice (const std::string &fieldName)
 
void setLayerDimXY (const double &dimX, const double &dimY) const override
 
void setVariables (const double &innerangle, const double &endcapsidelength) const override
 
- Public Member Functions inherited from gar::geo::seg::SegmentationAlg
virtual ~SegmentationAlg ()
 
virtual const std::stringname () const
 
virtual void setName (const std::string &value)
 
virtual const std::stringtype () const
 
virtual const std::stringdescription () const
 
virtual const BitFieldCoderdecoder () const
 
virtual const unsigned int & nPlanes () const
 
virtual const std::stringcellEncoding () const
 
virtual void setDecoder (const BitFieldCoder *decoder)
 

Protected Member Functions

void PrintParameters () const override
 
std::array< std::vector< unsigned int >, 2 > TokenizeLayerVectors (std::vector< std::string > grid) const
 
- Protected Member Functions inherited from gar::geo::seg::SegmentationAlg
 SegmentationAlg (fhicl::ParameterSet const &pset)
 
 SegmentationAlg (const BitFieldCoder *decoder, fhicl::ParameterSet const &pset)
 

Protected Attributes

double _gridSizeX
 the grid size in X More...
 
double _offsetX
 the coordinate offset in X More...
 
double _gridSizeY
 the grid size in Y More...
 
double _offsetY
 the coordinate offset in Y More...
 
std::string _xId
 the field name used for X More...
 
std::string _yId
 the field name used for Y More...
 
std::string _layerId
 the field name used for layer More...
 
std::string _sliceId
 the field name used for slice More...
 
std::string _encoding
 the encoding string More...
 
double _stripSizeX
 the strip size in X More...
 
double _stripSizeY
 the strip size in Y More...
 
double _frac
 fraction of tiles to remove at the edge More...
 
unsigned int _nLayers
 number of layers More...
 
unsigned int _active_slice
 active slice number More...
 
std::vector< std::string_gridBarrelLayers
 the layers (start::end) for grid in Barrel More...
 
std::vector< std::string_stripBarrelLayers
 the layers (start::end) for strips in Barrel More...
 
std::vector< std::string_gridEndcapLayers
 the layers (start::end) for grid in Endcap More...
 
std::vector< std::string_stripEndcapLayers
 the layers (start::end) for strips in Endcap More...
 
double _layer_dim_X
 layer dimension in X More...
 
double _layer_dim_Y
 layer dimension in Y More...
 
double _InnerAngle
 Inner Angle. More...
 
double _EndcapSideLength
 Endcap Side Length. More...
 
bool _OnSameLayer
 are the strips on the same layer? More...
 
- Protected Attributes inherited from gar::geo::seg::SegmentationAlg
std::string _name
 
std::string _type
 
std::string _description
 
std::string _encoding
 
double _gridSizeX
 
double _stripSizeX
 
unsigned int _nLayers
 
unsigned int _nPlanes
 
const BitFieldCoder_decoder = 0
 

Additional Inherited Members

- Static Protected Member Functions inherited from gar::geo::seg::SegmentationAlg
static double binToPosition (gar::raw::CellID_t bin, double cellSize, double offset=0)
 
static int positionToBin (double position, double cellSize, double offset=0)
 

Detailed Description

Definition at line 18 of file SegmentationMultiGridStripXYAlg.h.

Constructor & Destructor Documentation

gar::geo::seg::SegmentationMultiGridStripXYAlg::SegmentationMultiGridStripXYAlg ( fhicl::ParameterSet const &  pset)

Default constructor used by derived classes passing the encoding string.

Definition at line 20 of file SegmentationMultiGridStripXYAlg.cxx.

21  : SegmentationAlg(pset)
22  {
23  _type = "MultiGridStripXY";
24  _description = "Cartesian segmentation in the local XY-plane, containing integer number of tiles/strips/cells";
25 
26  std::cout << "######### gar::geo::seg::SegmentationMultiGridStripXYAlg() " << std::endl ;
27 
28  this->reconfigure(pset);
29  }
void reconfigure(fhicl::ParameterSet const &pset) override
SegmentationAlg(fhicl::ParameterSet const &pset)
QTextStream & endl(QTextStream &s)
gar::geo::seg::SegmentationMultiGridStripXYAlg::SegmentationMultiGridStripXYAlg ( const BitFieldCoder decoder,
fhicl::ParameterSet const &  pset 
)

Default constructor used by derived classes passing an existing decoder.

Definition at line 33 of file SegmentationMultiGridStripXYAlg.cxx.

34  : SegmentationAlg(decode, pset)
35  {
36  _type = "MultiGridStripXY";
37  _description = "Cartesian segmentation in the local XY-plane, containing integer number of tiles/strips/cells";
38 
39  std::cout << "######### gar::geo::seg::SegmentationMultiGridStripXYAlg() " << std::endl ;
40 
41  this->reconfigure(pset);
42  }
void reconfigure(fhicl::ParameterSet const &pset) override
void decode(std::any const &a, Hep2Vector &result)
Definition: CLHEP_ps.h:12
SegmentationAlg(fhicl::ParameterSet const &pset)
QTextStream & endl(QTextStream &s)
gar::geo::seg::SegmentationMultiGridStripXYAlg::~SegmentationMultiGridStripXYAlg ( )

Definition at line 45 of file SegmentationMultiGridStripXYAlg.cxx.

46  {
47  }

Member Function Documentation

std::pair< float, float > gar::geo::seg::SegmentationMultiGridStripXYAlg::CalculateLightPropagation ( const gar::geo::GeometryCore geo,
const std::array< double, 3 > &  local,
const gar::raw::CellID_t cID 
) const
overridevirtual

Reimplemented from gar::geo::seg::SegmentationAlg.

Definition at line 459 of file SegmentationMultiGridStripXYAlg.cxx.

460  {
461  //Propagate the light to the SiPM on the side
462  //convert c to mm/ns
463  // c = 29.9792458 cm/ns
464  float c = (CLHEP::c_light * CLHEP::mm / CLHEP::ns) / CLHEP::cm; // in cm/ns
465  //time1 is left SiPM
466  float time1 = 0.;
467  //time2 is right SiPM
468  float time2 = 0.;
469  //check if it is barrel or not
470  bool isBarrel = this->isBarrel(cID);
471 
472  //Strip along X (local)
473  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 == 0) )
474  {
475  if(isBarrel) {
476  time1 = ( _layer_dim_X / 2 + local[0] ) / c;
477  time2 = ( _layer_dim_X / 2 - local[0] ) / c;
478  } else {
479  float angle = _InnerAngle - M_PI/2;
480  int n = std::round( (local[0] - ( _EndcapSideLength / 2. )) / _stripSizeY );
481  if ( n < 0 ) n = 0;
482  float strip_dim = _layer_dim_X - ( n * ( _stripSizeY / std::tan(angle) ) );
483  time1 = ( strip_dim / 2. + local[0] ) / c;
484  time2 = ( strip_dim / 2. - local[0] ) / c;
485  }
486  }
487 
488  //Strip along Y (local)
489  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice+1) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 != 0) )
490  {
491  if(isBarrel) {
492  time1 = ( _layer_dim_Y / 2 + local[1] ) / c;
493  time2 = ( _layer_dim_Y / 2 - local[1] ) / c;
494  } else {
495  float angle = _InnerAngle - M_PI/2;
496  int n = std::round( (local[1] - ( _EndcapSideLength / 2. )) / _stripSizeX );
497  if ( n < 0 ) n = 0;
498  float strip_dim = _layer_dim_Y - ( n * ( _stripSizeX / std::tan(angle) ) );
499  time1 = ( strip_dim / 2. + local[1] ) / c;
500  time2 = ( strip_dim / 2. - local[1] ) / c;
501  }
502  }
503 
504  return std::make_pair(time1, time2);
505  }
static constexpr double cm
Definition: Units.h:68
const BitFieldCoder * _decoder
std::string _layerId
the field name used for layer
std::string _sliceId
the field name used for slice
std::void_t< T > n
#define M_PI
Definition: includeROOT.h:54
long64 get(long64 bitfield, size_t index) const
static constexpr double mm
Definition: Units.h:65
bool isBarrel(const gar::raw::CellID_t &cID) const override
QAsciiDict< Entry > ns
const std::string& gar::geo::seg::SegmentationMultiGridStripXYAlg::fieldNameLayer ( ) const
inline

Definition at line 67 of file SegmentationMultiGridStripXYAlg.h.

67 { return _layerId; }
std::string _layerId
the field name used for layer
const std::string& gar::geo::seg::SegmentationMultiGridStripXYAlg::fieldNameSlice ( ) const
inline

Definition at line 69 of file SegmentationMultiGridStripXYAlg.h.

69 { return _sliceId; }
std::string _sliceId
the field name used for slice
const std::string& gar::geo::seg::SegmentationMultiGridStripXYAlg::fieldNameX ( ) const
inline

Definition at line 63 of file SegmentationMultiGridStripXYAlg.h.

63 { return _xId; }
const std::string& gar::geo::seg::SegmentationMultiGridStripXYAlg::fieldNameY ( ) const
inline

Definition at line 65 of file SegmentationMultiGridStripXYAlg.h.

65 { return _yId; }
gar::raw::CellID_t gar::geo::seg::SegmentationMultiGridStripXYAlg::GetCellID ( const gar::geo::GeometryCore geo,
const unsigned int &  det_id,
const unsigned int &  stave,
const unsigned int &  module,
const unsigned int &  layer,
const unsigned int &  slice,
const std::array< double, 3 > &  localPosition 
) const
overridevirtual

determine the cell ID based on the position

Implements gar::geo::seg::SegmentationAlg.

Definition at line 210 of file SegmentationMultiGridStripXYAlg.cxx.

211  {
212  gar::raw::CellID_t cID = 0;
213 
214  _decoder->set(cID, "system", det_id);
215  _decoder->set(cID, "module", module);
216  _decoder->set(cID, "stave", stave);
217  _decoder->set(cID, "layer", layer);
218  _decoder->set(cID, "slice", slice);
219 
220  //Need to differentiate case tile and strips based on layer and slice
221  bool isTile = this->isTile(cID);
222 
223  double localX = localPosition[0];
224  double localY = localPosition[1];
225 
226  if(isTile)
227  {
228  _decoder->set(cID, _xId, positionToBin(localX, _gridSizeX, _offsetX));
229  _decoder->set(cID, _yId, positionToBin(localY, _gridSizeY, _offsetY));
230  }
231  else
232  {
233  if( (_OnSameLayer && slice == _active_slice) || (not _OnSameLayer && layer%2 == 0) )
234  {
235  //Segmentation in Y
236  int nCellsX = 1;
237  int nCellsY = int(_layer_dim_Y / _stripSizeY);
238 
239  int _cellIndexX = int ( localX / ( _layer_dim_X / nCellsX ) );
240  int _cellIndexY = int ( localY / ( _layer_dim_Y / nCellsY ) );
241 
242  _decoder->set(cID, _xId, _cellIndexX);
243  _decoder->set(cID, _yId, _cellIndexY);
244  }
245 
246  if( (_OnSameLayer && slice == _active_slice+1) || (not _OnSameLayer && layer%2 != 0) )
247  {
248  //Segmentation in X
249  int nCellsX = int(_layer_dim_X / _stripSizeX);
250  int nCellsY = 1;
251 
252  int _cellIndexX = int ( localX / ( _layer_dim_X / nCellsX ) );
253  int _cellIndexY = int ( localY / ( _layer_dim_Y / nCellsY ) );
254 
255  _decoder->set(cID, _xId, _cellIndexX);
256  _decoder->set(cID, _yId, _cellIndexY);
257  }
258  }
259 
260  return cID;
261  }
const BitFieldCoder * _decoder
void set(long64 &bitfield, size_t index, ulong64 value) const
bool isTile(const gar::raw::CellID_t &cID) const override
static int positionToBin(double position, double cellSize, double offset=0)
long long int CellID_t
Definition: CaloRawDigit.h:24
std::array< double, 3 > gar::geo::seg::SegmentationMultiGridStripXYAlg::GetPosition ( const gar::geo::GeometryCore geo,
const gar::raw::CellID_t cID 
) const
overridevirtual

Implements gar::geo::seg::SegmentationAlg.

Definition at line 92 of file SegmentationMultiGridStripXYAlg.cxx.

93  {
94  //Local origin for the Barrel in the middle of the layer
95  //Local origin for the Endcal at the corner of the full stave
96  std::array<double, 3> cellPosition;
97 
98  //Need to differentiate case tile and strips based on layer and slice
99  bool isTile = this->isTile(cID);
100  bool isBarrel = this->isBarrel(cID);
101 
102  if(isTile) {
103  //Need to check if the tile is at the edge of the layer!
104  cellPosition[0] = binToPosition(_decoder->get(cID, _xId), _gridSizeX, _offsetX);
105  cellPosition[1] = binToPosition(_decoder->get(cID, _yId), _gridSizeY, _offsetY);
106  cellPosition[2] = 0.;
107 
108  if( isBarrel ) {
109 
110  //Check if the position is outside of the layer size
111  if( std::fabs(cellPosition[0]) > _layer_dim_X/2. ) {
112 
113  cellPosition[0] = cellPosition[0] / std::fabs(cellPosition[0]) * ( _layer_dim_X - _frac ) / 2.;
114  }
115 
116  if(std::fabs(cellPosition[1]) > _layer_dim_Y/2. ) {
117 
118  cellPosition[1] = cellPosition[1] / std::fabs(cellPosition[1]) * ( _layer_dim_Y - _frac ) / 2.;
119  }
120  }
121 
122  //TODO
123  //Problem here is that the full layer is the endcap stave, no "layer shape"
124  //the problem will occur for hits that are at the limit
125  //checking if x or y are over the layer dim does not work (as the stave is not a square/rectangle)
126  if( not isBarrel ) {
127 
128  float r_point = std::sqrt( cellPosition[0]*cellPosition[0] + cellPosition[1]*cellPosition[1] );
129 
130  //Check if the point is outside.... layer_dim_x = layer_dim_y = apothem
131  if(r_point > _layer_dim_Y) {
132 
133  if( std::fabs(cellPosition[0]) < _EndcapSideLength / 2. || std::fabs(cellPosition[1]) < _EndcapSideLength / 2. ) {
134 
135  if( std::fabs(cellPosition[0]) < _EndcapSideLength / 2. && std::fabs(cellPosition[1]) > _layer_dim_Y ) {
136 
137  cellPosition[1] = cellPosition[1] / std::fabs(cellPosition[1]) * ( _layer_dim_Y - _frac ) ;
138  }
139 
140  if( std::fabs(cellPosition[1]) < _EndcapSideLength / 2. && std::fabs(cellPosition[0]) > _layer_dim_X ) {
141 
142  cellPosition[0] = cellPosition[0] / std::fabs(cellPosition[0]) * ( _layer_dim_X - _frac ) ;
143  }
144 
145  } else if ( std::fabs(cellPosition[0]) > _EndcapSideLength / 2. && std::fabs(cellPosition[1]) > _EndcapSideLength / 2. ) {
146  //Complicated part //do NOTHING the hit will be dropped
147  }
148  }
149  }
150  }
151  else
152  {
153  int cellIndexX = _decoder->get(cID,_xId);
154  int cellIndexY = _decoder->get(cID,_yId);
155 
156  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 == 0) )
157  {
158  //Segmentation in Y
159  int nCellsX = 1;
160  // int nCellsY = int(_layer_dim_Y / _stripSizeY);
161 
162  if(isBarrel) {
163  cellPosition[0] = ( cellIndexX + 0.5 ) * (_layer_dim_X / nCellsX ) - (_layer_dim_X / 2.);
164  cellPosition[1] = ( cellIndexY + 0.5 ) * _stripSizeY;
165  cellPosition[2] = 0.;
166  }
167  else {
168  cellPosition[1] = ( cellIndexY + 0.5 ) * _stripSizeY;
169  cellPosition[0] = ( cellIndexX + 0.5 ) * ( _layer_dim_X / nCellsX );
170  if( cellPosition[1] > _EndcapSideLength / 2.) {
171  //Correct for the endcap
172  float angle = _InnerAngle - M_PI/2;
173  int n = std::round( ( cellPosition[1] - ( _EndcapSideLength / 2. ) ) / _stripSizeX );
174  cellPosition[0] -= n * ( _stripSizeX / std::tan(angle) ) / 2.;
175  }
176  cellPosition[2] = 0.;
177  }
178  }
179 
180  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice+1) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 != 0) )
181  {
182  //Segmentation in X
183  // int nCellsX = int(_layer_dim_X / _stripSizeX);
184  int nCellsY = 1;
185 
186  if(isBarrel) {
187  cellPosition[0] = ( cellIndexX + 0.5 ) * _stripSizeX;
188  cellPosition[1] = ( cellIndexY + 0.5 ) * (_layer_dim_Y / nCellsY ) - (_layer_dim_Y / 2.);
189  cellPosition[2] = 0.;
190  }
191  else {
192  cellPosition[0] = ( cellIndexX + 0.5 ) * _stripSizeX;
193  cellPosition[1] = ( cellIndexY + 0.5 ) * ( _layer_dim_Y / nCellsY );
194  if( cellPosition[0] > _EndcapSideLength / 2.) {
195  //Correct for the endcap
196  float angle = _InnerAngle - M_PI/2;
197  int n = std::round( ( cellPosition[0] - ( _EndcapSideLength / 2. ) ) / _stripSizeY );
198  cellPosition[1] -= n * ( _stripSizeY / std::tan(angle) ) / 2.;
199  }
200  cellPosition[2] = 0.;
201  }
202  }
203  }
204 
205  return cellPosition;
206  }
double _frac
fraction of tiles to remove at the edge
const BitFieldCoder * _decoder
bool isTile(const gar::raw::CellID_t &cID) const override
static double binToPosition(gar::raw::CellID_t bin, double cellSize, double offset=0)
std::string _layerId
the field name used for layer
std::string _sliceId
the field name used for slice
std::void_t< T > n
#define M_PI
Definition: includeROOT.h:54
long64 get(long64 bitfield, size_t index) const
bool isBarrel(const gar::raw::CellID_t &cID) const override
std::pair< TVector3, TVector3 > gar::geo::seg::SegmentationMultiGridStripXYAlg::getStripEnds ( const gar::geo::GeometryCore geo,
const std::array< double, 3 > &  local,
const gar::raw::CellID_t cID 
) const
overridevirtual

Reimplemented from gar::geo::seg::SegmentationAlg.

Definition at line 407 of file SegmentationMultiGridStripXYAlg.cxx.

408  {
409  //Local origin for the Barrel in the middle of the layer
410  //Local origin for the Endcal at the corner of the full stave
411  TVector3 stripEnd1(0., 0., 0.);
412  TVector3 stripEnd2(0., 0., 0.);
413  bool isBarrel = this->isBarrel(cID);
414 
415  //Strip along X (local)
416  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 == 0) ) {
417 
418  if(isBarrel) {
419  stripEnd1.SetX(-_layer_dim_X/2.);
420  stripEnd2.SetX(_layer_dim_X/2.);
421  } else {
422  stripEnd1.SetX(0.);
423  //not perfect at the edges...
424  float angle = _InnerAngle - M_PI/2;
425  int n = std::round( (local[1] - ( _EndcapSideLength / 2. )) / _stripSizeX );
426  if ( n < 0 ) n = 0;
427  stripEnd2.SetX( _layer_dim_X - ( n * ( _stripSizeX / std::tan(angle) ) ) );
428  }
429 
430  stripEnd1.SetY(local[1]);
431  stripEnd2.SetY(local[1]);
432  stripEnd1.SetZ(local[2]);
433  stripEnd2.SetZ(local[2]);
434  }
435  //Strip along Y (local)
436  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice+1) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 != 0) ) {
437 
438  if(isBarrel) {
439  stripEnd1.SetY(-_layer_dim_Y/2.);
440  stripEnd2.SetY(_layer_dim_Y/2.);
441  } else {
442  stripEnd1.SetY(0.);
443  float angle = _InnerAngle - M_PI/2;
444  int n = std::round( (local[0] - (_EndcapSideLength / 2.) ) / _stripSizeY );
445  if ( n < 0 ) n = 0;
446  stripEnd2.SetY( _layer_dim_Y - ( n * ( _stripSizeY / std::tan(angle) ) ) );//not perfect at the edges...
447  }
448 
449  stripEnd1.SetX(local[0]);
450  stripEnd2.SetX(local[0]);
451  stripEnd1.SetZ(local[2]);
452  stripEnd2.SetZ(local[2]);
453  }
454 
455  return std::make_pair(stripEnd1, stripEnd2);
456  }
const BitFieldCoder * _decoder
std::string _layerId
the field name used for layer
std::string _sliceId
the field name used for slice
std::void_t< T > n
#define M_PI
Definition: includeROOT.h:54
long64 get(long64 bitfield, size_t index) const
bool isBarrel(const gar::raw::CellID_t &cID) const override
double gar::geo::seg::SegmentationMultiGridStripXYAlg::getStripLength ( const gar::geo::GeometryCore geo,
const std::array< double, 3 > &  local,
const gar::raw::CellID_t cID 
) const
overridevirtual

Reimplemented from gar::geo::seg::SegmentationAlg.

Definition at line 375 of file SegmentationMultiGridStripXYAlg.cxx.

376  {
377  double stripLength = 0.;
378  bool isBarrel = this->isBarrel(cID);
379 
380  //Strip along X
381  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 == 0) ) {
382  if(isBarrel) {
383  stripLength = _layer_dim_X;
384  } else {
385  float angle = _InnerAngle - M_PI/2;
386  int n = std::round( (local[1] - ( _EndcapSideLength / 2. )) / _stripSizeX );
387  if ( n < 0 ) n = 0;
388  stripLength = _layer_dim_X - ( n * ( _stripSizeX / std::tan(angle) ) );
389  }
390  }
391  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice+1) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 != 0) ) {
392  //Strip along Y
393  if(isBarrel) {
394  stripLength = _layer_dim_Y;
395  } else {
396  float angle = _InnerAngle - M_PI/2;
397  int n = std::round( (local[1] - ( _EndcapSideLength / 2. )) / _stripSizeY );
398  if ( n < 0 ) n = 0;
399  stripLength = _layer_dim_Y - ( n * ( _stripSizeY / std::tan(angle) ) );
400  }
401  }
402 
403  return stripLength;
404  }
const BitFieldCoder * _decoder
std::string _layerId
the field name used for layer
std::string _sliceId
the field name used for slice
std::void_t< T > n
#define M_PI
Definition: includeROOT.h:54
long64 get(long64 bitfield, size_t index) const
bool isBarrel(const gar::raw::CellID_t &cID) const override
const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::gridSizeX ( ) const
inlineoverridevirtual

Reimplemented from gar::geo::seg::SegmentationAlg.

Definition at line 47 of file SegmentationMultiGridStripXYAlg.h.

const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::gridSizeY ( ) const
inline

Definition at line 49 of file SegmentationMultiGridStripXYAlg.h.

void gar::geo::seg::SegmentationMultiGridStripXYAlg::Initialize ( const gar::geo::GeometryCore geo)
overridevirtual

Implements gar::geo::seg::SegmentationAlg.

Definition at line 86 of file SegmentationMultiGridStripXYAlg.cxx.

87  {
88 
89  }
bool gar::geo::seg::SegmentationMultiGridStripXYAlg::isBarrel ( const gar::raw::CellID_t cID) const
overridevirtual

Implements gar::geo::seg::SegmentationAlg.

Definition at line 363 of file SegmentationMultiGridStripXYAlg.cxx.

364  {
365  bool isBarrel = true;
366 
367  int det_id = _decoder->get(cID, "system");
368  int module = _decoder->get(cID, "module");
369  if( det_id == 2 && (module == 0 || module == 6) ) isBarrel = false;
370 
371  return isBarrel;
372  }
const BitFieldCoder * _decoder
long64 get(long64 bitfield, size_t index) const
bool isBarrel(const gar::raw::CellID_t &cID) const override
bool gar::geo::seg::SegmentationMultiGridStripXYAlg::isTile ( const gar::raw::CellID_t cID) const
overridevirtual

Implements gar::geo::seg::SegmentationAlg.

Definition at line 331 of file SegmentationMultiGridStripXYAlg.cxx.

332  {
333  bool isTile = false;
334 
335  unsigned int det_id = _decoder->get(cID, "system");
336  unsigned int layer = _decoder->get(cID, _layerId);
337 
338  std::array<std::vector<unsigned int>, 2> _list;
339 
340  if(det_id == 1)
342  if(det_id == 2)
344 
345  //Check if it is tile configuration
346  for(unsigned int i = 0; i < _list.at(0).size(); i++)
347  {
348  if( layer >= _list.at(0).at(i) && layer <= _list.at(1).at(i) )
349  {
350  // std::cout << layer << " " << _list.at(0).at(i) << " " << _list.at(1).at(i) << std::endl;
351  isTile = true;
352  break;
353  }
354  else{
355  continue;
356  }
357  }
358 
359  return isTile;
360  }
const BitFieldCoder * _decoder
std::vector< std::string > _gridBarrelLayers
the layers (start::end) for grid in Barrel
std::array< std::vector< unsigned int >, 2 > TokenizeLayerVectors(std::vector< std::string > grid) const
bool isTile(const gar::raw::CellID_t &cID) const override
std::string _layerId
the field name used for layer
long64 get(long64 bitfield, size_t index) const
std::vector< std::string > _gridEndcapLayers
the layers (start::end) for grid in Endcap
const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::layerDimX ( ) const
inline

Definition at line 59 of file SegmentationMultiGridStripXYAlg.h.

const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::layerDimY ( ) const
inline

Definition at line 61 of file SegmentationMultiGridStripXYAlg.h.

const unsigned int& gar::geo::seg::SegmentationMultiGridStripXYAlg::nLayers ( ) const
inlineoverridevirtual

Reimplemented from gar::geo::seg::SegmentationAlg.

Definition at line 71 of file SegmentationMultiGridStripXYAlg.h.

71 { return _nLayers; }
const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::offsetX ( ) const
inline

Definition at line 55 of file SegmentationMultiGridStripXYAlg.h.

55 { return _offsetX; }
const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::offsetY ( ) const
inline

Definition at line 57 of file SegmentationMultiGridStripXYAlg.h.

57 { return _offsetY; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::PrintParameters ( ) const
overrideprotectedvirtual

Implements gar::geo::seg::SegmentationAlg.

Definition at line 264 of file SegmentationMultiGridStripXYAlg.cxx.

265  {
266  std::cout << "cell encoding: " << _encoding << std::endl;
267  std::cout << "identifier_x: " << _xId << std::endl;
268  std::cout << "identifier_y: " << _yId << std::endl;
269  std::cout << "grid_size_x: " << _gridSizeX << " cm" << std::endl;
270  std::cout << "grid_size_y: " << _gridSizeY << " cm" << std::endl;
271  std::cout << "strip_size_x: " << _stripSizeX << " cm" << std::endl;
272  std::cout << "strip_size_y: " << _stripSizeY << " cm" << std::endl;
273  std::cout << "offset_x: " << _offsetX << " cm" << std::endl;
274  std::cout << "offset_y: " << _offsetY << " cm" << std::endl;
275 
276  std::cout << "identifier_layer: " << _layerId << std::endl;
277  std::cout << "identifier_slice: " << _sliceId << std::endl;
278  std::cout << "active slice: " << _active_slice << std::endl;
279  std::cout << "nlayers: " << _nLayers << std::endl;
280 
281  std::cout << "grid_barrel_layers: ";
282  for(unsigned int i = 0; i < _gridBarrelLayers.size(); i++)
283  std::cout << _gridBarrelLayers.at(i) << " ";
284  std::cout << std::endl;
285 
286  std::cout << "strip_barrel_layers: ";
287  for(unsigned int i = 0; i < _stripBarrelLayers.size(); i++)
288  std::cout << _stripBarrelLayers.at(i) << " ";
289  std::cout << std::endl;
290 
291  std::cout << "grid_endcap_layers: ";
292  for(unsigned int i = 0; i < _gridEndcapLayers.size(); i++)
293  std::cout << _gridEndcapLayers.at(i) << " ";
294  std::cout << std::endl;
295 
296  std::cout << "strip_endcap_layers: ";
297  for(unsigned int i = 0; i < _stripEndcapLayers.size(); i++)
298  std::cout << _stripEndcapLayers.at(i) << " ";
299  std::cout << std::endl;
300 
301  std::cout << "strip_on_same_layer: " << _OnSameLayer << std::endl;
302  }
std::vector< std::string > _gridBarrelLayers
the layers (start::end) for grid in Barrel
std::string _layerId
the field name used for layer
std::string _sliceId
the field name used for slice
std::vector< std::string > _stripBarrelLayers
the layers (start::end) for strips in Barrel
std::vector< std::string > _gridEndcapLayers
the layers (start::end) for grid in Endcap
std::vector< std::string > _stripEndcapLayers
the layers (start::end) for strips in Endcap
QTextStream & endl(QTextStream &s)
void gar::geo::seg::SegmentationMultiGridStripXYAlg::reconfigure ( fhicl::ParameterSet const &  pset)
overridevirtual

Implements gar::geo::seg::SegmentationAlg.

Definition at line 50 of file SegmentationMultiGridStripXYAlg.cxx.

51  {
52  _gridSizeX = pset.get<double>("grid_size_x");
53  _gridSizeY = pset.get<double>("grid_size_y");
54 
55  _stripSizeX = pset.get<double>("strip_size_x");
56  _stripSizeY = pset.get<double>("strip_size_y");
57  _encoding = pset.get<std::string>("cellEncoding");
58 
59  _offsetX = pset.get<double>("offset_x");
60  _offsetY = pset.get<double>("offset_y");
61 
62  _xId = pset.get<std::string>("identifier_x");
63  _yId = pset.get<std::string>("identifier_y");
64  _layerId = pset.get<std::string>("identifier_layer");
65  _sliceId = pset.get<std::string>("identifier_slice");
66 
67  _gridBarrelLayers = pset.get< std::vector<std::string> >("grid_barrel_layers");
68  _stripBarrelLayers = pset.get< std::vector<std::string> >("strip_barrel_layers");
69 
70  _gridEndcapLayers = pset.get< std::vector<std::string> >("grid_endcap_layers");
71  _stripEndcapLayers = pset.get< std::vector<std::string> >("strip_endcap_layers");
72 
73  _nLayers = pset.get<unsigned int>("nlayers");
74  _active_slice = pset.get<unsigned int>("active_slice");
75 
76  _frac = 1./3.;
77 
78  _OnSameLayer = pset.get<bool>("strip_on_same_layer");
79 
80  this->PrintParameters();
81 
82  return;
83  }
double _frac
fraction of tiles to remove at the edge
std::string string
Definition: nybbler.cc:12
std::vector< std::string > _gridBarrelLayers
the layers (start::end) for grid in Barrel
std::string _layerId
the field name used for layer
std::string _sliceId
the field name used for slice
std::vector< std::string > _stripBarrelLayers
the layers (start::end) for strips in Barrel
std::vector< std::string > _gridEndcapLayers
the layers (start::end) for grid in Endcap
std::vector< std::string > _stripEndcapLayers
the layers (start::end) for strips in Endcap
std::array< double, 3 > gar::geo::seg::SegmentationMultiGridStripXYAlg::ReconstructStripHitPosition ( const gar::geo::GeometryCore geo,
const std::array< double, 3 > &  local,
const float &  xlocal,
const gar::raw::CellID_t cID 
) const
overridevirtual

Reimplemented from gar::geo::seg::SegmentationAlg.

Definition at line 508 of file SegmentationMultiGridStripXYAlg.cxx.

509  {
510  float pos = xlocal;
511  //Need to check if the local position is bigger than the strip length!
512  bool isBarrel = this->isBarrel(cID);
513  float stripLength = this->getStripLength(geo, local, cID);
514 
515  if(isBarrel) {
516  if( std::abs(pos) > stripLength / 2. ) pos = (pos > 0) ? stripLength / 2. : -stripLength / 2.;
517  } else {
518  if( std::abs(pos) > stripLength ) pos = (pos > 0) ? stripLength : 0.;
519  }
520 
521  std::array<double, 3> newlocal;
522 
523  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 == 0) )
524  newlocal = {pos, local[1], local[2]};
525 
526  if( (_OnSameLayer && _decoder->get(cID, _sliceId) == _active_slice+1) || (not _OnSameLayer && _decoder->get(cID, _layerId)%2 != 0) ) //Strip along Y
527  newlocal = {local[0], pos, local[2]};
528 
529  return newlocal;
530  }
const BitFieldCoder * _decoder
double getStripLength(const gar::geo::GeometryCore &geo, const std::array< double, 3 > &local, const gar::raw::CellID_t &cID) const override
T abs(T value)
std::string _layerId
the field name used for layer
std::string _sliceId
the field name used for slice
long64 get(long64 bitfield, size_t index) const
bool isBarrel(const gar::raw::CellID_t &cID) const override
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setFieldNameLayer ( const std::string fieldName)
inline

Definition at line 89 of file SegmentationMultiGridStripXYAlg.h.

89 { _layerId = fieldName; }
std::string _layerId
the field name used for layer
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setFieldNameSlice ( const std::string fieldName)
inline

Definition at line 91 of file SegmentationMultiGridStripXYAlg.h.

91 { _sliceId = fieldName; }
std::string _sliceId
the field name used for slice
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setFieldNameX ( const std::string fieldName)
inline

Definition at line 85 of file SegmentationMultiGridStripXYAlg.h.

85 { _xId = fieldName; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setFieldNameY ( const std::string fieldName)
inline

Definition at line 87 of file SegmentationMultiGridStripXYAlg.h.

87 { _yId = fieldName; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setGridSizeX ( double  cellSize)
inline

Definition at line 73 of file SegmentationMultiGridStripXYAlg.h.

73 { _gridSizeX = cellSize; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setGridSizeY ( double  cellSize)
inline

Definition at line 75 of file SegmentationMultiGridStripXYAlg.h.

75 { _gridSizeY = cellSize; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setLayerDimXY ( const double &  dimX,
const double &  dimY 
) const
inlineoverridevirtual
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setOffsetX ( double  offset)
inline

Definition at line 81 of file SegmentationMultiGridStripXYAlg.h.

81 { _offsetX = offset; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setOffsetY ( double  offset)
inline

Definition at line 83 of file SegmentationMultiGridStripXYAlg.h.

83 { _offsetY = offset; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setStripSizeX ( double  stripSize)
inline

Definition at line 77 of file SegmentationMultiGridStripXYAlg.h.

77 { _stripSizeX = stripSize; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setStripSizeY ( double  stripSize)
inline

Definition at line 79 of file SegmentationMultiGridStripXYAlg.h.

79 { _stripSizeY = stripSize; }
void gar::geo::seg::SegmentationMultiGridStripXYAlg::setVariables ( const double &  innerangle,
const double &  endcapsidelength 
) const
inlineoverridevirtual
const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::stripSizeX ( ) const
inlineoverridevirtual

Reimplemented from gar::geo::seg::SegmentationAlg.

Definition at line 51 of file SegmentationMultiGridStripXYAlg.h.

const double& gar::geo::seg::SegmentationMultiGridStripXYAlg::stripSizeY ( ) const
inline

Definition at line 53 of file SegmentationMultiGridStripXYAlg.h.

std::array< std::vector< unsigned int >, 2 > gar::geo::seg::SegmentationMultiGridStripXYAlg::TokenizeLayerVectors ( std::vector< std::string grid) const
protected

Definition at line 305 of file SegmentationMultiGridStripXYAlg.cxx.

306  {
307  std::vector<unsigned int> _gridFirst;
308  std::vector<unsigned int> _gridLast;
309 
310  for(unsigned int i = 0; i < grid.size(); i++)
311  {
312  std::vector<std::string> descriptors ;
313  Tokenizer t( descriptors ,':') ;
314 
315  std::string value = grid.at(i);
316  std::for_each( value.begin(), value.end(), t ) ;
317 
318  // std::cout << descriptors.size() << std::endl;
319  // for(unsigned int ii = 0; ii < descriptors.size(); ii++)
320  // std::cout << descriptors.at(ii) << std::endl;
321 
322  _gridFirst.push_back(std::atoi(descriptors.at(0).c_str()));
323  _gridLast.push_back(std::atoi(descriptors.at(1).c_str()));
324  }
325 
326  std::array<std::vector<unsigned int>, 2> _list = {{_gridFirst, _gridLast}};
327  return _list;
328  }
std::string string
Definition: nybbler.cc:12

Member Data Documentation

unsigned int gar::geo::seg::SegmentationMultiGridStripXYAlg::_active_slice
protected

active slice number

Definition at line 130 of file SegmentationMultiGridStripXYAlg.h.

std::string gar::geo::seg::SegmentationMultiGridStripXYAlg::_encoding
protected

the encoding string

Definition at line 120 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_EndcapSideLength
mutableprotected

Endcap Side Length.

Definition at line 146 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_frac
protected

fraction of tiles to remove at the edge

Definition at line 126 of file SegmentationMultiGridStripXYAlg.h.

std::vector<std::string> gar::geo::seg::SegmentationMultiGridStripXYAlg::_gridBarrelLayers
protected

the layers (start::end) for grid in Barrel

Definition at line 132 of file SegmentationMultiGridStripXYAlg.h.

std::vector<std::string> gar::geo::seg::SegmentationMultiGridStripXYAlg::_gridEndcapLayers
protected

the layers (start::end) for grid in Endcap

Definition at line 136 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_gridSizeX
protected

the grid size in X

Definition at line 104 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_gridSizeY
protected

the grid size in Y

Definition at line 108 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_InnerAngle
mutableprotected

Inner Angle.

Definition at line 144 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_layer_dim_X
mutableprotected

layer dimension in X

Definition at line 140 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_layer_dim_Y
mutableprotected

layer dimension in Y

Definition at line 142 of file SegmentationMultiGridStripXYAlg.h.

std::string gar::geo::seg::SegmentationMultiGridStripXYAlg::_layerId
protected

the field name used for layer

Definition at line 116 of file SegmentationMultiGridStripXYAlg.h.

unsigned int gar::geo::seg::SegmentationMultiGridStripXYAlg::_nLayers
protected

number of layers

Definition at line 128 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_offsetX
protected

the coordinate offset in X

Definition at line 106 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_offsetY
protected

the coordinate offset in Y

Definition at line 110 of file SegmentationMultiGridStripXYAlg.h.

bool gar::geo::seg::SegmentationMultiGridStripXYAlg::_OnSameLayer
protected

are the strips on the same layer?

Definition at line 148 of file SegmentationMultiGridStripXYAlg.h.

std::string gar::geo::seg::SegmentationMultiGridStripXYAlg::_sliceId
protected

the field name used for slice

Definition at line 118 of file SegmentationMultiGridStripXYAlg.h.

std::vector<std::string> gar::geo::seg::SegmentationMultiGridStripXYAlg::_stripBarrelLayers
protected

the layers (start::end) for strips in Barrel

Definition at line 134 of file SegmentationMultiGridStripXYAlg.h.

std::vector<std::string> gar::geo::seg::SegmentationMultiGridStripXYAlg::_stripEndcapLayers
protected

the layers (start::end) for strips in Endcap

Definition at line 138 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_stripSizeX
protected

the strip size in X

Definition at line 122 of file SegmentationMultiGridStripXYAlg.h.

double gar::geo::seg::SegmentationMultiGridStripXYAlg::_stripSizeY
protected

the strip size in Y

Definition at line 124 of file SegmentationMultiGridStripXYAlg.h.

std::string gar::geo::seg::SegmentationMultiGridStripXYAlg::_xId
protected

the field name used for X

Definition at line 112 of file SegmentationMultiGridStripXYAlg.h.

std::string gar::geo::seg::SegmentationMultiGridStripXYAlg::_yId
protected

the field name used for Y

Definition at line 114 of file SegmentationMultiGridStripXYAlg.h.


The documentation for this class was generated from the following files: