GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testMaterialMapFactory.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 <iostream>
8 #include <assert.h>
9 
10 #include <exception>
11 #include <typeinfo>
12 #include <cstdlib>
13 
14 #include <sstream>
15 #include <fstream>
16 #include <math.h>
17 
18 #include "gear/geartgeo/MaterialMapFactory.h"
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  try{
62  MaterialMapFactory *myMapFactory= new MaterialMapFactory(gearMgr);
63 
64  MaterialMap *myMap=myMapFactory->createMaterialMap(-200,200, 10,-200., 200,10 ,-400, 400, 10, 0);
65 
66  for(int r=0;r<20;r++)
67  {
68  double x=-200+200*drand48();
69  double y=-200+200*drand48();
70  double z=-400*drand48();
71  //double interactionLengthsFromIp = myMap->getInteractionLength( r,theta*M_PI/180. ,0);
72  double radiationLengthsFromIp = myMap->getRadiationLength(x,y,z);
73  std::cout<<x<<" "<<y<<" "<<z<<" "<<radiationLengthsFromIp<<std::endl;
74  }
75 
76  }
77  catch(NotImplementedException e){}
78 
79 }
80 
81 
Material map using GearDistanceProperties.
Definition: MaterialMap.h:16
double getRadiationLength(double x, double y, double z) const
Returns the radiation length from the vertex at (0,0,0) to (x,y,z) using a distance wheighted interpo...
Definition: MaterialMap.cc:150
MaterialMap * createMaterialMap(double xmin, double xmax, int nxsteps, double ymin, double ymax, int nysteps, double zmin, double zmax, int nzsteps, int coord)
Creating a material map in memory.
Implementation of GEAR using XML.
Definition: GearXML.h:18
NotImplementedException used for features that are not implemented.
Definition: GEAR.h:81
Factory to create material maps using GearDistanceProperties.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
Definition: GearMgr.h:36