1 #include "gearimpl/RectangularPadRowLayout.h"
2 #include "gearimpl/Util.h"
3 #include "gearxml/GearXML.h"
4 #include "gear/GearMgr.h"
15 #include "AIDA/AIDA.h"
16 using namespace AIDA ;
20 using namespace gear ;
25 void gear_unexpected(){
31 }
catch( std::exception& e) {
33 std::cout <<
" A runtime error has occured : "
36 <<
" the program will have to be terminated - sorry." << std::endl ;
43 std::cout <<
" An unknown runtime error has occured : "
45 <<
" the program will have to be terminated - sorry." << std::endl ;
55 int main(
int argc,
char**argv){
58 std::set_unexpected( gear_unexpected ) ;
59 std::set_terminate( gear_unexpected ) ;
62 std::cout <<
" testgear: Testprogram for TPC prototype description " << std::endl
63 <<
" usage: testtpcproto input.xml " << std::endl ;
67 std::string fileName( argv[1] ) ;
71 GearMgr* gearMgr = gearXML.createGearMgr() ;
74 std::cout <<
" testtpcproto - instantiated GearMgr from file " << fileName
77 std::cout << *gearMgr << std::endl ;
84 testRectangularPadRowLayout( pl ) ;
86 catch(std::bad_cast& e){
87 std::cout <<
" wrong type of layout - expected RectangularPadRowLayout ! " << std::endl ;
92 GearXML::createXMLFile( gearMgr,
"testgear_out.xml" ) ;
103 std::string storeName(
"aidaroot.root");
105 IAnalysisFactory * myaida = AIDA_createAnalysisFactory() ;
107 ITreeFactory * mytreefactory = myaida->createTreeFactory() ;
109 ITree * mytree = mytreefactory->create(storeName,
"root",
false,
true,
"none") ;
112 IHistogramFactory * myhistofactory = myaida->createHistogramFactory( *mytree ) ;
124 std::cout <<
" RectangularPadRowLayout : " << std::endl
125 <<
" xMin: " << xmin << std::endl
126 <<
" xMax: " << xmax << std::endl
127 <<
" yMin: " << ymin << std::endl
128 <<
" yMax: " << ymax << std::endl
131 <<
" nRows : " << nRow << std::endl
136 IHistogram2D *padMap = myhistofactory->createHistogram2D(
"padMap",
143 for(
int i = 0 ; i < nRow ; i++) {
145 if( i==0 || i == nRow-1 )
146 std::cout <<
" --------- row : " << i << std::endl ;
150 int nPad = pads.size() ;
153 for(
int j = 0 ; j < nPad ; j++) {
177 for(
unsigned k=0;k<1000;++k){
178 double x = xmin + ( xmax - xmin ) * rand()/ double(RAND_MAX ) ;
179 double y = ymin + ( ymax - ymin ) * rand()/ double(RAND_MAX ) ;
182 padMap->fill( x , y ) ;
187 if( (i==0 && j < 10 ) || ( i == nRow-1 && j > nPad-9 ) ) {
189 std::cout <<
" pad: "
190 <<
" [" << iRow <<
"," << iPad <<
"] "
191 <<
" - ( " << p[0] <<
" , " << p[1] <<
") "
196 assert( pl.
isInsidePad( p[0] , p[1] , pads[j] ) ) ;
200 assert( nPadTotal == pl.
getNPads() ) ;
virtual int getNPads() const
The total number of pads in the TPC.
virtual int getRowNumber(int padIndex) const
The number of the row that contains the pad at padIndex - numbering starts at y==0 (bottom)...
virtual const TPCParameters & getTPCParameters() const =0
Get the TPCParameters.
virtual int getNearestPad(double x, double y) const
The index of the pad nearest to the given point in 2d coordinates (x,y,) or (r,phi).
virtual int getPadIndex(int rowNum, int padNum) const
Create a padIndex for the given row and pad ( column ) number.
Implementation of GEAR using XML.
virtual const std::vector< int > & getPadsInRow(int rowNumber) const
Indices of all pads in row rowNumber (row indices start from 0 at the bottom (CARTESIAN) or at the ce...
virtual double getPadWidth(int padIndex) const
The width of the pad at padIndex in mm.
virtual Vector2D getPadCenter(int padIndex) const
The center of the pad in 2d coordinates, (x,y) or (r,phi).
virtual int getPadNumber(int padIndex) const
The pad number (column) within the row - numbering starts at x==0 (left).
virtual bool isInsidePad(double x, double y, int padIndex) const
True if coordinate (x,y) is within the given pad.
virtual int getRightNeighbour(int padIndex) const
The index of the right neighbour pad.
virtual double getPadHeight(int padIndex) const
The height of the pad in mm.
virtual const std::vector< double > & getPlaneExtent() const
Extent of the sensitive plane - [xmin,xmax,ymin,ymax] CARTESIAN or [rmin,rmax,phimin,phimax] POLAR.
virtual int getLeftNeighbour(int padIndex) const
The index of the left neighbour pad.
virtual const PadRowLayout2D & getPadLayout() const =0
Kept for backward compatibility.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
Implementation of PadRowLayout2D for a rectangular row based layout where all pads in a given row are...
virtual int getNRows() const
The number of rows.