GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testGearTGeo.cc
1 
2 #include "gearimpl/Util.h"
3 #include "gearxml/GearXML.h"
4 #include "gear/GearMgr.h"
5 #include "gear/GEAR.h"
6 
7 #include "geartgeo/TGeoGearDistanceProperties.h"
8 #include "geartgeo/TGeoGearPointProperties.h"
9 
10 #include <iostream>
11 #include <assert.h>
12 
13 #include <exception>
14 #include <typeinfo>
15 #include <cstdlib>
16 
17 #include <sstream>
18 #include <fstream>
19 
20 using namespace gear ;
21 
22 
23 void gear_unexpected(){
24 
25  try {
26 
27  throw ;
28 
29  } catch( std::exception& e) {
30 
31  std::cout << " A runtime error has occured : "
32  << e.what()
33  << std::endl
34  << " the program will have to be terminated - sorry." << std::endl ;
35  exit(1) ;
36  }
37 }
38 
39 
44 int main(int argc, char**argv){
45 
46 
47  std::set_terminate( gear_unexpected ) ;
48 
49  if( argc < 2 ) {
50  std::cout << " testgear: Testprogram for gear classes. " << std::endl
51  << " usage: testgear input.xml " << std::endl ;
52  exit(1) ;
53  }
54 
55  std::string fileName( argv[1] ) ;
56 
57  GearXML gearXML( fileName ) ;
58 
59  GearMgr* gearMgr = gearXML.createGearMgr() ;
60 
61 
62  //std::cout << " testgear - instantiated GearMgr from file " << fileName
63  // << std::endl ;
64 
65  // --- testing geartgeo ---
66  try{
69 
70  Vector3D initial, final;
71  std::vector<std::string> matNames,volNames;
72  initial[0] = 0.0;
73  initial[1] = 0.0;
74  initial[2] = 0.0;
75 
76  final[0] = 0.0;
77  final[1] = 0.0;
78  final[2] = 5000.0;
79 
80  std::cout<<"Top logical volume containing point (0,0,0): "<<pointProp.getListOfLogicalVolumes(initial)[0]<<std::endl;
81  double radLen=distProp.getNRadlen(initial, final);
82  std::cout<<"Radiation length between (0,0,0) and (50,50,50): "<<radLen<<std::endl;
83  matNames = distProp.getMaterialNames(initial, final);
84  volNames = distProp.getVolumeNames(initial, final);
85 
86  std::cout<<"Volumes and their material between (0,0,0) and (50,50,50): "<<std::endl;
87  for(unsigned int i=0; i<volNames.size();i++)
88  std::cout <<i<<" "<< volNames[i]<<" "<<matNames[i] << std::endl;
89 
90  }
91  catch(NotImplementedException e){}
92 
93 
94 
95 }
96 
97 
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 double getNRadlen(const Vector3D &p0, const Vector3D &p1) const
The number of radiation lengths along the distance between [p0,p1] .
virtual const std::vector< std::string > & getMaterialNames(const Vector3D &p0, const Vector3D &p1) const
List of matrial names along the distance between [p0,p1]- WARNING: this method returns a reference to...
virtual const GearDistanceProperties & getDistanceProperties() const =0
Get the distance properties object.
TGeo Implementation of the abstract interface that returns the (material) properties along a given di...
virtual const std::vector< std::string > getVolumeNames(const Vector3D &p0, const Vector3D &p1) const
List of traversed volumes by name.
Implementation of GEAR using XML.
Definition: GearXML.h:18
NotImplementedException used for features that are not implemented.
Definition: GEAR.h:81
Simple three dimensional vector providing the components for cartesian, cylindrical and spherical coo...
Definition: Vector3D.h:18
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
Definition: GearMgr.h:36
TGeo implementation of the abstract interface that returns the (material) properties of a given point...
virtual const GearPointProperties & getPointProperties() const =0
Get the point properties object.