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_unexpected( gear_unexpected ) ;
53 std::set_terminate( gear_unexpected ) ;
56 std::cout <<
" testgear: Testprogram for gear classes. " << std::endl
57 <<
" usage: testgear input.xml " << std::endl ;
61 std::string fileName( argv[1] ) ;
65 GearMgr* gearMgr = gearXML.createGearMgr() ;
68 std::cout <<
" testgear - instantiated GearMgr from file " << fileName
71 std::cout << *gearMgr << std::endl ;
75 std::cout <<
" testgear - old point 3d : "
78 << p[2] << std::endl ;
104 std::cout <<
" wrong type of layout - TPCParameters should return a TPCModule ! " << std::endl ;
105 throw gear::Exception(
"wrong type of layout - TPCParameters should return a TPCModule");
111 std::cout <<
" wrong type of layout - expected FixedPadSizeDiskLayout ! " << std::endl ;
114 testFixedPadSizeDiskLayout( dynamic_cast<const FixedPadSizeDiskLayout &>(module.
getLocalPadLayout()) ) ;
118 std::cout <<
" oops - no TPC available :( " << std::endl ;
128 double bfield = gearMgr->
getBField().
at( 0, 0, 0 ).
z() ;
130 std::cout << std::endl
131 <<
" -- Bz at origin [double bfield = gearMgr->getBField().at( Vector3D(0,0,0) ).z() ;] : " << bfield
132 << std::endl << std::endl ;
136 std::cout <<
" oops - no BField available :( " << std::endl ;
142 std::ifstream inFile(
"mokka.steer");
143 std::stringstream steer;
145 while( ! inFile.eof() ) {
146 getline( inFile, line ) ;
147 steer << line << std::endl ;
154 std::vector<std::string> matNames, lvNames;
164 for(
unsigned int i=0; i<matNames.size();i++)
165 std::cout << matNames[i].c_str() << std::endl;
166 double bDl = distProp->
getBdL(initial,
final);
167 std::cout <<
"Bdl=" << bDl << std::endl;
168 double eDl = distProp->
getEdL(initial,
final);
169 std::cout <<
"Edl=" << eDl << std::endl;
175 const Vector3D position(0.0, 1730.0, 0.0);
177 std::cout <<
"Material: " <<
182 for(
unsigned int i=0; i<lvNames.size();i++)
183 std::cout << lvNames[i].c_str() << std::endl;
185 std::cout <<
"B=(" << B[0] <<
"," << B[1] <<
"," << B[2] <<
220 std::cout <<
" First (innermost) 10 pads and last (outermost) 10 pads : " << std::endl ;
222 for(
int i = 0 ; i < nRow ; i++) {
224 if( i==0 || i == nRow-1 )
225 std::cout <<
" --------- row : " << i << std::endl ;
229 int nPad = pads.size() ;
232 for(
int j = 0 ; j < nPad ; j++) {
254 if( (i==0 && j < 10 ) || ( i == nRow-1 && j > nPad-9 ) ) {
256 std::cout <<
" pad: "
257 <<
" [" << iRow <<
"," << iPad <<
"] "
258 <<
" - ( " << p[0] <<
" , " << p[1] <<
") "
263 assert( pl.
isInsidePad( p[0] , p[1] , pads[j] ) ) ;
270 assert( nPadTotal == pl.
getNPads() ) ;
281 Vector3D r2( r1[0] , r1[1] , r1[2] ) ;
284 std::cout <<
" test of Vector3D r : " << r[0] <<
", " << r[1] <<
", " << r[2] << std::endl ;
285 std::cout <<
" test of Vector3D r1 : " << r1[0] <<
", " << r1[1] <<
", " << r1[2] << std::endl ;
286 std::cout <<
" test of Vector3D r2: " << r2[0] <<
", " << r2[1] <<
", " << r2[2] << std::endl ;
287 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.