GEAR  1.6.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testMaterialBudget.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 #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 
47 int main(int argc, char**argv){
48 
49 
50  std::set_unexpected( gear_unexpected ) ;
51  std::set_terminate( gear_unexpected ) ;
52 
53  if( argc < 2 ) {
54  std::cout << " testgear: Testprogram for gear classes. " << std::endl
55  << " usage: testgear input.xml " << std::endl ;
56  exit(1) ;
57  }
58 
59  std::string fileName( argv[1] ) ;
60 
61  GearXML gearXML( fileName ) ;
62 
63  GearMgr* gearMgr = gearXML.createGearMgr() ;
64 
66  double L_tpc=0, Rtpc_i=0,Rtpc_o=0, Recal_o=0,Recal_i=0, Zecal=0;
67  try{
68  const TPCParameters &tpcparams= gearMgr->getTPCParameters() ;
69  //convert to cm for TGeo
70  double r_in = tpcparams.getDoubleVal("tpcInnerRadius")/10.;
71  double wall_in = tpcparams.getDoubleVal("tpcInnerWallThickness")/10.;
72  double wall_out = tpcparams.getDoubleVal("tpcOuterWallThickness")/10.;
73  double r_out = tpcparams.getDoubleVal("tpcOuterRadius")/10. ;
74  Rtpc_i=r_in-wall_in;
75  Rtpc_o=r_out+wall_out;
76  }
78  std::cout << " oops - no TPC available :( " << std::endl ;
79  return 0;
80  }
81  try{
82  const CalorimeterParameters &hcalparams= gearMgr->getHcalBarrelParameters() ;
83  //convert to cm for TGeo
84  L_tpc = hcalparams.getDoubleVal("TPC_Ecal_Hcal_barrel_halfZ")/10.;
85  }
87  std::cout << " oops - no TPC_Ecal_Hcal_barrel_halfZ available :( " << std::endl ;
88  return 0;
89  }
90  try{
91  const CalorimeterParameters &ecalparamsB= gearMgr->getEcalBarrelParameters() ;
92  //convert to cm for TGeo
93  Recal_o = ecalparamsB.getExtent()[0]/10.;
94  }
96  std::cout << " oops - no Ecal barrel available :( " << std::endl ;
97  return 0;
98  }
99  try{
100  const CalorimeterParameters &ecalparamsEC= gearMgr->getEcalEndcapParameters() ;
101  //convert to cm for TGeo
102  Zecal=ecalparamsEC.getExtent()[2]/10;
103  }
105  std::cout << " oops - no Ecal endcap available :( " << std::endl ;
106  return 0;
107  }
108  try{
109  const CalorimeterParameters &ecalparamsPl= gearMgr->getEcalPlugParameters() ;
110  //convert to cm for TGeo
111  Recal_i=ecalparamsPl.getExtent()[0]/10;
112  }
114  std::cout << " oops - no Ecal endcap available :( " << std::endl ;
115  return 0;
116  }
117 
118  try{
120  Vector3D tpc_initial, tpc_final;
121  Vector3D all_initial, all_final;
122  Vector3D bf_initial, bf_final;
123  double tpc_radLen=0, all_radLen=0, bf_radLen=0;
124  std::cout<<"# theta before TPC TPC up to ECAL"<<std::endl;
125  for(int theta=0;theta<90;theta++)
126  {
127  //all up to ECAL front
128  all_initial[0] = 0;
129  all_initial[1] = 0;
130  all_initial[2] = 0;
131  all_final[0] = 0.0;
132  all_final[1] = Recal_o;
133  all_final[2] = Recal_o/tan(theta*M_PI/180);
134  if(all_final[2]>Zecal)
135  {
136  all_final[2]=Zecal;
137  all_final[1]=Zecal*tan(theta*M_PI/180);
138  }
139  if(all_final[1]<Recal_i)
140  all_radLen=0;
141  else
142  all_radLen=distProp.getNRadlen(all_initial, all_final);
143  //TPC only
144  tpc_initial[0] = 0;
145  tpc_initial[1] = Rtpc_i;
146  tpc_initial[2] = Rtpc_i/tan(theta*M_PI/180);
147 
148  tpc_final[0] = 0.0;
149  tpc_final[1] = Rtpc_o;
150  tpc_final[2] = Rtpc_o/tan(theta*M_PI/180);
151  if(tpc_final[2]>L_tpc)
152  {
153  tpc_final[2]=L_tpc;
154  tpc_final[1]=L_tpc*tan(theta*M_PI/180);
155  }
156  if(tpc_initial[2]>L_tpc)
157  tpc_radLen=0;
158  else
159  tpc_radLen=distProp.getNRadlen(tpc_initial, tpc_final);
160 
161  //before TPC
162  bf_initial[0] = 0;
163  bf_initial[1] = 0;
164  bf_initial[2] = 0;
165  bf_final[0] = 0.0;
166  bf_final[1] = tpc_initial[1];
167  bf_final[2] = tpc_initial[2];
168  if(bf_final[2]>L_tpc)
169  bf_radLen=0;
170  else
171  bf_radLen=distProp.getNRadlen(bf_initial, bf_final);
172 
173  std::cout<<theta<<" "<<bf_radLen<<" "<<tpc_radLen<<" "<<all_radLen<<std::endl;
174 
175 
176 
177  }
178  }
179  catch(NotImplementedException e){}
180 
181 }
182 
183 
virtual const TPCParameters & getTPCParameters() const =0
Get the TPCParameters.
Proposal for an abstract interface that defines the geometry properties of a TPC like detector needed...
Definition: TPCParameters.h:24
virtual double getNRadlen(const Vector3D &p0, const Vector3D &p1) const
The number of radiation lengths along the distance between [p0,p1] .
virtual const GearDistanceProperties & getDistanceProperties() const =0
Get the distance properties object.
Proposal for an abstract interface that defines geometry properties of a typical sampling calorimeter...
TGeo Implementation of the abstract interface that returns the (material) properties along a given di...
virtual const std::vector< double > & getExtent() const =0
Extent of the calorimeter in the r-z-plane [ rmin, rmax, zmin, zmax ] in mm.
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
UnknownParameterException call Processor::end().
Definition: GEAR.h:99
virtual const CalorimeterParameters & getEcalPlugParameters() const =0
Get the Ecal plug parameters.
virtual const CalorimeterParameters & getEcalBarrelParameters() const =0
Get the Ecal barrel parameters.
virtual const CalorimeterParameters & getHcalBarrelParameters() const =0
Get the Hcal barrel parameters.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
Definition: GearMgr.h:36
virtual const CalorimeterParameters & getEcalEndcapParameters() const =0
Get the Ecal endcap parameters.
virtual double getDoubleVal(const std::string &key) const =0
Double value for key.