30 float Select(
float* Efit,
float* Tfit,
int m)
34 if(Efit[
m]>=0&&Tfit[
m]!=0)
39 float Select(
float* Efit,
float* Tfit,
int m,
int n)
42 if(Efit[
m]>=0&&Tfit[
m]!=0)
44 if(Efit[
n]>=0&&Tfit[
n]!=0)
49 float Select(
float* Efit,
float* Tfit,
int a,
int b,
int c,
int d)
52 if(Efit[
a]>=0&&Tfit[
a]!=0)
54 if(Efit[
b]>=0&&Tfit[
b]!=0)
56 if(Efit[
c]>=0&&Tfit[
c]!=0)
58 if(Efit[
d]>=0&&Tfit[
d]!=0)
63 float Select(
float* Efit,
float* Tfit,
int a,
int b,
int c,
int d,
int e,
int f)
66 if(Efit[
a]>=0&&Tfit[
a]!=0)
68 if(Efit[
b]>=0&&Tfit[
b]!=0)
70 if(Efit[
c]>=0&&Tfit[
c]!=0)
72 if(Efit[
d]>=0&&Tfit[
d]!=0)
74 if(Efit[
e]>=0&&Tfit[
e]!=0)
76 if(Efit[
f]>=0&&Tfit[
f]!=0)
83 double p = (5640.0-40.0)/307.0/10.0;
84 double halfLength = 280.0 ;
85 double lambdaIron = 131.9/7.87 ;
87 double lambda = 20.5559 ;
90 double enterPos = halfLength/lambda +
offset/lambdaIron ;
99 double zBLow[18] {136.0*
p, 116.*
p, 97.5*
p, 79.5*
p, 63*
p, 46.5*
p, 31*
p, 15.58*
p, 0, 0, -15.58*
p, -31*
p, -46.5*
p, -63*
p, -79.5*
p, -97.5*
p, -116.*
p, -136.0*
p};
102 xBLow[0] =
offset/lambdaIron;
105 for(
int i=0 ;
i<nBCell ;
i++)
107 xBLow[
i+1] = abs(enterPos-zBLow[
i+j]/lambda) ;
110 for(
int i=0 ;
i<nBCell+1 ;
i++)
111 cout<<xBLow[
i]<<endl ;
117 if(gSystem->AccessPathName(
"results"))
118 gSystem->Exec(
"mkdir results") ;
121 if (gSystem->AccessPathName(
"plots"))
122 gSystem->Exec(
"mkdir plots") ;
125 string Energies[] = {
"20000",
"50000",
"100000",
"180000"} ;
129 string PhysicsLists[] = {
"FTFP_BERT",
"FTFP_BERT_ATL_VALIDATION",
"QGSP_BERT",
"QGSP_BIC"} ;
132 string InPath =
"/rdata2/dengfeng/QT/20.3.7.4/OutputFlagZ2795/" ;
138 for(
int j=0 ; j<
sizeof(
Energies)/
sizeof(
string) ; j++)
151 cout<<
"In File: "<<
inputFile->GetName()<<endl ;
153 TTree* h1000 = (TTree*)
inputFile->Get(
"h1000") ;
157 cout<<
"Tree: h1000 doesn't exist!"<<endl ;
197 h1000->SetBranchAddress(
"EfitC0", EfitC0) ;
198 h1000->SetBranchAddress(
"EfitC1", EfitC1) ;
199 h1000->SetBranchAddress(
"EfitA0", EfitA0) ;
200 h1000->SetBranchAddress(
"EfitA1", EfitA1) ;
201 h1000->SetBranchAddress(
"EfitD0", EfitD0) ;
202 h1000->SetBranchAddress(
"EfitE0", EfitE0) ;
203 h1000->SetBranchAddress(
"TfitC0", TfitC0) ;
204 h1000->SetBranchAddress(
"TfitC1", TfitC1) ;
205 h1000->SetBranchAddress(
"TfitA0", TfitA0) ;
206 h1000->SetBranchAddress(
"TfitA1", TfitA1) ;
207 h1000->SetBranchAddress(
"TfitD0", TfitD0) ;
208 h1000->SetBranchAddress(
"TfitE0", TfitE0) ;
213 TH1F* AllRecoE =
bookTH1F(
"AllRecoE",
"Measured Energy",
"Reconstructed Energy [GeV]",
"Events", 100, 0, std::stoi(
Energies[j])/1000.*1.5) ;
215 TH1F* RecoE =
bookTH1F(
"RecoE",
"Measured Energy",
"Reconstructed Energy [GeV]",
"Events", 100, 0, std::stoi(
Energies[j])/1000.*1.5) ;
217 TH1F* RecoEModule0 =
bookTH1F(
"RecoEModule0",
"Deposit Energy in Module0",
"Reconstructed Energy [GeV]",
"Events", 100, 0,std::stoi(
Energies[j])/1000.*1.5) ;
219 TH1F* RecoECentralModule =
bookTH1F(
"RecoECentralModule",
"Deposit Energy in Central Module",
"Reconstructed Energy [GeV]",
"Events", 100, 0, std::stoi(
Energies[j])/1000.*1.5) ;
221 TH1F* RecoEEModule =
bookTH1F(
"RecoEEModule",
"Deposit Energy in Extended Module",
"Reconstructed Energy [GeV]",
"Events", 100, 0, std::stoi(
Energies[j])/1000.*1.5) ;
223 TH1F* LongitudinalProfile =
bookTH1F(
"LongitudinalProfile",
"Longitudinal Profile(Mean Deposit Energy in B, C and A Cells)",
"x[#lambda]",
"dE/dx[GeV/#lambda]", nBCell, xBLow) ;
225 cout<<
"Entries: "<<h1000->GetEntries()<<endl ;
227 for(
int n=0 ;
n<h1000->GetEntries() ;
n++)
231 for(
int m=0 ;
m<48 ;
m++)
233 if(
m==30||
m==31||
m==43)
240 totalE +=
Select(EfitC0, TfitC0,
m) ;
241 totalE +=
Select(EfitC1, TfitC1,
m) ;
242 totalE +=
Select(EfitA0, TfitA0,
m) ;
243 totalE +=
Select(EfitA1, TfitA1,
m) ;
245 if(
m==18||
m==19||(
m>=24&&
m<=29)||
m==33||
m==34||(
m>=42&&
m<=47)||
m==12||
m==13||
m==0||
m==1)
252 totalE +=
Select(EfitD0, TfitD0,
m) ;
253 totalE +=
Select(EfitE0, TfitE0,
m) ;
256 AllRecoE->Fill(totalE/1000.) ;
260 TF1* func =
new TF1(
"func",
"gaus",AllRecoE->GetMean()-2*AllRecoE->GetRMS(),AllRecoE->GetMean()+2*AllRecoE->GetRMS()) ;
261 AllRecoE->Fit(
"func",
"R") ;
265 float CoreUp = func->GetParameter(1)+3*func->GetParameter(2) ;
267 float CoreDown = func->GetParameter(1)-3*func->GetParameter(2) ;
271 for(
int n=0 ;
n<h1000->GetEntries() ;
n++)
275 float EModule0 = 0. ;
276 float ECModule = 0. ;
277 float EEModule = 0. ;
278 float EModule0ABCCell[18] ;
279 float ECModuleABCCell[18] ;
280 for(
int m=0 ;
m<18 ;
m++)
282 EModule0ABCCell[
m]=0. ;
283 ECModuleABCCell[
m]=0. ;
290 ECModuleABCCell[0] =
Select(EfitC1, TfitC1, 44, 45, 46, 47) ;
292 EModule0ABCCell[0] +=
Select(EfitC0, TfitC0, 44, 45, 46, 47) ;
294 ECModuleABCCell[1] +=
Select(EfitC1, TfitC1, 41, 40, 37, 38) ;
296 EModule0ABCCell[1] +=
Select(EfitC0, TfitC0, 41, 40, 37, 38) ;
298 ECModuleABCCell[2] +=
Select(EfitC1, TfitC1, 34, 35, 33, 36) ;
300 EModule0ABCCell[2] +=
Select(EfitC0, TfitC0, 34, 35, 33, 36) ;
302 ECModuleABCCell[3] +=
Select(EfitC1, TfitC1, 28, 29, 27, 30) ;
304 EModule0ABCCell[3] +=
Select(EfitC0, TfitC0, 28, 29, 27, 30) ;
306 ECModuleABCCell[4] +=
Select(EfitC1, TfitC1, 21, 22, 23, 24, 19, 20) ;
308 EModule0ABCCell[4] +=
Select(EfitC0, TfitC0, 21, 22, 23, 24, 19, 20) ;
310 ECModuleABCCell[5] +=
Select(EfitC1, TfitC1, 16, 17, 15, 18) ;
312 EModule0ABCCell[5] +=
Select(EfitC0, TfitC0, 16, 17, 15, 18) ;
314 ECModuleABCCell[6] +=
Select(EfitC1, TfitC1, 11, 12, 9, 10) ;
316 EModule0ABCCell[6] +=
Select(EfitC0, TfitC0, 11, 12, 9, 10) ;
318 ECModuleABCCell[7] +=
Select(EfitC1, TfitC1, 6, 7, 5, 8) ;
320 EModule0ABCCell[7] +=
Select(EfitC0, TfitC0, 6, 7, 5, 8) ;
322 ECModuleABCCell[8] +=
Select(EfitC1, TfitC1, 2, 3, 1, 4) ;
324 EModule0ABCCell[8] +=
Select(EfitC0, TfitC0, 2, 3, 1, 4) ;
328 ECModuleABCCell[9] +=
Select(EfitA1, TfitA1, 2, 3, 1, 4) ;
329 EModule0ABCCell[9] +=
Select(EfitA0, TfitA0, 2, 3, 1, 4) ;
330 ECModuleABCCell[10] +=
Select(EfitA1, TfitA1, 6, 7, 5, 8) ;
331 EModule0ABCCell[10] +=
Select(EfitA0, TfitA0, 6, 7, 5, 8) ;
332 ECModuleABCCell[11] +=
Select(EfitA1, TfitA1, 11, 12, 9, 10) ;
333 EModule0ABCCell[11] +=
Select(EfitA0, TfitA0, 11, 12, 9, 10) ;
334 ECModuleABCCell[12] +=
Select(EfitA1, TfitA1, 16, 17, 15, 18) ;
335 EModule0ABCCell[12] +=
Select(EfitA0, TfitA0, 16, 17, 15, 18) ;
336 ECModuleABCCell[13] +=
Select(EfitA1, TfitA1, 21, 22, 23, 24, 19, 20) ;
337 EModule0ABCCell[13] +=
Select(EfitA0, TfitA0, 21, 22, 23, 24, 19, 20) ;
338 ECModuleABCCell[14] +=
Select(EfitA1, TfitA1, 28, 29, 27, 30) ;
339 EModule0ABCCell[14] +=
Select(EfitA0, TfitA0, 28, 29, 27, 30) ;
340 ECModuleABCCell[15] +=
Select(EfitA1, TfitA1, 34, 35, 33, 36) ;
341 EModule0ABCCell[15] +=
Select(EfitA0, TfitA0, 34, 35, 33, 36) ;
342 ECModuleABCCell[16] +=
Select(EfitA1, TfitA1, 40, 41, 37, 38) ;
343 EModule0ABCCell[16] +=
Select(EfitA0, TfitA0, 40, 41, 37, 38) ;
344 ECModuleABCCell[17] +=
Select(EfitA1, TfitA1, 44, 45, 46, 47) ;
345 EModule0ABCCell[17] +=
Select(EfitA0, TfitA0, 44, 45, 46, 47) ;
348 for(
int m=0 ;
m<18 ;
m++)
350 All += ECModuleABCCell[
m] ;
351 All += EModule0ABCCell[
m] ;
355 for(
int m=0 ;
m<48 ;
m++)
358 if(
m==30||
m==31||
m==43)
367 totalE +=
Select(EfitC0, TfitC0,
m) ;
368 totalE +=
Select(EfitC1, TfitC1,
m) ;
369 totalE +=
Select(EfitA0, TfitA0,
m) ;
370 totalE +=
Select(EfitA1, TfitA1,
m) ;
372 EModule0 +=
Select(EfitC0, TfitC0,
m) ;
373 EModule0 +=
Select(EfitA0, TfitA0,
m) ;
374 ECModule +=
Select(EfitC1, TfitC1,
m) ;
375 ECModule +=
Select(EfitA1, TfitA1,
m) ;
378 if(
m==18||
m==19||(
m>=24&&j<=29)||
m==33||
m==34||(
m>=42&&
m<=47)||
m==12||
m==13||
m==0||
m==1)
387 totalE +=
Select(EfitD0, TfitD0,
m) ;
388 totalE +=
Select(EfitE0, TfitE0,
m) ;
390 EEModule +=
Select(EfitD0, TfitD0,
m) ;
391 EEModule +=
Select(EfitE0, TfitE0,
m) ;
396 if(totalE/1000<CoreDown||totalE/1000>CoreUp)
399 RecoEModule0->Fill(EModule0/1000.) ;
400 RecoEEModule->Fill(EEModule/1000.) ;
401 RecoECentralModule->Fill(ECModule/1000.) ;
402 RecoE->Fill(totalE/1000.) ;
404 for(
int m=0 ;
m<15 ;
m++)
410 LongitudinalProfile->Fill(LongitudinalProfile->GetBinCenter(
m+1), ((ECModuleABCCell[
m]+2*EModule0ABCCell[
m])/1000.)/LongitudinalProfile->GetBinWidth(
m+1)) ;
415 cout<<
"AccEntries: "<<AccEntries<<endl ;
418 LongitudinalProfile->Scale(1./AccEntries) ;
420 for(
int m=0 ;
m<18 ;
m++)
424 if(LongitudinalProfile->GetBinContent(
m+1)<0.05)
426 LongitudinalProfile->SetBinContent(
m+1, 0.) ;
427 LongitudinalProfile->SetBinError(
m+1, 0.) ;
433 string Sub_OutPath =
"./results/"+
Particles[
i]+
"/" ;
434 if(gSystem->AccessPathName(Sub_OutPath.c_str()))
436 cout<<Sub_OutPath<<
" doesn't exist! Making......"<<endl ;
437 gSystem->Exec((
"mkdir "+Sub_OutPath).c_str()) ;
442 PhysicsList =
"FTFP_BERT_ATL" ;
445 cout<<
"outputFile: "<<
outputFile->GetName()<<endl ;
449 RecoEModule0->Write() ;
450 RecoEEModule->Write() ;
451 RecoECentralModule->Write() ;
452 LongitudinalProfile->Write() ;