GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testMaterialMap.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 "gear/GearDistanceProperties.h"
8 #include "gear/GearPointProperties.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 #include <math.h>
20 
21 using namespace gear ;
22 
23 
24 void gear_unexpected(){
25 
26  try {
27 
28  throw ;
29 
30  } catch( std::exception& e) {
31 
32  std::cout << " A runtime error has occured : "
33  << e.what()
34  << std::endl
35  << " the program will have to be terminated - sorry." << std::endl ;
36  exit(1) ;
37  }
38 }
39 
40 
45 int main(int argc, char**argv){
46 
47 
48  std::set_terminate( gear_unexpected ) ;
49 
50  if( argc < 2 ) {
51  std::cout << " testMaterialMap: Testprogram for ceating material map based on gdml file with GearDistanceProperties. " << std::endl
52  << " usage: testgear input.xml " << std::endl ;
53  exit(1) ;
54  }
55 
56  std::string fileName( argv[1] ) ;
57 
58  GearXML gearXML( fileName ) ;
59 
60  GearMgr* gearMgr = gearXML.createGearMgr() ;
61 
62  // --- testing gear distance properties ---
63  try{
64 
65 
66  Vector3D initial, final;
67  std::vector<std::string> matNames,volNames;
68  initial[0] = 0.0;
69  initial[1] = 0.0;
70  initial[2] = 0.0;
71  for(int r=0;r<400;r+=40)
72  {
73  for(int theta=1;theta<90;theta+=2)
74  {
75  final[0] = 0.0;
76  final[2] = r*cos(theta*M_PI/180);
77  final[1] = final[2]*tan(theta*M_PI/180);
78 
79  double interactionLengthsFromIp = gearMgr->getDistanceProperties().getNIntlen( initial, final);
80  double radiationLengthsFromIp = gearMgr->getDistanceProperties().getNRadlen( initial, final);
81  std::cout<<r<<" "<<theta<<" "<<interactionLengthsFromIp<<" "<<radiationLengthsFromIp<<std::endl;
82  }
83  }
84  }
85  catch(NotImplementedException e){}
86 
87 
88 
89 }
90 
91 
virtual double getNIntlen(const Vector3D &p0, const Vector3D &p1) const =0
The number of interaction lengths along the distance between [p0,p1] .
virtual const GearDistanceProperties & getDistanceProperties() const =0
Get the distance properties object.
Implementation of GEAR using XML.
Definition: GearXML.h:18
virtual double getNRadlen(const Vector3D &p0, const Vector3D &p1) const =0
The number of radiation lengths along the distance between [p0,p1] .
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