GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testPlaneExtent.cc
1 #include <gearimpl/TPCModuleImpl.h>
2 #include <gearimpl/RectangularPadRowLayout.h>
3 #include <gearimpl/FixedPadSizeDiskLayout.h>
4 #include <gearimpl/GearMgrImpl.h>
5 #include <gearimpl/TPCParametersImpl.h>
6 #include <gear/PadRowLayout2D.h>
7 #include <gearxml/XMLHandlerMgr.h>
8 #include <gearxml/TPCParametersXML.h>
9 #include <gearxml/tinyxml.h>
10 #include <gearxml/GearXML.h>
11 #include <iostream>
12 #include <cmath>
13 #include <complex>
14 
15 using namespace gear;
16 using namespace std;
17 
18 void dumpCoordinates( PadRowLayout2D *layout)
19 {
20  cout << "#--------------------------------" << endl;
21  for (int row = 0; row < layout->getNRows() ; row++)
22  {
23  const std::vector< int > & padsInRow = layout->getPadsInRow (row);
24 // for (unsigned int i=0; i < (padsInRow.size() < 10 ? padsInRow.size() : 10 ); i++)
25  for (unsigned int i=0; i < padsInRow.size() ; i++)
26  {
27  Vector2D padCenter = layout->getPadCenter(padsInRow[i]);
28 
29  cout << padCenter[0] << "\t" << padCenter[1] << endl;
30  }
31  }
32 }
33 
34 
35 
36 void dumpPlaneExtent(TPCModule const * module)
37 {
38  // define step in y/phi
39  // one degree for phi
40  // one mm for y
41  double y_phi_step;
42 
43  switch (module->getTPCCoordinateType())
44  {
45  case PadRowLayout2D::POLAR :
46  {
47  y_phi_step = M_PI/180.;
48  }
49  break;
50  case PadRowLayout2D::CARTESIAN :
51  {
52  y_phi_step = 1.;
53  }
54  break;
55  default:
56  throw gear::Exception("dumpPlaneExtent: unkown coorinate type");
57  }
58 
59 
60  // scan y_phi in 5 degree steps
61  for (double y_phi = module->getPlaneExtent()[2]; y_phi < module->getPlaneExtent()[3] ; y_phi += y_phi_step)
62  cout << module->getPlaneExtent()[0] << "\t"<<y_phi <<endl;
63 
64 
65  for (double r = module->getPlaneExtent()[0]; r < module->getPlaneExtent()[1]; r +=1)
66  cout << r << "\t"<< module->getPlaneExtent()[3] <<endl;
67 
68  // scan y_phi in 5 degree steps
69  for (double y_phi = module->getPlaneExtent()[3]; y_phi > module->getPlaneExtent()[2] ; y_phi -= y_phi_step)
70  cout << module->getPlaneExtent()[1] << "\t"<<y_phi <<endl;
71 
72  for (double r = module->getPlaneExtent()[1]; r > module->getPlaneExtent()[0]; r -=1)
73  cout << r << "\t"<< module->getPlaneExtent()[2] <<endl;
74 
75  // now the local plane extent
76  PadRowLayout2D const & localPadPlane = module->getLocalPadLayout();
77  // define step in y/phi
78  // one degree for phi
79  // one mm for y
80  double local_y_phi_step;
81 
82  switch (localPadPlane.getCoordinateType())
83  {
84  case PadRowLayout2D::POLAR :
85  {
86  local_y_phi_step = M_PI/180.;
87  }
88  break;
89  case PadRowLayout2D::CARTESIAN :
90  {
91  local_y_phi_step = 1.;
92  }
93  break;
94  default:
95  throw gear::Exception("dumpPlaneExtent: unkown coorinate type");
96  }
97 
98  for (double y_phi = localPadPlane.getPlaneExtent()[2]; y_phi < localPadPlane.getPlaneExtent()[3] ; y_phi += local_y_phi_step)
99  {
100  gear::Vector2D globalCoords = module->localToGlobal(localPadPlane.getPlaneExtent()[0] , y_phi);
101  cout << "0\t 0\t"<<globalCoords[0] << "\t"<< globalCoords[1] <<endl;
102  }
103 
104  for (double r = localPadPlane.getPlaneExtent()[0]; r < localPadPlane.getPlaneExtent()[1]; r +=1)
105  {
106  gear::Vector2D globalCoords = module->localToGlobal(r, localPadPlane.getPlaneExtent()[3]);
107  cout << "0\t 0\t"<<globalCoords[0] << "\t"<< globalCoords[1] <<endl;
108  }
109 
110  // scan y_phi in 5 degree steps
111  for (double y_phi = localPadPlane.getPlaneExtent()[3]; y_phi > localPadPlane.getPlaneExtent()[2] ; y_phi -= local_y_phi_step)
112  {
113  gear::Vector2D globalCoords = module->localToGlobal(localPadPlane.getPlaneExtent()[1] , y_phi);
114  cout << "0\t 0\t"<<globalCoords[0] << "\t"<< globalCoords[1] <<endl;
115  }
116 
117  for (double r = localPadPlane.getPlaneExtent()[1]; r > localPadPlane.getPlaneExtent()[0]; r -=1)
118  {
119  gear::Vector2D globalCoords = module->localToGlobal(r, localPadPlane.getPlaneExtent()[2]);
120  cout << "0\t 0\t"<<globalCoords[0] << "\t"<< globalCoords[1] <<endl;
121  }
122 }
123 
124 int main(int argc,char* argv[])
125 {
126  if (argc != 2)
127  {
128  cout << "Tool to dump coordinates of the local plane extend, the module extent and the pad centres." << endl;
129  cout << "usage: testPlaneExtent gearfile.xml" << endl;
130  return 1;
131  }
132 
133  GearXML *xmlmgr = new GearXML(argv[1]);
134  GearMgr *mgr = xmlmgr->createGearMgr();
135 
136  TPCParameters const & mTPC = mgr->getTPCParameters();
137 
138  const std::vector<TPCModule *> & moduleVec = mTPC.getModules();
139 
140  for (std::vector<TPCModule *>::const_iterator moduleIter = moduleVec.begin();
141  moduleIter < moduleVec.end(); moduleIter++)
142  {
143  dumpPlaneExtent(*moduleIter);
144  dumpCoordinates(*moduleIter);
145  }
146 
147  delete xmlmgr; delete mgr;
148 }
virtual const TPCParameters & getTPCParameters() const =0
Get the TPCParameters.
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
Proposal for an abstract interface that defines the geometry properties of a TPC like detector needed...
Definition: TPCParameters.h:24
GearMgr * createGearMgr()
Creates an instance of GearMgr from the data given in the XML file.
Definition: GearXML.cc:473
Base exception class for GEAR - all other exceptions extend this.
Definition: GEAR.h:41
Implementation of GEAR using XML.
Definition: GearXML.h:18
virtual Vector2D localToGlobal(double c0, double c1) const =0
Returns the global coordinates for a point in local coordinates.
virtual const std::vector< TPCModule * > & getModules() const =0
Returns vector of all modules in this TPC (endplate).
virtual const PadRowLayout2D & getLocalPadLayout() const =0
Returns a reference to the instance of the underlaying pad layout.
virtual int getCoordinateType() const =0
The type of the row layouts coordinate system: PadRowLayout2D.CARTESIAN or PadRowLayout2D.POLAR.
virtual int getNRows() const =0
The number of rows.
virtual int getTPCCoordinateType() const =0
Returns the TPCs coordinate type.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
Definition: GearMgr.h:36
virtual const std::vector< double > & getPlaneExtent() const =0
Inherited from PadRowLayout2D.
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 const std::vector< double > & getPlaneExtent() const =0
Extent of the sensitive plane - [xmin,xmax,ymin,ymax] CARTESIAN or [rmin,rmax,phimin,phimax] POLAR.
A wrapper Class for PadRowLayout2D which converts between the actual pad layouts local coodinate syst...
Definition: TPCModule.h:41
virtual Vector2D getPadCenter(int padIndex) const =0
The center of the pad in 2d coordinates, (x,y) or (r,phi).