24 #include <eicqa_modules/EvalRootTTree.h>
25 #include <eicqa_modules/EvalHit.h>
31 void LoopEvalHR(
int print = 1,
int debug = 0, Double_t energyCutAggregate = 0.1, Double_t energyCut = 0.0,
int MIP_theta_parametrisation = 1){
33 Double_t EMC_cut = 0.0;
34 TF1 *mip_pmzn_energy_cut_ftheta =
new TF1(
"mip_pmzn_energy_cut_ftheta",
"(9.46093e-01) - 1.62771*x + 1.37776*(x^2) - (5.4996e-01)*(x^3) + (8.82673e-02)*(x^4)");
37 if(MIP_theta_parametrisation == 1 && energyCut != 0){
38 throw std::invalid_argument(
"We do not currently support theta-parametrized \nMIP cut on EMC simultaneously with individual tower cuts \non other detectors.:(;");
43 int arraySizeBins = 0;
44 Double_t arraySizeBinsLoop = 0;
45 int lowThresholdBins = 2;
46 int highThresholdBins = 9;
47 Double_t maxEnergyBin = 30;
48 Double_t lowEnergyBin = 3;
51 while(arraySizeBinsLoop < maxEnergyBin){
53 if(arraySizeBinsLoop < lowEnergyBin){
54 arraySizeBinsLoop += lowEnergyBin/lowThresholdBins;
57 arraySizeBinsLoop += (maxEnergyBin - lowEnergyBin)/highThresholdBins;
61 Double_t binLimitArray[arraySizeBins + 1];
64 for(
int i = 0; i <= arraySizeBins; i++){
65 if(i <= lowThresholdBins){
66 binLimitArray[i] = lowEnergyBin*i/lowThresholdBins;
69 binLimitArray[i] = lowEnergyBin + ((maxEnergyBin - lowEnergyBin)*(i - lowThresholdBins)/highThresholdBins);
74 for(
int i = 0; i < arraySizeBins; i++){
75 cout<<
"element "<<i<<
" of the bin array is "<<binLimitArray[i]<<
" \n";
80 TString detector =
"CEMC_HCALIN_HCALOUT";
81 TFile *f1 =
new TFile(
"merged_Eval_HCALIN.root",
"READ");
82 TFile *
f2 =
new TFile(
"merged_Eval_HCALOUT.root",
"READ");
83 TFile *f3 =
new TFile(
"merged_Eval_CEMC.root",
"READ");
85 TTree*
T1 = (TTree*)f1->Get(
"T");
88 TTree*
T2 = (TTree*)f2->Get(
"T");
91 TTree*
T3 = (TTree*)f3->Get(
"T");
94 gStyle->SetCanvasPreferGL(kTRUE);
95 TCanvas *
c =
new TCanvas();
100 gStyle->SetOptTitle(0);
101 gStyle->SetOptFit(102);
102 gStyle->SetTitleXOffset(1);
103 gStyle->SetTitleYOffset(1);
104 gStyle->SetLabelSize(0.05);
105 gStyle->SetTitleXSize(0.05);
106 gStyle->SetTitleYSize(0.05);
108 long double total_te = 0;
109 long double total_te_CircularCut = 0;
110 long double total_ge = 0;
112 int nSlicesx = arraySizeBins;
114 Double_t eta_min, eta_max;
115 Double_t x_radius_HCALIN = 0.15;
116 Double_t y_radius_HCALIN = 0.25;
117 Double_t x_radius_HCALOUT = 0.2;
118 Double_t y_radius_HCALOUT = 0.3;
119 Double_t x_radius_CEMC = 0.1;
120 Double_t y_radius_CEMC = 0.2;
121 Double_t fit_min, fit_max;
122 Double_t sigma_min, sigma_max;
123 Double_t mean_min, mean_max;
124 Double_t chi2_min, chi2_max;
125 Double_t recalibration_factor;
126 Double_t recalibration_firstSlice = 3.8147;
127 Double_t recalibration_firstSlice_FHCAL = 0.0260;
128 Double_t recalibration_firstSlice_FEMC = 0.0300;
129 Double_t te_minus_ge_by_ge_ge_min, te_minus_ge_by_ge_ge_max;
142 te_minus_ge_by_ge_ge_min = -0.99;
143 te_minus_ge_by_ge_ge_max = 1.0;
146 TString cut_text =
" {-0.96 < geta < 0.92} ";
149 TH2D *te_minus_ge_by_ge_ge_EtaCut =
new TH2D(
"te_minus_ge_by_ge_ge_EtaCut",
"#frac{#Delta e_{agg}}{truth e} vs truth e",200,0,30,200,-2,1);
150 TH2D *te_minus_ge_by_ge_ge_EtaCut_CircularCut =
new TH2D(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut",
"#frac{#Delta e_{agg}}{truth e} vs truth e",200,0,30,200,-1.5,2);;
151 TH2D *te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated =
new TH2D(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated",
"#frac{#Delta e_{agg}}{truth e} vs truth e",200,0,30,200,-1.5,1.5);
152 TH2D *te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp =
new TH2D(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp",
"#frac{#Delta e_{agg}}{truth e} vs truth e",nSlicesx,binLimitArray,nSlicesy,te_minus_ge_by_ge_ge_min,te_minus_ge_by_ge_ge_max);
154 TH2D *te_minus_ge_by_ge_ge_EtaCut_temp =
new TH2D(
"te_minus_ge_by_ge_ge_EtaCut_temp",
"#frac{#Delta e_{agg}}{truth e} vs truth e",nSlicesx,binLimitArray,500,-0.99,1.3);
156 TH2D *te_by_ge_ge_EtaCut =
new TH2D(
"te_by_ge_ge_EtaCut",
"te_{agg}/ge vs ge",200,0,30,200,-0.5,1.5);
157 TH2D *te_by_ge_ge_EtaCut_CircularCut =
new TH2D(
"te_by_ge_ge_EtaCut_CircularCut",
"te_{agg}/ge vs ge",200,0,30,200,-1,2);
158 TH2D *te_by_ge_ge_EtaCut_CircularCut_HCALIN =
new TH2D(
"te_by_ge_ge_EtaCut_CircularCut_HCALIN",
"te_{agg}/ge vs ge",200,0,30,200,-1,2);
159 TH2D *te_by_ge_ge_EtaCut_CircularCut_HCALOUT =
new TH2D(
"te_by_ge_ge_EtaCut_CircularCut_HCALOUT",
"te_{agg}/ge vs ge",200,0,30,200,-1,2);
160 TH2D *te_by_ge_ge_EtaCut_CircularCut_CEMC =
new TH2D(
"te_by_ge_ge_EtaCut_CircularCut_CEMC",
"te_{agg}/ge vs ge",200,0,30,200,-1,2);
162 auto *mean_te_by_ge_ge_EtaCut_CircularCut =
new TProfile(
"mean_te_by_ge_ge_EtaCut_CircularCut",
"Mean_{te/ge}",nSlicesx,binLimitArray,-0.5,35);
163 auto *mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN =
new TProfile(
"mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN",
"Mean_{te/ge}",nSlicesx,binLimitArray,-0.5,35);
164 auto *mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT =
new TProfile(
"mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT",
"Mean_{te/ge}",nSlicesx,binLimitArray,-0.5,35);
165 auto *mean_te_by_ge_ge_EtaCut_CircularCut_CEMC =
new TProfile(
"mean_te_by_ge_ge_EtaCut_CircularCut_CEMC",
"Mean_{te/ge}",nSlicesx,binLimitArray,-0.5,35);
167 T1->SetBranchAddress(
"DST#EvalTTree_HCALIN",&evaltree1);
168 T2->SetBranchAddress(
"DST#EvalTTree_HCALOUT",&evaltree2);
169 T3->SetBranchAddress(
"DST#EvalTTree_CEMC",&evaltree3);
172 for(
int i=0; i<T1->GetEntries(); i++)
179 std::cout<<
"\n\n\n------------------------------------------\nParticle: "<<i<<
"\n\n";
180 std::cout<<
"Initial Parameters "<<
"\n";
183 Double_t geta1 = evaltree1->
get_geta();
186 std::cout<<
"geta: "<<geta1<<
"\n";
189 if(geta1>=eta_min && geta1<=eta_max){
192 cout<<
"\ngeta cut applied (1.3, 3.3)"<<
"\n\n";
194 Double_t ge = evaltree1->
get_ge();
196 std::cout<<
"ge: "<<ge<<
"\n";
199 Double_t gphi = evaltree1->
get_gphi();
201 std::cout<<
"gphi: "<<gphi<<
"\n";
206 std::cout<<
"gtheta: "<<gtheta<<
"\n";
211 std::cout<<
"total_ge till now = "<<total_ge<<
"\n";
214 Double_t te_aggregate = 0;
215 Double_t te_aggregate_CircularCut = 0;
216 Double_t te_aggregate_HCALIN_CircularCut = 0;
217 Double_t te_aggregate_HCALOUT_CircularCut = 0;
222 std::cout<<
"\nHCALIN Tower: "<<j<<
"\n";
229 cout<<
"non-empty HCALIN tower\n";
234 std::cout<<
"tphi: "<<tphi<<
"\n";
239 std::cout<<
"ttheta: "<<ttheta<<
"\n";
242 Double_t dphi = tphi - gphi;
244 std::cout<<
"tphi-gphi: "<<dphi<<
"\n";
247 Double_t dtheta = ttheta - gtheta;
249 std::cout<<
"ttheta-gtheta: "<<dtheta<<
"\n";
252 Double_t te = twr1->
get_te();
254 std::cout<<
"te: "<<te<<
"\n";
261 std::cout<<
"HCALIN: pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALOUT,2) = "<<pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2)<<
"\n";
264 if (pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2)<=1){
266 cout<<
"HCALIN Tower included after circular cut\n";
269 te_aggregate_CircularCut += te;
270 te_aggregate_HCALIN_CircularCut += te;
275 cout<<
"te_aggregate till now = "<<te_aggregate<<
"\n";
276 std::cout<<
"te += "<<twr1->
get_te()<<
"\n";
277 cout<<
"te_aggregate_CircularCut till now = "<<te_aggregate_CircularCut<<
"\n";
287 std::cout<<
"\nHCALOUT Tower: "<<j<<
"\n";
294 cout<<
"non-empty HCALOUT tower\n";
299 std::cout<<
"tphi: "<<tphi<<
"\n";
304 std::cout<<
"ttheta: "<<ttheta<<
"\n";
307 Double_t dphi = tphi - gphi;
309 std::cout<<
"tphi-gphi: "<<dphi<<
"\n";
312 Double_t dtheta = ttheta - gtheta;
314 std::cout<<
"ttheta-gtheta: "<<dtheta<<
"\n";
317 Double_t te = twr2->
get_te();
319 std::cout<<
"te: "<<te<<
"\n";
326 std::cout<<
"HCALOUT: pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2): "<<pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2)<<
"\n";
329 if (pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2)<=1){
331 cout<<
"HCALOUT Tower included after circular cut\n";
334 te_aggregate_HCALOUT_CircularCut += te;
335 te_aggregate_CircularCut += te;
339 cout<<
"te_aggregate till now = "<<te_aggregate<<
"\n";
340 cout<<
"te_aggregate_CircularCut till now = "<<te_aggregate_CircularCut<<
"\n";
341 std::cout<<
"te += "<<twr2->
get_te()<<
"\n";
352 std::cout<<
"\nCEMC Tower: "<<j<<
"\n";
359 cout<<
"non-empty CEMC tower\n";
364 std::cout<<
"tphi: "<<tphi<<
"\n";
369 std::cout<<
"ttheta: "<<ttheta<<
"\n";
372 Double_t dphi = tphi - gphi;
374 std::cout<<
"tphi-gphi: "<<dphi<<
"\n";
377 Double_t dtheta = ttheta - gtheta;
379 std::cout<<
"ttheta-gtheta: "<<dtheta<<
"\n";
382 Double_t te = twr3->
get_te();
384 std::cout<<
"te: "<<te<<
"\n";
387 if(MIP_theta_parametrisation == 1){
388 EMC_cut = mip_pmzn_energy_cut_ftheta->Eval(gtheta);
391 if(te > energyCut + EMC_cut){
395 std::cout<<
"CEMC: pow(dphi/y_radius,2)+pow(dtheta/x_radius,2): "<<pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2)<<
"\n";
398 if (pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2)<=1){
400 cout<<
"CEMC Tower included after circular cut\n";
402 te_aggregate_CircularCut += te;
406 cout<<
"te_aggregate till now = "<<te_aggregate<<
"\n";
407 cout<<
"te_aggregate_CircularCut till now = "<<te_aggregate_CircularCut<<
"\n";
408 std::cout<<
"te += "<<twr3->
get_te()<<
"\n";
414 total_te += te_aggregate;
415 total_te_CircularCut += te_aggregate_CircularCut;
418 cout<<
"total_te till now = "<<total_te<<
"\n";
419 cout<<
"total_te_CircularCut till now = "<<total_te_CircularCut<<
"\n\n";
422 if(te_aggregate_CircularCut > energyCutAggregate){
424 te_minus_ge_by_ge_ge_EtaCut->Fill(ge, (te_aggregate-ge)/ge);
427 cout<<
"(ge, (te_aggregate-ge)/ge): ("<<ge<<
", "<<(te_aggregate-ge)/ge<<
")\n";
430 te_minus_ge_by_ge_ge_EtaCut_CircularCut->Fill(ge, (te_aggregate_CircularCut-ge)/ge);
432 cout<<
"(ge, (te_aggregate_CircularCut-ge)/ge): ("<<ge<<
", "<<(te_aggregate_CircularCut-ge)/ge<<
")\n";
442 te_by_ge_ge_EtaCut->Fill(ge, te_aggregate/ge);
445 cout<<
"(ge, te_aggregate/ge): ("<<ge<<
", "<<te_aggregate/ge<<
")\n";
448 te_by_ge_ge_EtaCut_CircularCut->Fill(ge, te_aggregate_CircularCut/ge);
449 te_by_ge_ge_EtaCut_CircularCut_HCALIN->Fill(ge, te_aggregate_HCALIN_CircularCut/ge);
450 te_by_ge_ge_EtaCut_CircularCut_HCALOUT->Fill(ge, te_aggregate_HCALOUT_CircularCut/ge);
451 te_by_ge_ge_EtaCut_CircularCut_CEMC->Fill(ge, (te_aggregate_CircularCut-te_aggregate_HCALIN_CircularCut-te_aggregate_HCALOUT_CircularCut)/ge);
453 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->Fill(ge, te_aggregate_HCALIN_CircularCut/ge);
454 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->Fill(ge, te_aggregate_HCALOUT_CircularCut/ge);
455 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->Fill(ge, (te_aggregate_CircularCut-te_aggregate_HCALIN_CircularCut-te_aggregate_HCALOUT_CircularCut)/ge);
459 cout<<
"\n(ge, te_aggregate_CircularCut/ge): ("<<ge<<
", "<<te_aggregate_CircularCut/ge<<
")\n";
460 cout<<
"(ge, te_aggregate_HCALIN_CircularCut/ge): ("<<ge<<
", "<<te_aggregate_HCALIN_CircularCut/ge<<
")\n";
461 cout<<
"(ge, te_aggregate_HCALOUT_CircularCut/ge): ("<<ge<<
", "<<te_aggregate_HCALOUT_CircularCut/ge<<
")\n";
462 cout<<
"(ge, (te_aggregate_CircularCut-te_aggregate_HCALIN_CircularCut - te_aggregate_HCALOUT_CircularCut)/ge): ("<<ge<<
", "<<(te_aggregate_CircularCut-te_aggregate_HCALIN_CircularCut - te_aggregate_HCALOUT_CircularCut)/ge<<
")\n\n";
469 cout<<
"\neta cut if ends"<<
"\n";
474 TString arr[nSlicesx];
475 for(
int sno = 0; sno < nSlicesx; sno++){
476 arr[sno] = TString::Itoa(sno + 1, 10);
480 std::cout<<
"\nGenerating sigma_e vs ge plots\n\n";
483 Double_t recalibrationArr1[nSlicesx];
484 Double_t rf_integral_HCALIN = 0;
485 Double_t weight_HCALIN = te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetMean(2);
488 cout <<
"HCALIN weight is : " << weight_HCALIN << endl;
495 for(
int binIter = 1; binIter <= nSlicesx; binIter++){
496 recalibrationArr1[binIter-1] = mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetBinContent(binIter);
497 rf_integral_HCALIN += recalibrationArr1[binIter-1];
500 cout<<
"rf_integral_HCALIN += "<<recalibrationArr1[binIter-1]<<
"\n";
503 cout <<
"Recalibration factor for slice " << binIter <<
" of HCALIN is: " << recalibrationArr1[binIter-1] << endl;
507 cout<<
"rf_integral_HCALIN = "<<rf_integral_HCALIN<<
"\n\n";
510 Double_t recalibrationArr2[nSlicesx];
511 Double_t rf_integral_HCALOUT = 0;
512 Double_t weight_HCALOUT = te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetMean(2);
515 cout <<
"HCALOUT weight is : " << weight_HCALOUT << endl;
522 for(
int binIter = 1; binIter <= nSlicesx; binIter++){
523 recalibrationArr2[binIter-1] = mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetBinContent(binIter);
524 rf_integral_HCALOUT += recalibrationArr2[binIter-1];
527 cout<<
"rf_integral_HCALOUT += "<<recalibrationArr2[binIter-1]<<
"\n";
530 cout <<
"Recalibration factor for slice " << binIter <<
" of HCALOUT is: " << recalibrationArr2[binIter-1] << endl;
534 cout<<
"rf_integral_HCALOUT = "<<rf_integral_HCALOUT<<
"\n\n";
538 Double_t recalibrationArr3[nSlicesx];
539 Double_t rf_integral_CEMC = 0;
540 Double_t weight_CEMC = te_by_ge_ge_EtaCut_CircularCut_CEMC->GetMean(2);
543 cout <<
"CEMC weight is : " << weight_CEMC << endl;
550 for(
int binIter = 1; binIter <= nSlicesx; binIter++){
551 recalibrationArr3[binIter-1] = mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->GetBinContent(binIter);
552 rf_integral_CEMC += recalibrationArr3[binIter-1];
555 cout<<
"rf_integral_CEMC += "<<recalibrationArr3[binIter-1]<<
"\n";
558 cout <<
"Recalibration factor for slice " << binIter <<
" of CEMC is: " << recalibrationArr3[binIter-1] << endl;
562 cout<<
"rf_integral_CEMC = "<<rf_integral_CEMC<<
"\n\n";
565 for(
int i=0; i<T1->GetEntries(); i++){
571 Double_t geta1 = evaltree1->
get_geta();
572 Double_t gphi = evaltree1->
get_gphi();
574 Double_t ge = evaltree1->
get_ge();
575 Double_t te_aggregate_CircularCut = 0;
576 Double_t te_aggregate_CircularCut_normalised = 0;
578 int recalibration_factor = 0;
580 if(ge > lowEnergyBin){
581 Double_t eRangeBin = (maxEnergyBin - lowEnergyBin)/highThresholdBins;
582 recalibration_factor = (lowThresholdBins - 1) + ceil(ge/eRangeBin)- 1;
586 recalibration_factor = ceil((ge/lowEnergyBin)*(Double_t)lowThresholdBins)- 1;
590 cout <<
"Recalibration index in Loop 2 is : " << recalibration_factor << endl;
593 if(geta1>=eta_min && geta1<=eta_max){
603 Double_t dphi = tphi - gphi;
604 Double_t dtheta = ttheta - gtheta;
605 Double_t te = twr1->
get_te();
610 std::cout<<
"pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2): "<<pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2)<<
"\n";
613 if (pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2)<=1){
614 te_aggregate_CircularCut += te;
615 te_aggregate_CircularCut_normalised += te*weight_HCALIN/recalibrationArr1[recalibration_factor];
628 Double_t dphi = tphi - gphi;
629 Double_t dtheta = ttheta - gtheta;
630 Double_t te = twr2->
get_te();
635 std::cout<<
"pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2): "<<pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2)<<
"\n";
638 if (pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2)<=1){
639 te_aggregate_CircularCut += te;
640 te_aggregate_CircularCut_normalised += te*weight_HCALOUT/recalibrationArr2[recalibration_factor];
653 Double_t dphi = tphi - gphi;
654 Double_t dtheta = ttheta - gtheta;
655 Double_t te = twr3->
get_te();
657 if(MIP_theta_parametrisation == 1){
658 EMC_cut = mip_pmzn_energy_cut_ftheta->Eval(gtheta);
661 if(te > energyCut + EMC_cut){
664 std::cout<<
"pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2): "<<pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2)<<
"\n";
667 if (pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2)<=1){
668 te_aggregate_CircularCut += te;
669 te_aggregate_CircularCut_normalised += te*weight_CEMC/recalibrationArr3[recalibration_factor];
675 if(te_aggregate_CircularCut > energyCutAggregate){
676 mean_te_by_ge_ge_EtaCut_CircularCut->Fill(ge, te_aggregate_CircularCut_normalised/ge);
679 cout <<
"mean_te_by_ge_ge_EtaCut_CircularCut entry " << i <<
" is : " << te_aggregate_CircularCut_normalised/ge << endl;
685 cout<<
"(ge, te_aggregate_CircularCut_normalised/ge): ("<<ge<<
", "<<te_aggregate_CircularCut_normalised/ge<<
")\n";
691 Double_t recalibrationArr[nSlicesx];
696 for(
int binIter = 1; binIter <= nSlicesx; binIter++){
697 recalibrationArr[binIter-1] = mean_te_by_ge_ge_EtaCut_CircularCut->GetBinContent(binIter);
698 cout <<
"Recalibration factor for slice " << binIter <<
" is: " << recalibrationArr[binIter-1] << endl;
702 for(
int i=0; i<T1->GetEntries(); i++){
708 Double_t geta1 = evaltree1->
get_geta();
709 Double_t gphi = evaltree1->
get_gphi();
711 Double_t ge = evaltree1->
get_ge();
712 Double_t te_aggregate_CircularCut = 0;
713 Double_t te_aggregate_CircularCut_normalised = 0;
715 int recalibration_factor = 0;
718 if(ge > lowEnergyBin){
719 Double_t eRangeBin = (maxEnergyBin - lowEnergyBin)/highThresholdBins;
720 recalibration_factor = (lowThresholdBins - 1) + ceil(ge/eRangeBin)- 1;
724 recalibration_factor = ceil((ge/lowEnergyBin)*(Double_t)lowThresholdBins)- 1;
728 cout <<
"Recalibration index in Loop 3 is : " << recalibration_factor << endl;
731 if(geta1>=eta_min && geta1<=eta_max){
741 Double_t dphi = tphi - gphi;
742 Double_t dtheta = ttheta - gtheta;
743 Double_t te = twr1->
get_te();
748 std::cout<<
"pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2): "<<pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2)<<
"\n";
751 if (pow(dphi/y_radius_HCALIN,2)+pow(dtheta/x_radius_HCALIN,2)<=1){
752 te_aggregate_CircularCut += te;
753 te_aggregate_CircularCut_normalised += te*weight_HCALIN/recalibrationArr1[recalibration_factor];
766 Double_t dphi = tphi - gphi;
767 Double_t dtheta = ttheta - gtheta;
768 Double_t te = twr2->
get_te();
773 std::cout<<
"pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2): "<<pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2)<<
"\n";
776 if (pow(dphi/y_radius_HCALOUT,2)+pow(dtheta/x_radius_HCALOUT,2)<=1){
777 te_aggregate_CircularCut += te;
778 te_aggregate_CircularCut_normalised += te*weight_HCALOUT/recalibrationArr2[recalibration_factor];
791 Double_t dphi = tphi - gphi;
792 Double_t dtheta = ttheta - gtheta;
793 Double_t te = twr3->
get_te();
795 if(MIP_theta_parametrisation == 1){
796 EMC_cut = mip_pmzn_energy_cut_ftheta->Eval(gtheta);
799 if(te > energyCut + EMC_cut){
802 std::cout<<
"pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2): "<<pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2)<<
"\n";
805 if (pow(dphi/y_radius_CEMC,2)+pow(dtheta/x_radius_CEMC,2)<=1){
806 te_aggregate_CircularCut += te;
807 te_aggregate_CircularCut_normalised += te*weight_CEMC/recalibrationArr3[recalibration_factor];
813 if(te_aggregate_CircularCut > energyCutAggregate){
814 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->Fill(ge, ((te_aggregate_CircularCut_normalised/recalibrationArr[recalibration_factor])-ge)/ge);
815 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp->Fill(ge, ((te_aggregate_CircularCut_normalised/recalibrationArr[recalibration_factor])-ge)/ge);
818 cout <<
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated entry " << i <<
" is : " << ((te_aggregate_CircularCut_normalised/recalibrationArr[recalibration_factor])-ge)/ge << endl;
824 cout<<
"(ge, ((te_aggregate_CircularCut_normalised/recalibration_factor)-ge)/ge: ("<<ge<<
", "<<((te_aggregate_CircularCut_normalised/recalibrationArr[recalibration_factor])-ge)/ge<<
")\n";
831 TF1 *fit =
new TF1(
"fit",
"gaus");
832 TF1 *fit1 =
new TF1(
"fit1",
"gaus",fit_min,fit_max);
833 TF1 *fExp =
new TF1(
"fExp",
"0.1 + 1.0/sqrt(x)",0,30);
834 TF1 *fTrue =
new TF1(
"fTrue",
"[0] + [1]/sqrt(x)",0,30);
837 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp->FitSlicesY(0, 1, -1, 0,
"QN");
838 TH2D *te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2 = (TH2D*)gDirectory->Get(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2");
839 TH2D *te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1 = (TH2D*)gDirectory->Get(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1");
840 TH2D *te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2 = (TH2D*)gDirectory->Get(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2");
844 TH1D* slices[nSlicesx];
847 for(
int sno = 0; sno < nSlicesx; sno++){
849 TString sname =
"slice " + arr[sno];
850 slices[sno] = te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp->ProjectionY(sname, plusOne, plusOne);
855 cout<<
"\nHistogram Formatting\n\n";
858 te_minus_ge_by_ge_ge_EtaCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
859 te_minus_ge_by_ge_ge_EtaCut->GetXaxis()->SetLabelSize(0.05);
860 te_minus_ge_by_ge_ge_EtaCut->GetXaxis()->SetTitleSize(0.05);
861 te_minus_ge_by_ge_ge_EtaCut->GetYaxis()->SetTitle(
"(te_{agg}-ge)/ge");
862 te_minus_ge_by_ge_ge_EtaCut->GetYaxis()->SetLabelSize(0.05);
863 te_minus_ge_by_ge_ge_EtaCut->GetYaxis()->SetTitleSize(0.05);
865 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
866 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetLabelSize(0.05);
867 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitleSize(0.05);
868 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitle(
"(te_{agg}-ge)/ge");
869 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetLabelSize(0.05);
870 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitleSize(0.05);
872 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
873 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetXaxis()->SetLabelSize(0.05);
874 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetXaxis()->SetTitleSize(0.05);
875 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetYaxis()->SetTitle(
"(te_{agg}-ge)/ge");
876 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetYaxis()->SetLabelSize(0.05);
877 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetYaxis()->SetTitleSize(0.05);
879 te_by_ge_ge_EtaCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
880 te_by_ge_ge_EtaCut->GetXaxis()->SetLabelSize(0.05);
881 te_by_ge_ge_EtaCut->GetXaxis()->SetTitleSize(0.05);
882 te_by_ge_ge_EtaCut->GetYaxis()->SetTitle(
"te_{agg}/ge");
883 te_by_ge_ge_EtaCut->GetYaxis()->SetLabelSize(0.05);
884 te_by_ge_ge_EtaCut->GetYaxis()->SetTitleSize(0.05);
886 te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
887 te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetLabelSize(0.05);
888 te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitleSize(0.05);
889 te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitle(
"te_{agg}/ge");
890 te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetLabelSize(0.05);
891 te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitleSize(0.05);
893 mean_te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
894 mean_te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetLabelSize(0.05);
895 mean_te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitleSize(0.05);
896 mean_te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitle(
"Mean of te_{agg}/ge");
897 mean_te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetLabelSize(0.05);
898 mean_te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitleSize(0.05);
900 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
901 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetXaxis()->SetLabelSize(0.05);
902 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetXaxis()->SetTitleSize(0.05);
903 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetYaxis()->SetTitle(
"Mean of te_{agg}/ge (HCALIN)");
904 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetYaxis()->SetLabelSize(0.05);
905 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->GetYaxis()->SetTitleSize(0.05);
907 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
908 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetXaxis()->SetLabelSize(0.05);
909 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetXaxis()->SetTitleSize(0.05);
910 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetYaxis()->SetTitle(
"Mean of te_{agg}/ge (HCALOUT)");
911 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetYaxis()->SetLabelSize(0.05);
912 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->GetYaxis()->SetTitleSize(0.05);
914 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
915 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->GetXaxis()->SetLabelSize(0.05);
916 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->GetXaxis()->SetTitleSize(0.05);
917 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->GetYaxis()->SetTitle(
"Mean of te_{agg}/ge (CEMC)");
918 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->GetYaxis()->SetLabelSize(0.05);
919 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->GetYaxis()->SetTitleSize(0.05);
921 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
922 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetXaxis()->SetLabelSize(0.05);
923 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetXaxis()->SetTitleSize(0.05);
924 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetYaxis()->SetTitle(
"#sigma_{e_{agg}}");
925 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetYaxis()->SetLabelSize(0.05);
926 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetYaxis()->SetTitleSize(0.05);
929 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
930 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetXaxis()->SetLabelSize(0.05);
931 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetXaxis()->SetTitleSize(0.05);
932 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetYaxis()->SetTitle(
"Reduced_#chi^{2}_{e_{agg}}");
933 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetYaxis()->SetLabelSize(0.05);
934 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetYaxis()->SetTitleSize(0.04);
937 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
938 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetXaxis()->SetLabelSize(0.05);
939 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetXaxis()->SetTitleSize(0.05);
940 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetYaxis()->SetTitle(
"Mean_{e_{agg}}");
941 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetYaxis()->SetLabelSize(0.05);
942 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetYaxis()->SetTitleSize(0.05);
945 for(
int sno = 0; sno < nSlicesx; sno++){
946 slices[sno]->GetXaxis()->SetTitle(
"#Delta e^{agg}/ ge");
947 slices[sno]->GetXaxis()->SetLabelSize(0.05);
948 slices[sno]->GetXaxis()->SetTitleSize(0.05);
949 slices[sno]->GetYaxis()->SetTitle(
"Counts");
950 slices[sno]->GetYaxis()->SetLabelSize(0.05);
951 slices[sno]->GetYaxis()->SetTitleSize(0.05);
955 std::cout<<
"\nWrite Histograms to File\n";
958 TFile *f =
new TFile(
"energy_verification_EtaCut_CircularCut_" + detector +
".root",
"RECREATE");
960 f->GetList()->Add(te_by_ge_ge_EtaCut);
961 f->GetList()->Add(te_by_ge_ge_EtaCut_CircularCut);
962 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut);
963 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut);
964 f->GetList()->Add(mean_te_by_ge_ge_EtaCut_CircularCut);
965 f->GetList()->Add(mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN);
966 f->GetList()->Add(mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT);
967 f->GetList()->Add(mean_te_by_ge_ge_EtaCut_CircularCut_CEMC);
968 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated);
969 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2);
970 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1);
971 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2);
973 for(
int sno = 0; sno < nSlicesx; sno++){
974 f->GetList()->Add(slices[sno]);
980 gStyle -> SetOptFit(112);
1007 std::cout<<
"\nSaving Histograms as .png\n";
1012 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->SetAxisRange(mean_min,mean_max,
"Y");
1013 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->Draw();
1020 c->Print(detector +
"_meanE_ge_EtaCut_CircularCut.png");
1022 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->SetAxisRange(chi2_min,chi2_max,
"Y");
1023 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->Draw();
1030 c->Print(detector +
"_chi2E_ge_EtaCut_CircularCut.png");
1033 gStyle -> SetOptFit(0);
1041 fExp->SetLineColor(4);
1042 fTrue->SetLineColor(2);
1044 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetMarkerStyle(kFullCircle);
1045 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetMarkerColor(46);
1046 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetMarkerSize(0.75);
1047 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetAxisRange(sigma_min,sigma_max,
"Y");
1049 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->Fit(
"fTrue",
"M+");
1050 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->Draw(
"same");
1056 TLegend* legend =
new TLegend(1.75,1.75);
1057 legend->SetHeader(
"Legend",
"C");
1060 legend->AddEntry(fTrue,
"p_{0} + p_{1}/#sqrt{ge} (Fitted)",
"l");
1061 legend->AddEntry((
TObject*)0,
"",
"");
1062 legend->AddEntry(fExp,
"0.1 + 1.0/#sqrt{ge} (Requirement)",
"l");
1063 legend->SetTextSize(0.033);
1066 std::cout<<
"reduced_chi2 of fit: "<<fTrue->GetChisquare()/fTrue->GetNDF()<<
"\n";
1068 c->Print(detector +
"_sigmaE_ge_EtaCut_CircularCut.png");
1071 gStyle -> SetOptFit(112);
1073 for(
int sno = 0; sno < nSlicesx; sno++){
1074 TString plusOne = (TString)(sno + 1);
1075 TString nameF = detector +
"_sigmaE_slice" + arr[sno] +
"_EtaCut_CircularCut.png";
1076 slices[sno] -> Fit(
"fit",
"M+");
1077 slices[sno] ->
Draw(
"hist same");
1083 te_by_ge_ge_EtaCut->Draw(
"colz");
1084 c->Print(detector +
"_te_by_ge_ge_EtaCut.png");
1085 te_by_ge_ge_EtaCut_CircularCut->Draw(
"colz");
1086 c->Print(detector +
"_te_by_ge_ge_EtaCut_CircularCut.png");
1088 te_minus_ge_by_ge_ge_EtaCut->Draw(
"colz");
1089 c->Print(detector +
"_te_minus_ge_by_ge_ge_EtaCut.png");
1090 te_minus_ge_by_ge_ge_EtaCut_CircularCut->Draw(
"colz");
1091 c->Print(detector +
"_te_minus_ge_by_ge_ge_EtaCut_CircularCut.png");
1092 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->Draw(
"colz");
1093 c->Print(detector +
"_te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated.png");
1097 mean_te_by_ge_ge_EtaCut_CircularCut->Draw();
1098 c->Print(detector +
"_mean_te_by_ge_ge_EtaCut_CircularCut.png");
1100 mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN->Draw();
1101 c->Print(detector +
"_mean_te_by_ge_ge_EtaCut_CircularCut_HCALIN.png");
1103 mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT->Draw();
1104 c->Print(detector +
"_mean_te_by_ge_ge_EtaCut_CircularCut_HCALOUT.png");
1106 mean_te_by_ge_ge_EtaCut_CircularCut_CEMC->Draw();
1107 c->Print(detector +
"_mean_te_by_ge_ge_EtaCut_CircularCut_CEMC.png");
1114 std::cout <<
"The total te is: " << total_te << endl;
1115 std::cout <<
"The total te_CircularCut is: " << total_te_CircularCut << endl;
1116 std::cout <<
"The total ge is: " << total_ge << endl;
1117 std::cout<<
"\n\nDone\n----------------------------------------------------------------------\n\n";