8 |
|
|
9 |
|
#include "usefullcode.cc" |
10 |
|
|
11 |
< |
float ccalib_GR_42_V13[2][101][101]; |
11 |
> |
|
12 |
> |
|
13 |
> |
float ccalibpretag[2][101][101]; |
14 |
|
|
15 |
|
float interCalib_preCalib[170][360]; |
16 |
|
float interCalibEndcap_preCalib[2][101][101]; |
17 |
|
|
18 |
|
|
19 |
+ |
|
20 |
|
bool isTestBeamSM(int iSM){ |
21 |
|
|
22 |
|
|
81 |
|
|
82 |
|
|
83 |
|
void combinCalibConstantEndcapv1(){ |
84 |
< |
|
84 |
> |
|
85 |
> |
|
86 |
|
cout.setf(ios::fixed,ios::floatfield); |
87 |
|
cout.precision(8); |
88 |
|
|
98 |
|
|
99 |
|
readInterCalibEndcap_GR09_V8(); |
100 |
|
|
101 |
< |
|
98 |
< |
getInterCalibEndcapv1("interCalibEE_GR_R_42_V13.txt",ccalib_GR_42_V13); ///2010 IC |
99 |
< |
|
101 |
> |
getInterCalibEndcapv1("interCalibEE_GR_P_V39.txt",ccalibpretag); |
102 |
|
|
103 |
|
|
104 |
|
get_xyzEBrechits(); |
105 |
|
setEtaRingBoundaryEndcap(); |
106 |
|
|
105 |
– |
|
106 |
– |
|
107 |
|
map<int,string> icFiles; |
108 |
|
|
109 |
|
|
110 |
< |
//// datachain_alcapizEE_data_20111122_158851_180363_160404to166923and166946to167913floatAlphav1 |
111 |
< |
//// datachain_alcapizEE_data_20111122_158851_180363_169985to173692floatAlphav1 |
112 |
< |
/// datachain_floatAlphav1_175832to180252_piz |
113 |
< |
|
114 |
< |
icFiles[0] = "calibres/deriveCalibConst.testCalibv1e.dflag41.pe1.cut3.rmOvlap0.step24.method2.corrEta1.corrPhi0.corrDead0.precalib1.vtx1.encorr0.evtNot-1.trig0.es1.txt"; |
115 |
< |
icFiles[1] = "calibres/deriveCalibConst.testCalibv1e.dflag42.pe1.cut3.rmOvlap0.step30.method2.corrEta1.corrPhi0.corrDead0.precalib1.vtx1.encorr0.evtNot-1.trig0.es1.txt"; |
116 |
< |
icFiles[2] = "calibres/deriveCalibConst.testCalibv1e.dflag45.pe1.cut3.rmOvlap0.step25.method2.corrEta1.corrPhi0.corrDead0.precalib1.vtx1.encorr0.evtNot-1.trig0.es1.txt"; |
117 |
< |
|
118 |
< |
|
119 |
< |
icFiles[3] = "calibres/deriveCalibConst.testCalibv1e.dflag124.pe2.cut1.rmOvlap0.step30.method2.corrEta1.corrPhi0.corrDead0.precalib1.vtx1.encorr0.evtNot-1.trig0.es1.txt"; |
120 |
< |
icFiles[4] = "calibres/deriveCalibConst.testCalibv1e.dflag122.pe2.cut1.rmOvlap0.step40.method2.corrEta1.corrPhi0.corrDead0.precalib1.vtx1.encorr0.evtNot-1.trig0.es1.txt"; |
121 |
< |
icFiles[5] = "calibres/deriveCalibConst.testCalibv1e.dflag125.pe2.cut3.rmOvlap0.step35.method2.corrEta1.corrPhi0.corrDead0.precalib1.vtx1.encorr0.evtNot-1.trig0.es1.txt"; |
110 |
> |
icFiles[0] = "calibres/deriveCalibConst.dflag2.pe1.step2.iter50.txt"; |
111 |
> |
icFiles[1] = "calibres/deriveCalibConst.dflag3.pe2.step2.iter50.txt"; |
112 |
|
|
113 |
< |
int nIC = 3; |
113 |
> |
int nIC = 1; |
114 |
|
|
115 |
+ |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag2.txt",ndeadflag_ic[0]); |
116 |
+ |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag3.txt",ndeadflag_ic[1]); |
117 |
|
|
126 |
– |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag41.txt",ndeadflag_ic[0]); |
127 |
– |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag42.txt",ndeadflag_ic[1]); |
128 |
– |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag45.txt",ndeadflag_ic[2]); |
118 |
|
|
130 |
– |
|
131 |
– |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag124.txt",ndeadflag_ic[3]); |
132 |
– |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag122.txt",ndeadflag_ic[4]); |
133 |
– |
getCrystaldeadflagEndcap_v1("deadflag/crystal_deadflag_ee_dflag125.txt",ndeadflag_ic[5]); |
134 |
– |
|
135 |
– |
|
136 |
– |
|
119 |
|
int nConstantSet = int(icFiles.size()); |
120 |
|
|
121 |
|
if( nConstantSet >50){ |
129 |
|
|
130 |
|
TFile *fnew = new TFile("combineCalibConstantEndcapv1.root","recreate"); |
131 |
|
|
132 |
+ |
|
133 |
|
|
134 |
|
TH1F *hh_cc_ietaring[50][3][40]; //file,ee-/ee+/both, ring, |
135 |
|
TH1F *hh_res_cc_ietaring[50][3][3]; |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
< |
TH1F *hh_c_deadflag[51][20]; |
244 |
< |
TH1F *hh_c_deadflag_period[51][20]; |
243 |
> |
TH1F *hh_c_deadflag[51][30]; |
244 |
> |
TH1F *hh_c_deadflag_period[51][30]; |
245 |
|
for(int j=0; j< nConstantSet+1; j++){ |
246 |
< |
for(int k=0; k<20; k++){ |
246 |
> |
for(int k=0; k<30; k++){ |
247 |
|
TString histname = TString(Form("hh_c_deadflag_%d_%d",j,k)); |
248 |
|
hh_c_deadflag[j][k] = new TH1F(histname,histname,500,0,2); |
249 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
275 |
– |
TH1F *hh_c_check[51][20]; |
276 |
– |
for(int j=0; j< nConstantSet+1; j++){ |
277 |
– |
for(int k=0; k<20; k++){ |
278 |
– |
TString histname = TString(Form("hh_c_check_%d_%d",j,k)); |
279 |
– |
hh_c_check[j][k] = new TH1F(histname,histname,500,0,2); |
280 |
– |
} |
281 |
– |
} |
282 |
– |
|
258 |
|
|
259 |
|
ofstream txtoutcheck("combineCalibConstantEndcapv1.txt",ios::out); |
260 |
|
|
261 |
|
|
262 |
|
for(int n=0; n< nConstantSet; n++){ |
263 |
|
string filename = icFiles[n]; |
264 |
+ |
|
265 |
+ |
|
266 |
|
getInterCalibEndcap(filename.c_str(),cc); |
267 |
|
|
268 |
|
|
276 |
|
for(int j=0; j<101; j++){ |
277 |
|
for(int k=0; k< 101; k++){ |
278 |
|
ic[n][iz][j][k] = cc[iz][j][k]; |
279 |
+ |
|
280 |
+ |
if( ndeadflag_ic[n][iz][j][k] < 0 && ic[n][iz][j][k] >0){ |
281 |
+ |
cout<<"warning (can be ignored) dead crystal " <<ic[n][iz][j][k] <<endl; |
282 |
+ |
ic[n][iz][j][k] = -1; |
283 |
+ |
} |
284 |
+ |
|
285 |
|
} |
286 |
|
} |
287 |
|
} |
288 |
+ |
|
289 |
+ |
|
290 |
+ |
|
291 |
|
} |
292 |
|
|
293 |
+ |
|
294 |
+ |
cout<<" nConstantSet " << nConstantSet <<endl; |
295 |
+ |
|
296 |
+ |
|
297 |
|
for(int n=0; n< nConstantSet; n++){ |
298 |
|
|
299 |
|
for(int iz=0; iz<2; iz++){ |
303 |
|
if( validRecHitEndCap[iz][j][k] <1) { |
304 |
|
continue; |
305 |
|
} |
306 |
+ |
|
307 |
|
int iring = iRingEndCap(2*iz-1,j,k); ///input -1/1, |
308 |
|
float c = ic[n][iz][j][k]; |
309 |
|
if(c >0){ |
336 |
|
hh2_diff_cc[n][m][iz]->SetBinContent(j,k,c1-c2); |
337 |
|
hh_diff_cc_ietaring[n][m][iz][iring]->Fill( (c1 -c2)/(0.5*(c1+c2))); |
338 |
|
hh_diff_cc_ietaring[n][m][2][iring]->Fill( (c1 -c2)/(0.5*(c1+c2))); |
348 |
– |
//hh_diff_cc_ietaring[n][m][2][iring]->Fill( (c1 -c2)); |
349 |
– |
|
339 |
|
|
340 |
|
}else{ |
341 |
|
hh2_diff_cc[n][m][iz]->SetBinContent(j,k,-1); |
388 |
|
} |
389 |
|
} |
390 |
|
|
402 |
– |
//float sigmaTB = 2.5; ///precision of precalib+LC |
403 |
– |
//float sigmaTB = 3; ///precision of precalib+LC |
404 |
– |
|
391 |
|
|
392 |
< |
//Please note that this number is not precise at all. |
393 |
< |
float sigmaTB = 2; ///precision of precalib+LC |
392 |
> |
|
393 |
> |
float sigmaSys = 2; ///precision of precalib+LC |
394 |
|
|
395 |
|
|
396 |
|
cout<<"combine " <<endl; |
422 |
|
|
423 |
|
|
424 |
|
float sigma = hh_res_cc_ietaring[n][2][2]->GetBinContent(iring+1); |
425 |
< |
//float sigma = hh_res_cc_ietaring[n][iz][2]->GetBinContent(iring+1); |
426 |
< |
|
441 |
< |
if( sigma > sigmaTB){ |
442 |
< |
sigma = sqrt( sigma * sigma - sigmaTB * sigmaTB); |
443 |
< |
} |
425 |
> |
sigma = sqrt( sigma * sigma + sigmaSys * sigmaSys); |
426 |
> |
|
427 |
|
if( c > 0){ |
428 |
|
float tmp1 = c/ ( sigma * sigma); |
429 |
|
float tmp2 = 1/(sigma * sigma); |
436 |
|
wtSumS_period[nperiod] += tmp2; |
437 |
|
|
438 |
|
int deadflag = ndeadflag_ic[n][iz][j][k]; |
439 |
< |
hh_c_deadflag[n][deadflag]->Fill( c); |
440 |
< |
|
458 |
< |
if( iz == 0 && j>= 50 && j<=56 && k>= 25 && k<=31){ |
459 |
< |
hh_c_check[n][0]->Fill(c); |
439 |
> |
if(deadflag>=0){ |
440 |
> |
hh_c_deadflag[n][deadflag]->Fill( c); |
441 |
|
} |
442 |
+ |
|
443 |
|
} |
444 |
|
} |
445 |
|
|
446 |
|
if( wtSumC > 0){ |
447 |
|
icwt[iz][j][k] = wtSumC / wtSumS; |
448 |
|
|
449 |
+ |
|
450 |
|
hh_ccwtavg_ietaring[iz][iring] ->Fill( icwt[iz][j][k] ); |
451 |
|
hh_ccwtavg_ietaring[2][iring] ->Fill( icwt[iz][j][k] ); |
452 |
|
|
504 |
|
string filename = string(Form("interCalibConstants.combinedPi0EtaPeriod%d.EcalEndcap.txt",j)); |
505 |
|
txtout_period[j].open(filename.c_str(),ios::out); |
506 |
|
} |
507 |
< |
|
507 |
> |
|
508 |
|
|
509 |
|
cout<<"print out final " <<endl; |
510 |
|
for(int iz=0; iz<2; iz++){ |
518 |
|
for(int n=0; n< nIC; n++){ ///for each period |
519 |
|
|
520 |
|
float sigmaC = hh_res_ccwtavg_ietaring_period[n][2][2]->GetBinContent(iring+1); |
521 |
< |
//float sigmaC = hh_res_ccwtavg_ietaring_period[n][iz][2]->GetBinContent(iring+1); |
522 |
< |
|
540 |
< |
float cErr = sigmaTB; |
541 |
< |
if( sigmaC > sigmaTB ){ |
542 |
< |
cErr = sqrt( sigmaC *sigmaC - sigmaTB * sigmaTB); |
543 |
< |
} |
521 |
> |
|
522 |
> |
float cErr = sqrt( sigmaC *sigmaC + sigmaSys * sigmaSys); |
523 |
|
cErr /=100; |
524 |
|
|
525 |
|
float c = icwt_period[n][iz][j][k]; |
526 |
|
if( c >0){ |
527 |
|
|
528 |
< |
int deadflag = ndeadflag_ic[n][iz][j][k]; |
529 |
< |
if(deadflag<0){ |
530 |
< |
cout<<"wrong deadflag ! " << n <<endl; |
531 |
< |
exit(1); |
528 |
> |
int deadflag1 = ndeadflag_ic[n%nIC][iz][j][k]; |
529 |
> |
int deadflag2 = ndeadflag_ic[nIC+n%nIC][iz][j][k]; |
530 |
> |
if(deadflag1<0 && deadflag2<0){ |
531 |
> |
cout<<"wrong deadflag ! " << n << " "<<iz <<" "<< j<<" "<<k <<endl; |
532 |
> |
return; |
533 |
|
} |
534 |
< |
hh_c_deadflag_period[n][deadflag]->Fill( c); |
535 |
< |
if(deadflag>0){ |
534 |
> |
if(deadflag1>0 ){ |
535 |
> |
hh_c_deadflag_period[n][deadflag1]->Fill( c); |
536 |
|
hh_c_deadflag_period[n][19]->Fill( c); |
537 |
|
} |
538 |
+ |
|
539 |
|
} |
540 |
|
|
541 |
|
if( c > 0){ |
542 |
< |
txtout_period[n]<<j<<" "<<k<<" "<< 2*iz-1<<" "<< c*ccalib_GR_42_V13[iz][j][k]<<" "<< cErr * c*ccalib_GR_42_V13[iz][j][k] <<endl; |
562 |
< |
//txtout_period[n]<<2*iz-1<<" "<< j<<" "<<k<<" "<< c * ccalib_GR_42_V13[iz][j][k] <<endl; |
542 |
> |
txtout_period[n]<<j<<" "<<k<<" "<< 2*iz-1<<" "<< c*ccalibpretag[iz][j][k]<<" "<< cErr * c*ccalibpretag[iz][j][k] <<endl; |
543 |
|
|
544 |
|
}else{ |
545 |
|
txtout_period[n]<<j<<" "<<k<<" "<< 2*iz-1<<" "<<-1 <<" "<< 999 <<endl; |
566 |
– |
//txtout_period[n]<<2*iz-1<<" "<< j<<" "<<k<<" "<< ccalib_GR_42_V13[iz][j][k] <<endl; |
546 |
|
} |
547 |
|
} |
548 |
|
|
552 |
|
hh2_cc_xy[nConstantSet][iz]->SetBinContent(j,k,c); |
553 |
|
|
554 |
|
float sigmaC = hh_res_ccwtavg_ietaring[2][2]->GetBinContent(iring+1); |
576 |
– |
//float sigmaC = hh_res_ccwtavg_ietaring[iz][2]->GetBinContent(iring+1); |
555 |
|
|
556 |
< |
float cErr = sigmaTB; |
579 |
< |
if( sigmaC > sigmaTB ){ |
580 |
< |
cErr = sqrt( sigmaC *sigmaC - sigmaTB * sigmaTB); |
581 |
< |
} |
556 |
> |
float cErr = sqrt( sigmaC *sigmaC + sigmaSys * sigmaSys); |
557 |
|
cErr /=100; |
558 |
< |
//txtout<<2*iz-1<<" "<< j<<" "<<k<<" "<< c * ccalib_GR_42_V13[iz][j][k] <<endl; |
584 |
< |
txtout<<j<<" "<<k<<" "<< 2*iz-1<<" "<< c * ccalib_GR_42_V13[iz][j][k] <<" "<< cErr * c * ccalib_GR_42_V13[iz][j][k] <<endl; |
558 |
> |
txtout<<j<<" "<<k<<" "<< 2*iz-1<<" "<< c * ccalibpretag[iz][j][k] <<" "<< cErr * c * ccalibpretag[iz][j][k] <<endl; |
559 |
|
}else{ |
586 |
– |
//txtout<<2*iz-1<<" "<< j<<" "<<k<<" "<< ccalib_GR_42_V13[iz][j][k] <<endl; |
560 |
|
txtout<<j<<" "<<k<<" "<< 2*iz-1<<" "<<-1 <<" "<< 999 <<endl; |
561 |
|
} |
562 |
|
} |
568 |
|
fnew->Close(); |
569 |
|
|
570 |
|
|
571 |
< |
|
571 |
> |
|
572 |
|
} |