GEAR  1.9.0
 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_terminate( gear_unexpected ) ;
51 
52  if( argc < 2 ) {
53  std::cout << " testgear: Testprogram for gear classes. " << std::endl
54  << " usage: testgear input.xml " << std::endl ;
55  exit(1) ;
56  }
57 
58  std::string fileName( argv[1] ) ;
59 
60  GearXML gearXML( fileName ) ;
61 
62  GearMgr* gearMgr = gearXML.createGearMgr() ;
63 
65  double L_tpc=0, Rtpc_i=0,Rtpc_o=0, Recal_o=0,Recal_i=0, Zecal=0;
66  try{
67  const TPCParameters &tpcparams= gearMgr->getTPCParameters() ;
68  //convert to cm for TGeo
69  double r_in = tpcparams.getDoubleVal("tpcInnerRadius")/10.;
70  double wall_in = tpcparams.getDoubleVal("tpcInnerWallThickness")/10.;
71  double wall_out = tpcparams.getDoubleVal("tpcOuterWallThickness")/10.;
72  double r_out = tpcparams.getDoubleVal("tpcOuterRadius")/10. ;
73  Rtpc_i=r_in-wall_in;
74  Rtpc_o=r_out+wall_out;
75  }
77  std::cout << " oops - no TPC available :( " << std::endl ;
78  return 0;
79  }
80  try{
81  const CalorimeterParameters &hcalparams= gearMgr->getHcalBarrelParameters() ;
82  //convert to cm for TGeo
83  L_tpc = hcalparams.getDoubleVal("TPC_Ecal_Hcal_barrel_halfZ")/10.;
84  }
86  std::cout << " oops - no TPC_Ecal_Hcal_barrel_halfZ available :( " << std::endl ;
87  return 0;
88  }
89  try{
90  const CalorimeterParameters &ecalparamsB= gearMgr->getEcalBarrelParameters() ;
91  //convert to cm for TGeo
92  Recal_o = ecalparamsB.getExtent()[0]/10.;
93  }
95  std::cout << " oops - no Ecal barrel available :( " << std::endl ;
96  return 0;
97  }
98  try{
99  const CalorimeterParameters &ecalparamsEC= gearMgr->getEcalEndcapParameters() ;
100  //convert to cm for TGeo
101  Zecal=ecalparamsEC.getExtent()[2]/10;
102  }
104  std::cout << " oops - no Ecal endcap available :( " << std::endl ;
105  return 0;
106  }
107  try{
108  const CalorimeterParameters &ecalparamsPl= gearMgr->getEcalPlugParameters() ;
109  //convert to cm for TGeo
110  Recal_i=ecalparamsPl.getExtent()[0]/10;
111  }
113  std::cout << " oops - no Ecal endcap available :( " << std::endl ;
114  return 0;
115  }
116 
117  try{
119  Vector3D tpc_initial, tpc_final;
120  Vector3D all_initial, all_final;
121  Vector3D bf_initial, bf_final;
122  double tpc_radLen=0, all_radLen=0, bf_radLen=0;
123  std::cout<<"# theta before TPC TPC up to ECAL"<<std::endl;
124  for(int theta=0;theta<90;theta++)
125  {
126  //all up to ECAL front
127  all_initial[0] = 0;
128  all_initial[1] = 0;
129  all_initial[2] = 0;
130  all_final[0] = 0.0;
131  all_final[1] = Recal_o;
132  all_final[2] = Recal_o/tan(theta*M_PI/180);
133  if(all_final[2]>Zecal)
134  {
135  all_final[2]=Zecal;
136  all_final[1]=Zecal*tan(theta*M_PI/180);
137  }
138  if(all_final[1]<Recal_i)
139  all_radLen=0;
140  else
141  all_radLen=distProp.getNRadlen(all_initial, all_final);
142  //TPC only
143  tpc_initial[0] = 0;
144  tpc_initial[1] = Rtpc_i;
145  tpc_initial[2] = Rtpc_i/tan(theta*M_PI/180);
146 
147  tpc_final[0] = 0.0;
148  tpc_final[1] = Rtpc_o;
149  tpc_final[2] = Rtpc_o/tan(theta*M_PI/180);
150  if(tpc_final[2]>L_tpc)
151  {
152  tpc_final[2]=L_tpc;
153  tpc_final[1]=L_tpc*tan(theta*M_PI/180);
154  }
155  if(tpc_initial[2]>L_tpc)
156  tpc_radLen=0;
157  else
158  tpc_radLen=distProp.getNRadlen(tpc_initial, tpc_final);
159 
160  //before TPC
161  bf_initial[0] = 0;
162  bf_initial[1] = 0;
163  bf_initial[2] = 0;
164  bf_final[0] = 0.0;
165  bf_final[1] = tpc_initial[1];
166  bf_final[2] = tpc_initial[2];
167  if(bf_final[2]>L_tpc)
168  bf_radLen=0;
169  else
170  bf_radLen=distProp.getNRadlen(bf_initial, bf_final);
171 
172  std::cout<<theta<<" "<<bf_radLen<<" "<<tpc_radLen<<" "<<all_radLen<<std::endl;
173 
174 
175 
176  }
177  }
178  catch(NotImplementedException e){}
179 
180 }
181 
182 
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.