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_terminate( gear_unexpected ) ;
61 std::cout <<
" testgear: Testprogram for TPC prototype description " << std::endl
62 <<
" usage: testtpcproto input.xml " << std::endl ;
66 std::string fileName( argv[1] ) ;
70 GearMgr* gearMgr = gearXML.createGearMgr() ;
73 std::cout <<
" testtpcproto - instantiated GearMgr from file " << fileName
76 std::cout << *gearMgr << std::endl ;
83 testRectangularPadRowLayout( pl ) ;
85 catch(std::bad_cast& e){
86 std::cout <<
" wrong type of layout - expected RectangularPadRowLayout ! " << std::endl ;
91 GearXML::createXMLFile( gearMgr,
"testgear_out.xml" ) ;
102 std::string storeName(
"aidaroot.root");
104 IAnalysisFactory * myaida = AIDA_createAnalysisFactory() ;
106 ITreeFactory * mytreefactory = myaida->createTreeFactory() ;
108 ITree * mytree = mytreefactory->create(storeName,
"root",
false,
true,
"none") ;
111 IHistogramFactory * myhistofactory = myaida->createHistogramFactory( *mytree ) ;
123 std::cout <<
" RectangularPadRowLayout : " << std::endl
124 <<
" xMin: " << xmin << std::endl
125 <<
" xMax: " << xmax << std::endl
126 <<
" yMin: " << ymin << std::endl
127 <<
" yMax: " << ymax << std::endl
130 <<
" nRows : " << nRow << std::endl
135 IHistogram2D *padMap = myhistofactory->createHistogram2D(
"padMap",
142 for(
int i = 0 ; i < nRow ; i++) {
144 if( i==0 || i == nRow-1 )
145 std::cout <<
" --------- row : " << i << std::endl ;
149 int nPad = pads.size() ;
152 for(
int j = 0 ; j < nPad ; j++) {
176 for(
unsigned k=0;k<1000;++k){
177 double x = xmin + ( xmax - xmin ) * rand()/ double(RAND_MAX ) ;
178 double y = ymin + ( ymax - ymin ) * rand()/ double(RAND_MAX ) ;
181 padMap->fill( x , y ) ;
186 if( (i==0 && j < 10 ) || ( i == nRow-1 && j > nPad-9 ) ) {
188 std::cout <<
" pad: "
189 <<
" [" << iRow <<
"," << iPad <<
"] "
190 <<
" - ( " << p[0] <<
" , " << p[1] <<
") "
195 assert( pl.
isInsidePad( p[0] , p[1] , pads[j] ) ) ;
199 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.