2 #include "gearimpl/FixedPadSizeDiskLayout.h"
3 #include "gearimpl/Util.h"
4 #include "gearxml/GearXML.h"
5 #include "gear/GearMgr.h"
9 #include "gearcga/CGAGearDistanceProperties.h"
10 #include "gearcga/CGAGearPointProperties.h"
23 using namespace gear ;
28 void gear_unexpected(){
34 }
catch( std::exception& e) {
36 std::cout <<
" A runtime error has occured : "
39 <<
" the program will have to be terminated - sorry." << std::endl ;
49 int main(
int argc,
char**argv){
52 std::set_terminate( gear_unexpected ) ;
55 std::cout <<
" testgear: Testprogram for gear classes. " << std::endl
56 <<
" usage: testgear input.xml " << std::endl ;
60 std::string fileName( argv[1] ) ;
64 GearMgr* gearMgr = gearXML.createGearMgr() ;
67 std::cout <<
" testgear - instantiated GearMgr from file " << fileName
70 std::cout << *gearMgr << std::endl ;
74 std::cout <<
" testgear - old point 3d : "
77 << p[2] << std::endl ;
103 std::cout <<
" wrong type of layout - TPCParameters should return a TPCModule ! " << std::endl ;
104 throw gear::Exception(
"wrong type of layout - TPCParameters should return a TPCModule");
110 std::cout <<
" wrong type of layout - expected FixedPadSizeDiskLayout ! " << std::endl ;
113 testFixedPadSizeDiskLayout( dynamic_cast<const FixedPadSizeDiskLayout &>(module.
getLocalPadLayout()) ) ;
117 std::cout <<
" oops - no TPC available :( " << std::endl ;
127 double bfield = gearMgr->
getBField().
at( 0, 0, 0 ).
z() ;
129 std::cout << std::endl
130 <<
" -- Bz at origin [double bfield = gearMgr->getBField().at( Vector3D(0,0,0) ).z() ;] : " << bfield
131 << std::endl << std::endl ;
135 std::cout <<
" oops - no BField available :( " << std::endl ;
141 std::ifstream inFile(
"mokka.steer");
142 std::stringstream steer;
144 while( ! inFile.eof() ) {
145 getline( inFile, line ) ;
146 steer << line << std::endl ;
153 std::vector<std::string> matNames, lvNames;
163 for(
unsigned int i=0; i<matNames.size();i++)
164 std::cout << matNames[i].c_str() << std::endl;
165 double bDl = distProp->
getBdL(initial,
final);
166 std::cout <<
"Bdl=" << bDl << std::endl;
167 double eDl = distProp->
getEdL(initial,
final);
168 std::cout <<
"Edl=" << eDl << std::endl;
174 const Vector3D position(0.0, 1730.0, 0.0);
176 std::cout <<
"Material: " <<
181 for(
unsigned int i=0; i<lvNames.size();i++)
182 std::cout << lvNames[i].c_str() << std::endl;
184 std::cout <<
"B=(" << B[0] <<
"," << B[1] <<
"," << B[2] <<
219 std::cout <<
" First (innermost) 10 pads and last (outermost) 10 pads : " << std::endl ;
221 for(
int i = 0 ; i < nRow ; i++) {
223 if( i==0 || i == nRow-1 )
224 std::cout <<
" --------- row : " << i << std::endl ;
228 int nPad = pads.size() ;
231 for(
int j = 0 ; j < nPad ; j++) {
253 if( (i==0 && j < 10 ) || ( i == nRow-1 && j > nPad-9 ) ) {
255 std::cout <<
" pad: "
256 <<
" [" << iRow <<
"," << iPad <<
"] "
257 <<
" - ( " << p[0] <<
" , " << p[1] <<
") "
262 assert( pl.
isInsidePad( p[0] , p[1] , pads[j] ) ) ;
269 assert( nPadTotal == pl.
getNPads() ) ;
280 Vector3D r2( r1[0] , r1[1] , r1[2] ) ;
283 std::cout <<
" test of Vector3D r : " << r[0] <<
", " << r[1] <<
", " << r[2] << std::endl ;
284 std::cout <<
" test of Vector3D r1 : " << r1[0] <<
", " << r1[1] <<
", " << r1[2] << std::endl ;
285 std::cout <<
" test of Vector3D r2: " << r2[0] <<
", " << r2[1] <<
", " << r2[2] << std::endl ;
286 std::cout <<
" test of Vector3D r3: " << r3[0] <<
", " << r3[1] <<
", " << r3[2] << std::endl ;
virtual int getNRows() const
The number of rows.
virtual const TPCParameters & getTPCParameters() const =0
Get the TPCParameters.
virtual Vector3D getB(const Vector3D &pos) const
The magnetic field vector at pos in [Tesla].
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
virtual int getPadNumber(int padIndex) const
The pad number (column) within the row - numbering starts at phi/x =.
Base exception class for GEAR - all other exceptions extend this.
CGA Implementation of the abstract interface that returns the (material) properties along a given dis...
virtual double getDensity(const Vector3D &pos) const
Density in kg/m^3 at pos.
Implementation of PadRowLayout2D for a disk with fixed sized keystone pads.
virtual int getNearestPad(double c0, double c1) const
The index of the pad nearest to the given point in 2d coordinates (x,y,) or (r,phi).
virtual const BField & getBField() const =0
Get the B field map.
Implementation of GEAR using XML.
NotImplementedException used for features that are not implemented.
virtual Vector3D at(Vector3D point) const =0
Returns the B field vector in Tesla at given point.
virtual int getRightNeighbour(int padIndex) const
The index of the right neighbour pad.
Simple three dimensional vector providing the components for cartesian, cylindrical and spherical coo...
virtual const PadRowLayout2D & getLocalPadLayout() const =0
Returns a reference to the instance of the underlaying pad layout.
UnknownParameterException call Processor::end().
static void createXMLFile(GearMgr *mgr, const std::string &fileName)
Write an XML file to disk from the given GearMgr object.
virtual int getPadLayoutImplType() const =0
The type of the row layout implementation: PadRowLayout2D.RECTANGULARPADROWLAYOUT, PadRowLayout2D.FIXEDPADSIZEDISKLAYOUT, PadRowLayout2D.FIXEDPADANGLEDISKLAYOUT or PadRowLayout2D.TPCMODULE.
virtual bool isInsidePad(double c0, double c1, int padIndex) const
True if coordinate (c0,c1) is within the given pad.
double z()
Cartesian cartesian z coordinate.
virtual const std::vector< std::string > & getMaterialNames(const Vector3D &p0, const Vector3D &p1) const
List of matrial names along the distance between [p0,p1] .
virtual std::vector< std::string > getListOfLogicalVolumes(const Vector3D &pos) const
Names of (geant4) logical volumes in heirarchy starting at given pos ending with the world volume...
virtual const PadRowLayout2D & getPadLayout() const =0
Kept for backward compatibility.
virtual const std::string & getMaterialName(const Vector3D &pos) const
Name of material at pos.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
CGA implementation of the abstract interface that returns the (material) properties of a given point ...
virtual int getLeftNeighbour(int padIndex) const
The index of the left neighbour pad.
virtual int getNPads() const
The total number of pads in the TPC.
virtual double getBdL(const Vector3D &p0, const Vector3D &p1) const
The integrated magnetic field along the distance between [p0,p1] in Tesla*mm.
virtual int getPadIndex(int rowNum, int padNum) const
Create a padIndex for the given row and pad ( column ) number.
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 int getRowNumber(int padIndex) const
The number of the row that contains the pad at padIndex - numbering starts at r/y==0.
virtual Vector2D getPadCenter(int padIndex) const
The center of the pad in 2d coordinates, (x,y) or (r,phi).
A wrapper Class for PadRowLayout2D which converts between the actual pad layouts local coodinate syst...
virtual double getEdL(const Vector3D &p0, const Vector3D &p1) const
The integrated electric field along the distance between [p0,p1] in mVolt.