GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testGearMgr.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 
13 using namespace gear;
14 using namespace std;
15 
16 void dumpCoordinates( PadRowLayout2D *layout)
17 {
18  cout << "#--------------------------------" << endl;
19  for (int row = 0; row < layout->getNRows() ; row++)
20  {
21  const std::vector< int > & padsInRow = layout->getPadsInRow (row);
22  for ( unsigned int i=0; i < (padsInRow.size() < 10 ? padsInRow.size() : 10 ); i++)
23  {
24  Vector2D padCenter = layout->getPadCenter(padsInRow[i]);
25 
26  // reretrieve the padIndex from the layout
27  int padIndex = layout->getNearestPad( padCenter[0] , padCenter[1] );
28 
29  cout << padCenter[0] << "\t" << padCenter[1] << "\t"
30  << padsInRow[i] << "\t" << padIndex << endl;
31  }
32  }
33 }
34 
35 int main(int argc,char* argv[])
36 {
37 
38  if (argc != 2)
39  {
40  cout << "usage: " << argv[0] << " gearfile.xml" << endl;
41  return 1;
42  }
43 // GearXML *xmlmgr = new GearXML("testFixedAngle.xml");
44 // GearXML *xmlmgr = new GearXML("gear_tpc_proto.xml");
45  GearXML *xmlmgr = new GearXML(argv[1]);
46  GearMgr *mgr = xmlmgr->createGearMgr();
47 
48  TPCParameters const & mTPC = mgr->getTPCParameters();
49 
50  const std::vector<TPCModule *> & moduleVec = mTPC.getModules();
51 
52  TPCParametersXML *modularTPCXML = new TPCParametersXML;
53 
54  cout << "vector size is "<< moduleVec.size() << endl;
55 
56 // for (std::vector<TPCModule *>::const_iterator moduleIter = moduleVec.begin() ;
57 // moduleIter < moduleVec.end() ; moduleIter++ )
58 // {
59 // cout << modularTPCXML->toXML(**moduleIter )<<endl;
60 // }
61  cout << modularTPCXML->toXML(mTPC )<<endl;
62 
63  cout << "drift distance is " << mTPC.getMaxDriftLength() << std::endl;
64 
65  // TiXmlElement modularTPCElement = modularTPCXML->toXML(*modularTPCRectangular );
66  // cout << modularTPCElement<<endl;
67  // cout << modularTPCXML->toXML(*modularTPCCircular )<<endl;
68 
69  delete xmlmgr; delete mgr; delete modularTPCXML;
70 }
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
Abstract XML handler for TPCParameters.
Implementation of GEAR using XML.
Definition: GearXML.h:18
virtual const std::vector< TPCModule * > & getModules() const =0
Returns vector of all modules in this TPC (endplate).
virtual int getNRows() const =0
The number of rows.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
Definition: GearMgr.h:36
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 double getMaxDriftLength() const =0
The maximum drift length in the TPC in mm.
virtual TiXmlElement toXML(const GearParameters &modularTPC) const
Creates an XML node for the given TPCParameters.
virtual Vector2D getPadCenter(int padIndex) const =0
The center of the pad in 2d coordinates, (x,y) or (r,phi).