GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testXMLOut.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 <iostream>
11 
12 using namespace gear;
13 using namespace std;
14 
15 void dumpCoordinates( PadRowLayout2D *layout)
16 {
17  cout << "#--------------------------------" << endl;
18  for (int row = 0; row < layout->getNRows() ; row++)
19  {
20  const std::vector< int > & padsInRow = layout->getPadsInRow (row);
21  for ( unsigned int i=0; i < (padsInRow.size() < 10 ? padsInRow.size() : 10 ); i++)
22  {
23  Vector2D padCenter = layout->getPadCenter(padsInRow[i]);
24 
25  // reretrieve the padIndex from the layout
26  int padIndex = layout->getNearestPad( padCenter[0] , padCenter[1] );
27 
28  cout << padCenter[0] << "\t" << padCenter[1] << "\t"
29  << padsInRow[i] << "\t" << padIndex << endl;
30  }
31  }
32 }
33 
34 int main()
35 {
36  // create a module with rectangular layout
37  RectangularPadRowLayout *rectangularPadPlane = new RectangularPadRowLayout(-10, 10);
38  rectangularPadPlane->addRow(3, 10, 2., 5.);
39 
40 // dumpCoordinates( rectangularPadPlane );
41 
42  //
43  TPCModuleImpl *rectangularModule1 = new TPCModuleImpl(0, rectangularPadPlane, PadRowLayout2D::CARTESIAN, 40);
44  rectangularModule1->setIntVal("myIntForForTheModule",43);
45 
46  rectangularModule1->setOffset(25. ,20.);
47  rectangularModule1->setAngle(M_PI/4);
48 // dumpCoordinates( rectangularModule1 );
49 
50 // TPCModuleImpl *rectangularModule2 = new TPCModuleImpl(1, new RectangularPadRowLayout(*rectangularPadPlane), PadRowLayout2D::POLAR, 40);
51 // dumpCoordinates( rectangularModule2 );
52 
53 // rectangularModule2->setOffset(25. ,20.);
54 // rectangularModule2->setAngle(M_PI/4);
55 // dumpCoordinates( rectangularModule2 );
56 
57  FixedPadSizeDiskLayout *circularPadPlane = new FixedPadSizeDiskLayout(15., 30., 5., 2.);
58 
59 
60  TPCModuleImpl *circularModule1 = new TPCModuleImpl(2, circularPadPlane, PadRowLayout2D::CARTESIAN, 40);
61 
62  circularModule1->setOffset(25. ,20.);
63  circularModule1->setAngle(M_PI/4);
64 // dumpCoordinates( circularModule1 );
65 
66  TPCModuleImpl *circularModule2 = new TPCModuleImpl(3, new FixedPadSizeDiskLayout(*circularPadPlane), PadRowLayout2D::POLAR, 40);
67 
68  circularModule2->setOffset(25. ,20.);
69  circularModule2->setAngle(M_PI/4);
70 // dumpCoordinates( circularModule2 );
71 
72 
73  TPCParametersImpl *modularTPCRectangular = new TPCParametersImpl(260.4, PadRowLayout2D::CARTESIAN );
74 
75  modularTPCRectangular->addModule(rectangularModule1);
76 // modularTPCRectangular->addModule(rectangularModule2);
77  modularTPCRectangular->addModule(circularModule1);
78 
79  TPCParametersImpl *modularTPCCircular = new TPCParametersImpl(260.4, PadRowLayout2D::POLAR );
80 
81  // modularTPCCircular->addModule(rectangularModule2);
82  modularTPCCircular->addModule(circularModule2);
83 
84  modularTPCRectangular->setIntVal("myIntForTheTPC",42);
85 
86  GearMgr *myGearMgr = new GearMgrImpl;
87 
88  TPCParametersXML *modularTPCXML = new TPCParametersXML;
89 
90  TiXmlElement modularTPCElement = modularTPCXML->toXML(*modularTPCRectangular );
91  cout << modularTPCElement<<endl;
92  cout << modularTPCXML->toXML(*modularTPCCircular )<<endl;
93 
94  delete modularTPCCircular; delete modularTPCRectangular; delete modularTPCXML; delete myGearMgr;
95 }
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.
Manager class that returns the Gear classes for the relevant subdetectors.
Definition: GearMgrImpl.h:23
Abstract XML handler for TPCParameters.
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.
The element is a container class.
Definition: tinyxml.h:827
virtual void setIntVal(const std::string &key, int val)
Set Integer value for key.
A Container for TPCModules which describe the geometry properties of a given TPC. ...
virtual void addModule(TPCModule *TPCModule)
Adds a Module to the vector of modules, or throws an exception.
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).
Implementation of PadRowLayout2D for a rectangular row based layout where all pads in a given row are...
virtual TiXmlElement toXML(const GearParameters &modularTPC) const
Creates an XML node for the given TPCParameters.
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).