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