GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testVersatileLayout.cc
1 #include <gearimpl/TPCModuleImpl.h>
2 #include <gearimpl/RectangularPadRowLayout.h>
3 #include <gearimpl/FixedPadSizeDiskLayout.h>
4 #include <gearimpl/FixedPadAngleDiskLayout.h>
5 #include <gearimpl/VersatileDiskRowLayout.h>
6 #include <gear/PadRowLayout2D.h>
7 #include <cmath>
8 #include <iostream>
9 
10 using namespace gear;
11 using namespace std;
12 
13 void dumpCoordinates( PadRowLayout2D *layout)
14 {
15  cout << "#--------------------------------" << endl;
16  for (int row = 0; row < layout->getNRows() ; row++)
17  {
18  const std::vector< int > & padsInRow = layout->getPadsInRow (row);
19 // for ( unsigned int i=0; i < (padsInRow.size() < 10 ? padsInRow.size() : 10 ); i++)
20  for ( unsigned int i=0; i < padsInRow.size() ; i++)
21  {
22  Vector2D padCenter = layout->getPadCenter(padsInRow[i]);
23 
24  // reretrieve the padIndex from the layout
25  int padIndex = layout->getNearestPad( padCenter[0] , padCenter[1] );
26 
27  cout << padCenter[0] << "\t" << padCenter[1] << "\t"
28  << padsInRow[i] << "\t" << padIndex << endl;
29  }
30  }
31 }
32 
33 int main()
34 {
35  VersatileDiskRowLayout *circularPadPlane = new VersatileDiskRowLayout(15.);
36  circularPadPlane->addRow( 10 /*nPads*/,
37  2. /*padPitch*/,
38  10. /*rowHeight*/,
39  0. /*offset*/);
40  circularPadPlane->addRow( 10 /*nPads*/,
41  2. /*padPitch*/,
42  10. /*rowHeight*/,
43  1. /*offset*/,0,0,3);
44  circularPadPlane->addRow( 10 /*nPads*/,
45  2. /*padPitch*/,
46  10. /*rowHeight*/,
47  -1. /*offset*/);
48 
49  dumpCoordinates( circularPadPlane );
50 
51  // get coordinates if pad centre 0
52 
53 
54  Vector2D padZeroCentre = circularPadPlane->getPadCenter( 0 );
55  cout << endl << "# pad centre: "<< padZeroCentre[0] << "\t" << padZeroCentre[1]<< endl<<endl;
56 
57  // now check the distances
58  cout << "# r\t phi\t d" << endl;
59  for (double phi = -M_PI*0.2; phi < M_PI*0.2; phi +=M_PI*0.005 )
60  {
61  double r = 10.;
62 // cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getDistanceToPad(r, phi, 0)<< endl;
63  cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getNearestPad(r, phi)<< endl;
64  }
65 
66  for (double r = 10.; r < 100.; r+=1.)
67  {
68  double phi = M_PI*0.2;
69 // cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getDistanceToPad(r, phi, 0)<< endl;
70  cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getNearestPad(r, phi)<< endl;
71  }
72 
73  for (double phi = M_PI*0.2; phi > -M_PI*0.2; phi -=M_PI*0.005 )
74  {
75  double r = 100.;
76 // cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getDistanceToPad(r, phi, 0)<< endl;
77  cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getNearestPad(r, phi)<< endl;
78  }
79 
80  for (double r = 100.; r > 10.; r-=1.)
81  {
82  double phi = -M_PI*0.2;
83 // cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getDistanceToPad(r, phi, 0)<< endl;
84  cout << r << "\t"<< phi<<"\t"<< circularPadPlane->getNearestPad(r, phi)<< endl;
85  }
86 
87 
88  delete circularPadPlane;
89 }
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
virtual int getNearestPad(double c0, double c1) const
The index of the pad nearest to the given point in 2d coordinates (x,y,) or (r,phi).
virtual void addRow(int nPads, double padPitch, double rowHeight, double offset=0., double padWidth=0., double padHeight=0., int repeat=1)
Add &#39;repeat&#39; rows with the given parameters.
virtual Vector2D getPadCenter(int padIndex) const
The center of the pad in 2d coordinates, (x,y) or (r,phi).
virtual int getNRows() const =0
The number of rows.
virtual const std::vector< int > & getPadsInRow(int rowNumber) const =0
Indices of all pads in row rowNumber (row indices start from 0 at the bottom (CARTESIAN) or at the ce...
virtual int getNearestPad(double c0, double c1) const =0
The index of the pad nearest to the given point in 2d coordinates (x,y,) or (r,phi).
Implementation of PadRowLayout2D for a wedge shaped module.
virtual Vector2D getPadCenter(int padIndex) const =0
The center of the pad in 2d coordinates, (x,y) or (r,phi).