GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testTPCModule.cc
1 #include <gearimpl/TPCModuleImpl.h>
2 #include <gearimpl/RectangularPadRowLayout.h>
3 #include <gearimpl/FixedPadSizeDiskLayout.h>
4 #include <gear/PadRowLayout2D.h>
5 #include <iostream>
6 
7 using namespace gear;
8 using namespace std;
9 
10 void dumpCoordinates( PadRowLayout2D *layout)
11 {
12  cout << "#--------------------------------" << endl;
13  for (int row = 0; row < layout->getNRows() ; row++)
14  {
15  const std::vector< int > & padsInRow = layout->getPadsInRow (row);
16  for ( unsigned int i=0; i < (padsInRow.size() < 10 ? padsInRow.size() : 10 ); i++)
17  {
18  Vector2D padCenter = layout->getPadCenter(padsInRow[i]);
19 
20  // reretrieve the padIndex from the layout
21  int padIndex = layout->getNearestPad( padCenter[0] , padCenter[1] );
22 
23  cout << padCenter[0] << "\t" << padCenter[1] << "\t"
24  << padsInRow[i] << "\t" << padIndex << endl;
25  }
26  }
27 }
28 
29 int main()
30 {
31  // create a module with rectangular layout
32  RectangularPadRowLayout *rectangularPadPlane = new RectangularPadRowLayout(-10, 10);
33  rectangularPadPlane->addRow(3, 10, 2., 5.);
34 
35  dumpCoordinates( rectangularPadPlane );
36 
37  //
38  TPCModuleImpl *rectangularModule1 = new TPCModuleImpl(0, rectangularPadPlane, PadRowLayout2D::CARTESIAN, 40);
39 
40  rectangularModule1->setOffset(25. ,20.);
41  rectangularModule1->setAngle(M_PI/4);
42  dumpCoordinates( rectangularModule1 );
43 
44 // TPCModuleImpl *rectangularModule2 = new TPCModuleImpl(0, new RectangularPadRowLayout(*rectangularPadPlane), PadRowLayout2D::POLAR, 40 );
45 // dumpCoordinates( rectangularModule2 );
46 //
47 // rectangularModule2->setOffset(25. ,20.);
48 // rectangularModule2->setAngle(M_PI/4);
49 // dumpCoordinates( rectangularModule2 );
50 
51  FixedPadSizeDiskLayout *circularPadPlane = new FixedPadSizeDiskLayout(15., 30., 5., 2.);
52 
53 
54  TPCModuleImpl *circularModule1 = new TPCModuleImpl(0, circularPadPlane, PadRowLayout2D::CARTESIAN, 40);
55 
56  circularModule1->setOffset(25. ,20.);
57  circularModule1->setAngle(M_PI/4);
58  dumpCoordinates( circularModule1 );
59 
60  TPCModuleImpl *circularModule2 = new TPCModuleImpl(0, new FixedPadSizeDiskLayout( *circularPadPlane), PadRowLayout2D::POLAR, 40);
61 
62  circularModule2->setOffset(25. ,20.);
63  circularModule2->setAngle(M_PI/4);
64  dumpCoordinates( circularModule2 );
65 
66  delete circularModule2; delete circularModule1; delete rectangularModule1; // delete rectangularModule2;
67 }
void setOffset(double x_r, double y_phi)
Set the offset of the local pad plane wrt.
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
Implementation of PadRowLayout2D for a disk with fixed sized keystone pads.
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 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 rectangular row based layout where all pads in a given row are...
A wrapper Class for PadRowLayout2D, allowing which converts between local and global coordinate syste...
Definition: TPCModuleImpl.h:23
virtual Vector2D getPadCenter(int padIndex) const =0
The center of the pad in 2d coordinates, (x,y) or (r,phi).