55 Vector3D pointOnCylinder(
double theta,
double r,
double z,
double phi){
57 double theta0 = atan2( r, z ) ;
70 Handler() { SetErrorHandler(Handler::print); }
72 static void print(
int level, Bool_t abort,
const char *location,
const char *msg) {
73 if ( level > kInfo || abort ) ::printf(
"%s: %s\n", location, msg);
77 std::cout <<
" usage: materialBudget compact.xml steering.txt" << std::endl
78 <<
" -> create histograms with the material budget as seen from the IP within fixed ranges of (rmin, rmax, zmin. zmax)" << std::endl
79 <<
" see example steering file for details ..." << std::endl
80 <<
" -x : dump example steering file " << std::endl
89 std::string dummy = argv[1] ;
102 std::string compactFile = argv[1];
103 std::string steeringFile = argv[2];
105 double phi0 =
M_PI / 2. ;
106 double thetaMin = 0. ;
107 double thetaMax = 90. ;
109 double etaMax = -1. ;
110 std::string outFileName(
"material_budget.root") ;
111 std::vector<SDetHelper> subdets ;
114 std::ifstream infile(steeringFile );
117 while (std::getline(infile, line)) {
119 if( line.empty() || line.find(
"#") == 0 )
122 std::istringstream iss(line);
126 if( token ==
"nbins" ){
129 else if( token ==
"thetaMin" ){
132 else if( token ==
"thetaMax" ){
135 else if( token ==
"etaMin" ){
138 else if( token ==
"etaMax" ){
141 else if( token ==
"rootfile" ){
144 else if( token ==
"phi" ){
146 phi0 = phi0 / 180. *
M_PI ;
148 else if( token ==
"subdet" ){
151 subdets.emplace_back(
det );
155 std::cout <<
" ERROR parsing line : " << line << std::endl ;
161 std::cout <<
"Invalid value for binning (nbins) " << nbins << std::endl;
166 setPrintLevel(WARNING);
169 description.
fromXML(compactFile ) ;
172 TFile* rootFile =
new TFile(outFileName.c_str(),
"recreate");
173 for(
auto&
det : subdets ) {
174 std::string hxn(
det.name), hxnn(
det.name) ;
175 std::string hln(
det.name), hlnn(
det.name) ;
179 hxnn +=
" integrated X0 vs eta" ;
180 det.hx =
new TH1F( hxn.c_str(), hxnn.c_str(), nbins, etaMin , etaMax ) ;
183 hlnn +=
" integrated int. lengths vs eta" ;
184 det.hl =
new TH1F( hln.c_str(), hlnn.c_str(), nbins, etaMin , etaMax ) ;
188 hxnn +=
" integrated X0 vs -theta" ;
189 det.hx =
new TH1F( hxn.c_str(), hxnn.c_str(), nbins, -thetaMax , -thetaMin ) ;
192 hlnn +=
" integrated int. lengths vs -theta" ;
193 det.hl =
new TH1F( hln.c_str(), hlnn.c_str(), nbins, -thetaMax , -thetaMin ) ;
203 thetaMin = thetaMin / 180. *
M_PI ;
204 thetaMax = thetaMax / 180. *
M_PI ;
205 double dTheta = (thetaMax-thetaMin)/nbins;
206 double dEta = (etaMax-etaMin)/nbins ;
208 std::cout <<
"====================================================================================================" << std::endl ;
209 std::cout <<
"theta:f/" ;
210 for(
auto&
det : subdets){ std::cout <<
det.name <<
"_x0:f/" <<
det.name <<
"_lam:f/" ; }
211 std::cout << std::endl ;
213 if ( nbins <= 0 || nbins > USHRT_MAX ) {
214 std::cout <<
"Unreasonable number of bins: " << nbins << std::endl;
218 for(
int i=0 ; i< nbins ;++i){
219 double theta = ( etaMax > 0. ? 2. * atan ( exp ( - ( etaMin + (0.5+i)*dEta) ) ) : ( thetaMin + (0.5+i)*dTheta ) ) ;
220 std::stringstream paramLine;
222 paramLine << std::scientific << theta <<
" " ;
223 for(
auto&
det : subdets ) {
227 double sum_x0(0.), sum_lambda(0.);
230 for(
auto amat : materials ) {
231 TGeoMaterial* mat = amat.first->GetMaterial();
232 double length = amat.second;
233 double nx0 = length / mat->GetRadLen();
235 double nLambda = length / mat->GetIntLen();
236 sum_lambda += nLambda;
240 double binX = ( etaMax > 0. ? (etaMin + (0.5+i)*dEta) : -theta/
M_PI*180. ) ;
241 det.hx->Fill( binX , sum_x0 ) ;
242 det.hl->Fill( binX , sum_lambda ) ;
243 paramLine << std::scientific << sum_x0 <<
" " << sum_lambda <<
" " ;
245 std::cout << paramLine.str() << std::endl;
247 std::cout <<
"====================================================================================================" << std::endl ;
254 std::cout <<
"# Example steering file for materialBudget (taken from ILD_l5_v02)" << std::endl ;
255 std::cout << std::endl ;
256 std::cout <<
"# root output file" << std::endl ;
257 std::cout <<
"rootfile material_budget.root" << std::endl ;
258 std::cout <<
"# number of bins for polar angle (default 90)" << std::endl ;
259 std::cout <<
"nbins 90" << std::endl ;
260 std::cout << std::endl ;
261 std::cout <<
"# use polar angle - specify minimum and maximum theta value" << std::endl ;
262 std::cout <<
"# thetaMin 0." << std::endl ;
263 std::cout <<
"# thetaMax 90." << std::endl ;
264 std::cout << std::endl ;
265 std::cout <<
"# use pseudo rapidity rather than polar angle - specify minimum and maximum eta value" << std::endl ;
266 std::cout <<
"# etaMin -3." << std::endl ;
267 std::cout <<
"# etaMax 3." << std::endl ;
268 std::cout << std::endl ;
269 std::cout <<
"# phi direction in deg (default: 90./y-axis)" << std::endl ;
270 std::cout <<
"phi 90." << std::endl ;
271 std::cout << std::endl ;
272 std::cout <<
"# names and subdetector ranges given in [rmin,zmin,rmax,zmax] - e.g. for ILD_l5_vo2 (run dumpdetector -d to get numbers... ) " << std::endl ;
273 std::cout << std::endl ;
274 std::cout <<
"subdet vxd 0. 0. 6.549392e+00 1.450000e+01" << std::endl ;
275 std::cout <<
"subdet sitftd 0. 0. 3.024000e+01 2.211800e+02" << std::endl ;
276 std::cout <<
"subdet tpc 0. 0. 1.692100e+02 2.225000e+02" << std::endl ;
277 std::cout <<
"subdet outtpc 0. 0. 1.769800e+02 2.350000e+02" << std::endl ;
278 std::cout <<
"subdet set 0. 0. 1.775200e+02 2.300000e+02" << std::endl ;