GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
RectangularPadRowLayout.h
1 #ifndef RectangularPadRowLayout_h
2 #define RectangularPadRowLayout_h 1
3 
4 #include <vector>
5 #include "gear/PadRowLayout2D.h"
6 
7 
8 namespace gear {
9 
10 
11 
27 
28  public:
29 
31  struct Row{
32  int NPad {};
33  double PadWidth {};
34  double PadHeight {};
35  double Height {};
36  double LeftOffset {};
37  double RightOffset {};
38  double Center {};
39  double WidthPerPad {}; // pad + insensitive ( gap )
40  } ;
41 
42 
43  protected:
44  int _nRow {};
45  int _nPad {};
46  int _repeatRows {};
47  std::vector<Row> _rows {};
48  std::vector<double> _extent {};
49  mutable std::vector< std::vector<int>* > _padIndices {};
50  std::vector<unsigned> _nRows {}; // helper vector to keep track of equal rows
51 
57 
62  void cleanup();
63 
64  public:
65 
70  RectangularPadRowLayout( double xMin, double xMax , double yMin=0.0) ;
71 
76 
79 
81  virtual ~RectangularPadRowLayout() ;
82 
83  /* The clone function. Used to access the copy-constructor if this class via the
84  * acstract PadRowLayout2D interface.
85  */
86  PadRowLayout2D* clone() const;
87 
90  virtual void addRow( int nRow, int nPad , double padWidth , double padHeight ,
91  double rowHeight =0.0, double leftOffset =0.0 ,
92  double rightOffset =0.0 );
93 
94 
99  virtual void repeatRows(unsigned count) ;
100 
103  int getRepeatRowCount() const { return _repeatRows ; }
104 
105 
115  virtual int getPadLayoutType() const;
116 
120  virtual int getPadLayoutImplType() const { return PadRowLayout2D::RECTANGULARPADROWLAYOUT ; }
121 
125  virtual int getCoordinateType() const { return PadRowLayout2D::CARTESIAN ; }
126 
129  virtual int getPadShape() const { return PadRowLayout2D::RECTANGLE ; }
130 
133  virtual int getNPads() const { return _nPad ; }
134 
137  virtual int getNRows() const ;
138 
141  virtual double getRowHeight(int rowNumber) const ;
142 
145  virtual double getPadHeight(int padIndex) const ;
146 
151  virtual double getPadWidth(int padIndex) const ;
152 
156  virtual double getPadPitch( int padIndex ) const ;
157 
160  virtual Vector2D getPadCenter(int padIndex) const;
161 
162 
166  virtual const std::vector<int>& getPadsInRow(int rowNumber) const ;
167 
171  virtual const std::vector<double>& getPlaneExtent() const { return _extent ; }
172 
175  virtual int getRowNumber(int padIndex) const ;
176 
179  virtual int getPadNumber(int padIndex) const { return ( 0x0000ffff & padIndex ) ; }
180 
183  virtual int getPadIndex(int rowNum, int padNum) const;
184 
188  virtual int getNearestPad(double x, double y) const;
189 
190  int getNearestPadOld(double x, double y) const;
191 
194  virtual int getRightNeighbour(int padIndex) const;
195 
198  virtual int getLeftNeighbour(int padIndex) const;
199 
202  virtual bool isInsidePad(double x, double y, int padIndex) const;
203 
206  virtual bool isInsidePad(double x, double y) const;
207 
210  virtual double getDistanceToPad(double c0, double c1, int padIndex) const;
211 
212 
214  const std::vector<unsigned>& equalRowNumbers() const { return _nRows ; }
215 
217  const std::vector<Row>& rows() const { return _rows ; }
218 
219  protected:
220 
224  double distanceToBox( const Vector2D& p , double xMin, double yMin, double xMax, double yMax ) const ;
225 
226  }; // class
227 
228 } // namespace gear
229 #endif // ifndef RectangularPadRowLayout_h
int getRepeatRowCount() const
Returns the number number for which a given row pattern has been repaeted.
double distanceToBox(const Vector2D &p, double xMin, double yMin, double xMax, double yMax) const
Helper function for finding the nearest pad - returns the distance for points outside the box and -1...
virtual int getNPads() const
The total number of pads in the TPC.
virtual double getDistanceToPad(double c0, double c1, int padIndex) const
Returns the closest distance to the edge (outer border) of the pad.
virtual int getRowNumber(int padIndex) const
The number of the row that contains the pad at padIndex - numbering starts at y==0 (bottom)...
const std::vector< Row > & rows() const
Helper method with all row data.
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
virtual double getPadPitch(int padIndex) const
The pitch (i.
virtual int getPadShape() const
The shape of the pads: PadRowLayout2D::RECTANGLE (i.e.
virtual int getNearestPad(double x, double y) const
The index of the pad nearest to the given point in 2d coordinates (x,y,) or (r,phi).
PadRowLayout2D * clone() const
Returns a copy (clone) of this class.
virtual int getPadIndex(int rowNum, int padNum) const
Create a padIndex for the given row and pad ( column ) number.
virtual ~RectangularPadRowLayout()
Destructor.
virtual const std::vector< int > & getPadsInRow(int rowNumber) const
Indices of all pads in row rowNumber (row indices start from 0 at the bottom (CARTESIAN) or at the ce...
virtual double getPadWidth(int padIndex) const
The width of the pad at padIndex in mm.
virtual Vector2D getPadCenter(int padIndex) const
The center of the pad in 2d coordinates, (x,y) or (r,phi).
RectangularPadRowLayout(double xMin, double xMax, double yMin=0.0)
Construct the empty RectangularPadRowLayout with the width and x position specified through xMin and ...
const std::vector< unsigned > & equalRowNumbers() const
Helper method to identify equal row numbers in this layout (as they have been added).
virtual void addRow(int nRow, int nPad, double padWidth, double padHeight, double rowHeight=0.0, double leftOffset=0.0, double rightOffset=0.0)
Add nRow rows with the given parameters.
virtual int getPadNumber(int padIndex) const
The pad number (column) within the row - numbering starts at x==0 (left).
RectangularPadRowLayout & operator=(const RectangularPadRowLayout &)
The assignment operator.
virtual double getRowHeight(int rowNumber) const
The row height in mm.
virtual bool isInsidePad(double x, double y, int padIndex) const
True if coordinate (x,y) is within the given pad.
void cleanup()
function to delete all the objects pointed to and owned by the GearMgr.
virtual int getRightNeighbour(int padIndex) const
The index of the right neighbour pad.
virtual double getPadHeight(int padIndex) const
The height of the pad in mm.
virtual const std::vector< double > & getPlaneExtent() const
Extent of the sensitive plane - [xmin,xmax,ymin,ymax] CARTESIAN or [rmin,rmax,phimin,phimax] POLAR.
void copy_and_assign(const RectangularPadRowLayout &)
function to copy all internal variables, incl.
virtual void repeatRows(unsigned count)
Repeat the current rows &#39;count&#39; times - this allows to easily repeat a pattern of several rows...
virtual int getLeftNeighbour(int padIndex) const
The index of the left neighbour pad.
virtual int getCoordinateType() const
The type of the row layouts coordinate system: PadRowLayout2D.CARTESIAN.
Implementation of PadRowLayout2D for a rectangular row based layout where all pads in a given row are...
Internal helper class for RectangularPadRowLayout.
virtual int getPadLayoutImplType() const
The type of the row layout implementation: PadRowLayout2D.RECTANGULARPADROWLAYOUT.
virtual int getNRows() const
The number of rows.