25 #include <eicqa_modules/EvalRootTTree.h>
26 #include <eicqa_modules/EvalHit.h>
33 void LoopEvalFR(
int print = 1,
int debug = 0, Double_t energyCutAggregate = 0.1, Double_t energyCut = 0.0,
int MIP_theta_parametrisation = 1)
36 Double_t EMC_cut = 0.0;
38 TF1 *mip_pmzn_energy_cut_ftheta =
new TF1(
"mip_pmzn_energy_cut_ftheta",
"0");
40 if(MIP_theta_parametrisation == 1 && energyCut != 0){
41 throw std::invalid_argument(
"We do not currently support theta-parametrized \nMIP cut on EMC simultaneously with individual tower cuts \non other detectors.:(;");
45 int arraySizeBins = 0;
46 Double_t arraySizeBinsLoop = 0;
47 int lowThresholdBins = 2;
48 int highThresholdBins = 9;
49 Double_t maxEnergyBin = 30;
50 Double_t lowEnergyBin = 3;
53 while(arraySizeBinsLoop < maxEnergyBin){
55 if(arraySizeBinsLoop < lowEnergyBin){
56 arraySizeBinsLoop += lowEnergyBin/lowThresholdBins;
59 arraySizeBinsLoop += (maxEnergyBin - lowEnergyBin)/highThresholdBins;
63 Double_t binLimitArray[arraySizeBins + 1];
66 for(
int i = 0; i <= arraySizeBins; i++){
67 if(i <= lowThresholdBins){
68 binLimitArray[i] = lowEnergyBin*i/lowThresholdBins;
71 binLimitArray[i] = lowEnergyBin + ((maxEnergyBin - lowEnergyBin)*(i - lowThresholdBins)/highThresholdBins);
76 for(
int i = 0; i < arraySizeBins; i++){
77 cout<<
"element "<<i<<
" of the bin array is "<<binLimitArray[i]<<
" \n";
82 TString detector =
"FEMC_FHCAL";
83 TFile *f1 =
new TFile(
"merged_Eval_FHCAL.root",
"READ");
84 TFile *
f2 =
new TFile(
"merged_Eval_FEMC.root",
"READ");
90 TTree*
T1 = (TTree*)f1->Get(
"T");
93 TTree*
T2 = (TTree*)f2->Get(
"T");
96 gStyle->SetCanvasPreferGL(kTRUE);
97 TCanvas *
c =
new TCanvas();
102 gStyle->SetOptTitle(0);
103 gStyle->SetOptFit(102);
104 gStyle->SetTitleXOffset(1);
105 gStyle->SetTitleYOffset(1);
106 gStyle->SetLabelSize(0.05);
107 gStyle->SetTitleXSize(0.05);
108 gStyle->SetTitleYSize(0.05);
110 long double total_te = 0;
111 long double total_te_CircularCut = 0;
112 long double total_ge = 0;
114 int nSlicesx = arraySizeBins;
116 Double_t eta_min, eta_max;
117 Double_t x_radius_FHCAL = 0.15;
118 Double_t y_radius_FHCAL = 0.45;
119 Double_t x_radius_FEMC = 0.13;
120 Double_t y_radius_FEMC = 0.35;
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 = 20.746;
127 Double_t recalibration_firstSlice_FHCAL = 0.2079;
128 Double_t recalibration_firstSlice_FEMC = 0.1498;
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 =
" {1.4 < geta < 3.0} ";
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);
153 TH2D *te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_FEMC =
new TH2D(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_FEMC",
"#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_CircularCut_Recalibrated_FHCAL =
new TH2D(
"te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_FHCAL",
"#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);
156 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);
158 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);
160 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);
161 TH2D *te_by_ge_ge_EtaCut_CircularCut =
new TH2D(
"te_by_ge_ge_EtaCut_CircularCut",
"te_{agg}/ge vs ge",200,0,30,200,-0.5,1.5);
163 TH2D *te_by_ge_ge_EtaCut_CircularCut_FHCAL =
new TH2D(
"te_by_ge_ge_EtaCut_CircularCut_FHCAL",
"te_{agg}/ge vs ge",200,0,30,200,-1,2);
164 TH2D *te_by_ge_ge_EtaCut_CircularCut_FEMC =
new TH2D(
"te_by_ge_ge_EtaCut_CircularCut_FEMC",
"te_{agg}/ge vs ge",200,0,30,200,-1,2);
166 TH1D *te_aggregate_EtaCut_CircularCut_FEMC =
new TH1D(
"te_aggregate_EtaCut_CircularCut_FEMC",
"",200,0,1);
168 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);
169 auto *mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL =
new TProfile(
"mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL",
"Mean_{te/ge}",nSlicesx,binLimitArray,-0.5,35);
170 auto *mean_te_by_ge_ge_EtaCut_CircularCut_FEMC =
new TProfile(
"mean_te_by_ge_ge_EtaCut_CircularCut_FEMC",
"Mean_{te/ge}",nSlicesx,binLimitArray,-0.5,35);
172 T1->SetBranchAddress(
"DST#EvalTTree_FHCAL",&evaltree1);
173 T2->SetBranchAddress(
"DST#EvalTTree_FEMC",&evaltree2);
175 for(
int i=0; i<T1->GetEntries(); i++)
181 std::cout<<
"\n\n\n------------------------------------------\nParticle: "<<i<<
"\n\n";
182 std::cout<<
"Initial Parameters "<<
"\n";
185 Double_t geta1 = evaltree1->
get_geta();
188 std::cout<<
"geta: "<<geta1<<
"\n";
191 if(geta1>=eta_min && geta1<=eta_max){
194 cout<<
"\ngeta cut applied (1.3, 3.3)"<<
"\n\n";
196 Double_t ge = evaltree1->
get_ge();
198 std::cout<<
"ge: "<<ge<<
"\n";
201 Double_t gphi = evaltree1->
get_gphi();
203 std::cout<<
"gphi: "<<gphi<<
"\n";
208 std::cout<<
"gtheta: "<<gtheta<<
"\n";
213 std::cout<<
"total_ge till now = "<<total_ge<<
"\n";
216 Double_t te_aggregate = 0;
217 Double_t te_aggregate_CircularCut = 0;
218 Double_t te_aggregate_FHCAL_CircularCut = 0;
223 std::cout<<
"\nFHCAL Tower: "<<j<<
"\n";
230 cout<<
"non-empty FHCAL tower\n";
235 std::cout<<
"tphi: "<<tphi<<
"\n";
240 std::cout<<
"ttheta: "<<ttheta<<
"\n";
243 Double_t dphi = tphi - gphi;
245 std::cout<<
"tphi-gphi: "<<dphi<<
"\n";
248 Double_t dtheta = ttheta - gtheta;
250 std::cout<<
"ttheta-gtheta: "<<dtheta<<
"\n";
253 Double_t te = twr1->
get_te();
255 std::cout<<
"te: "<<te<<
"\n";
262 std::cout<<
"FHCAL: pow(dphi/y_radius,2)+pow(dtheta/x_radius,2) = "<<pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2)<<
"\n";
265 if (pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2)<=1){
267 cout<<
"FHCAL Tower included after circular cut\n";
269 te_aggregate_CircularCut += te;
270 te_aggregate_FHCAL_CircularCut += te;
274 cout<<
"te_aggregate till now = "<<te_aggregate<<
"\n";
275 std::cout<<
"te += "<<twr1->
get_te()<<
"\n";
276 cout<<
"te_aggregate_CircularCut till now = "<<te_aggregate_CircularCut<<
"\n";
286 std::cout<<
"\nFEMC Tower: "<<j<<
"\n";
293 cout<<
"non-empty FEMC tower\n";
298 std::cout<<
"tphi: "<<tphi<<
"\n";
303 std::cout<<
"ttheta: "<<ttheta<<
"\n";
306 Double_t dphi = tphi - gphi;
308 std::cout<<
"tphi-gphi: "<<dphi<<
"\n";
311 Double_t dtheta = ttheta - gtheta;
313 std::cout<<
"ttheta-gtheta: "<<dtheta<<
"\n";
316 Double_t te = twr2->
get_te();
318 std::cout<<
"te: "<<te<<
"\n";
321 if(MIP_theta_parametrisation == 1){
322 EMC_cut = mip_pmzn_energy_cut_ftheta->Eval(gtheta);
325 if(te > energyCut + EMC_cut){
329 std::cout<<
"FEMC: pow(dphi/y_radius,2)+pow(dtheta/x_radius,2): "<<pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2)<<
"\n";
332 if (pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2)<=1){
334 cout<<
"FEMC Tower included after circular cut\n";
336 te_aggregate_CircularCut += te;
340 cout<<
"te_aggregate till now = "<<te_aggregate<<
"\n";
341 cout<<
"te_aggregate_CircularCut till now = "<<te_aggregate_CircularCut<<
"\n";
342 std::cout<<
"te += "<<twr2->
get_te()<<
"\n";
348 total_te += te_aggregate;
349 total_te_CircularCut += te_aggregate_CircularCut;
352 cout<<
"total_te till now = "<<total_te<<
"\n";
353 cout<<
"total_te_CircularCut till now = "<<total_te_CircularCut<<
"\n\n";
356 if(te_aggregate_CircularCut > energyCutAggregate){
358 if(te_aggregate_CircularCut < 0.1) {
360 cout <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
364 te_minus_ge_by_ge_ge_EtaCut->Fill(ge, (te_aggregate-ge)/ge);
367 cout<<
"(ge, (te_aggregate-ge)/ge): ("<<ge<<
", "<<(te_aggregate-ge)/ge<<
")\n";
370 te_minus_ge_by_ge_ge_EtaCut_CircularCut->Fill(ge, (te_aggregate_CircularCut-ge)/ge);
372 cout<<
"(ge, (te_aggregate_CircularCut-ge)/ge): ("<<ge<<
", "<<(te_aggregate_CircularCut-ge)/ge<<
")\n";
382 te_by_ge_ge_EtaCut->Fill(ge, te_aggregate/ge);
385 cout<<
"(ge, te_aggregate/ge): ("<<ge<<
", "<<te_aggregate/ge<<
")\n";
388 te_by_ge_ge_EtaCut_CircularCut->Fill(ge, te_aggregate_CircularCut/ge);
390 te_aggregate_EtaCut_CircularCut_FEMC->Fill(te_aggregate_CircularCut - te_aggregate_FHCAL_CircularCut);
392 te_by_ge_ge_EtaCut_CircularCut_FHCAL->Fill(ge, te_aggregate_FHCAL_CircularCut/ge);
393 te_by_ge_ge_EtaCut_CircularCut_FEMC->Fill(ge, (te_aggregate_CircularCut - te_aggregate_FHCAL_CircularCut)/ge);
395 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->Fill(ge, te_aggregate_FHCAL_CircularCut/ge);
396 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->Fill(ge, (te_aggregate_CircularCut-te_aggregate_FHCAL_CircularCut)/ge);
399 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_FHCAL->Fill(ge, (te_aggregate_FHCAL_CircularCut-ge)/ge);
400 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_FEMC->Fill(ge, (te_aggregate_CircularCut - te_aggregate_FHCAL_CircularCut-ge)/ge);
404 cout<<
"(ge, te_aggregate_CircularCut/ge): ("<<ge<<
", "<<te_aggregate_CircularCut/ge<<
")\n";
405 cout<<
"(ge, te_aggregate_FHCAL_CircularCut/ge): ("<<ge<<
", "<<te_aggregate_FHCAL_CircularCut/ge<<
")\n";
406 cout<<
"(ge, (te_aggregate_CircularCut-te_aggregate_FHCAL_CircularCut)/ge): ("<<ge<<
", "<<(te_aggregate_CircularCut-te_aggregate_FHCAL_CircularCut)/ge<<
")\n";
413 cout<<
"\neta cut if ends"<<
"\n";
418 TString arr[nSlicesx];
419 for(
int sno = 0; sno < nSlicesx; sno++){
420 arr[sno] = TString::Itoa(sno + 1, 10);
424 std::cout<<
"\nGenerating sigma_e vs ge plots\n\n";
427 Double_t recalibrationArr1[nSlicesx];
428 Double_t rf_integral_FHCAL = 0;
429 Double_t weight_FHCAL = te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetMean(2);
435 for(
int binIter = 1; binIter <= nSlicesx; binIter++){
436 recalibrationArr1[binIter-1] = mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetBinContent(binIter);
437 rf_integral_FHCAL += recalibrationArr1[binIter-1];
440 cout<<
"rf_integral_FHCAL += "<<recalibrationArr1[binIter-1]<<
"\n";
443 cout <<
"Recalibration factor for slice " << binIter <<
" of FHCAL is: " << recalibrationArr1[binIter-1] << endl;
447 cout<<
"rf_integral_FHCAL = "<<rf_integral_FHCAL<<
"\n\n";
450 Double_t recalibrationArr2[nSlicesx];
451 Double_t rf_integral_FEMC = 0;
452 Double_t weight_FEMC = te_by_ge_ge_EtaCut_CircularCut_FEMC->GetMean(2);
457 for(
int binIter = 1; binIter <= nSlicesx; binIter++){
458 recalibrationArr2[binIter-1] = mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->GetBinContent(binIter);
459 rf_integral_FEMC += recalibrationArr2[binIter-1];
462 cout<<
"rf_integral_FEMC += "<<recalibrationArr2[binIter-1]<<
"\n";
465 cout <<
"Recalibration factor for slice " << binIter <<
" of FEMC is: " << recalibrationArr2[binIter-1] << endl;
469 cout<<
"rf_integral_FEMC = "<<rf_integral_FEMC<<
"\n\n";
472 for(
int i=0; i<T1->GetEntries(); i++){
477 Double_t geta1 = evaltree1->
get_geta();
478 Double_t gphi = evaltree1->
get_gphi();
480 Double_t ge = evaltree1->
get_ge();
481 Double_t te_aggregate_CircularCut = 0;
482 Double_t te_aggregate_FHCAL_CircularCut = 0;
483 Double_t te_aggregate_CircularCut_normalised = 0;
485 int recalibration_factor = 0;
488 if(ge > lowEnergyBin){
489 Double_t eRangeBin = (maxEnergyBin - lowEnergyBin)/highThresholdBins;
490 recalibration_factor = (lowThresholdBins - 1) + ceil(ge/eRangeBin)- 1;
494 recalibration_factor = ceil((ge/lowEnergyBin)*(Double_t)lowThresholdBins)- 1;
497 if(geta1>=eta_min && geta1<=eta_max){
507 Double_t dphi = tphi - gphi;
508 Double_t dtheta = ttheta - gtheta;
509 Double_t te = twr1->
get_te();
514 std::cout<<
"pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2): "<<pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2)<<
"\n";
517 if (pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2)<=1){
518 te_aggregate_CircularCut += te;
519 te_aggregate_FHCAL_CircularCut += te;
520 te_aggregate_CircularCut_normalised += te*weight_FHCAL/recalibrationArr1[recalibration_factor];
533 Double_t dphi = tphi - gphi;
534 Double_t dtheta = ttheta - gtheta;
535 Double_t te = twr2->
get_te();
537 if(MIP_theta_parametrisation == 1){
538 EMC_cut = mip_pmzn_energy_cut_ftheta->Eval(gtheta);
541 if(te > energyCut + EMC_cut){
544 std::cout<<
"pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2): "<<pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2)<<
"\n";
547 if (pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2)<=1){
548 te_aggregate_CircularCut += te;
549 te_aggregate_CircularCut_normalised += te*weight_FEMC/recalibrationArr2[recalibration_factor];
556 if(te_aggregate_CircularCut > energyCutAggregate){
557 mean_te_by_ge_ge_EtaCut_CircularCut->Fill(ge, te_aggregate_CircularCut_normalised/ge);
559 cout<<
"(ge, te_aggregate_CircularCut_normalised/ge): ("<<ge<<
", "<<te_aggregate_CircularCut_normalised/ge<<
")\n";
566 Double_t recalibrationArr[nSlicesx];
571 for(
int binIter = 1; binIter <= nSlicesx; binIter++){
572 recalibrationArr[binIter-1] = mean_te_by_ge_ge_EtaCut_CircularCut->GetBinContent(binIter);
573 cout <<
"Recalibration factor for slice " << binIter <<
" of is: " << recalibrationArr[binIter-1] << endl;
577 for(
int i=0; i<T1->GetEntries(); i++){
582 Double_t geta1 = evaltree1->
get_geta();
583 Double_t gphi = evaltree1->
get_gphi();
585 Double_t ge = evaltree1->
get_ge();
586 Double_t te_aggregate_CircularCut = 0.0;
587 Double_t te_aggregate_FHCAL_CircularCut = 0.0;
588 Double_t te_aggregate_CircularCut_normalised = 0.0;
590 int recalibration_factor = 0;
593 if(ge > lowEnergyBin){
594 Double_t eRangeBin = (maxEnergyBin - lowEnergyBin)/highThresholdBins;
595 recalibration_factor = (lowThresholdBins - 1) + ceil(ge/eRangeBin)- 1;
599 recalibration_factor = ceil((ge/lowEnergyBin)*(Double_t)lowThresholdBins)- 1;
603 if(geta1>=eta_min && geta1<=eta_max){
613 Double_t dphi = tphi - gphi;
614 Double_t dtheta = ttheta - gtheta;
615 Double_t te = twr1->
get_te();
620 std::cout<<
"pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2): "<<pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2)<<
"\n";
623 if (pow(dphi/y_radius_FHCAL,2)+pow(dtheta/x_radius_FHCAL,2)<=1){
624 te_aggregate_CircularCut += te;
625 te_aggregate_FHCAL_CircularCut += te;
626 te_aggregate_CircularCut_normalised += te*weight_FHCAL/recalibrationArr1[recalibration_factor];
639 Double_t dphi = tphi - gphi;
640 Double_t dtheta = ttheta - gtheta;
641 Double_t te = twr2->
get_te();
643 if(MIP_theta_parametrisation == 1){
644 EMC_cut = mip_pmzn_energy_cut_ftheta->Eval(gtheta);
647 if(te > energyCut + EMC_cut){
650 std::cout<<
"pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2): "<<pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2)<<
"\n";
653 if (pow(dphi/y_radius_FEMC,2)+pow(dtheta/x_radius_FEMC,2)<=1){
654 te_aggregate_CircularCut += te;
655 te_aggregate_CircularCut_normalised += te*weight_FEMC/recalibrationArr2[recalibration_factor];
662 if(te_aggregate_CircularCut > energyCutAggregate){
663 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->Fill(ge, ((te_aggregate_CircularCut_normalised/recalibrationArr[recalibration_factor])-ge)/ge);
664 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp->Fill(ge, ((te_aggregate_CircularCut_normalised/recalibrationArr[recalibration_factor])-ge)/ge);
667 cout<<
"(ge, ((te_aggregate_CircularCut_normalised/recalibration_factor)-ge)/ge: ("<<ge<<
", "<<((te_aggregate_CircularCut_normalised/recalibrationArr[recalibration_factor])-ge)/ge<<
")\n";
675 TF1 *fit =
new TF1(
"fit",
"gaus");
676 TF1 *fit1 =
new TF1(
"fit1",
"gaus",fit_min,fit_max);
677 TF1 *fExp =
new TF1(
"fExp",
"0.1 + 0.5/sqrt(x)",0,30);
678 TF1 *fTrue =
new TF1(
"fTrue",
"[0] + [1]/sqrt(x)",0,30);
681 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp->FitSlicesY(0, 1, -1, 0,
"QN");
682 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");
683 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");
684 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");
688 TH1D* slices[nSlicesx];
691 for(
int sno = 0; sno < nSlicesx; sno++){
693 TString sname =
"slice " + arr[sno];
694 slices[sno] = te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp->ProjectionY(sname, plusOne, plusOne);
698 cout<<
"\nHistogram Formatting\n\n";
701 te_minus_ge_by_ge_ge_EtaCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
702 te_minus_ge_by_ge_ge_EtaCut->GetXaxis()->SetLabelSize(0.05);
703 te_minus_ge_by_ge_ge_EtaCut->GetXaxis()->SetTitleSize(0.05);
704 te_minus_ge_by_ge_ge_EtaCut->GetYaxis()->SetTitle(
"(te_{agg}-ge)/ge");
705 te_minus_ge_by_ge_ge_EtaCut->GetYaxis()->SetLabelSize(0.05);
706 te_minus_ge_by_ge_ge_EtaCut->GetYaxis()->SetTitleSize(0.05);
708 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
709 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetLabelSize(0.05);
710 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitleSize(0.05);
711 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitle(
"(te_{agg}-ge)/ge");
712 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetLabelSize(0.05);
713 te_minus_ge_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitleSize(0.05);
715 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
716 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetXaxis()->SetLabelSize(0.05);
717 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetXaxis()->SetTitleSize(0.05);
718 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetYaxis()->SetTitle(
"(te_{agg}-ge)/ge");
719 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetYaxis()->SetLabelSize(0.05);
720 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->GetYaxis()->SetTitleSize(0.05);
722 te_by_ge_ge_EtaCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
723 te_by_ge_ge_EtaCut->GetXaxis()->SetLabelSize(0.05);
724 te_by_ge_ge_EtaCut->GetXaxis()->SetTitleSize(0.05);
725 te_by_ge_ge_EtaCut->GetYaxis()->SetTitle(
"te_{agg}/ge");
726 te_by_ge_ge_EtaCut->GetYaxis()->SetLabelSize(0.05);
727 te_by_ge_ge_EtaCut->GetYaxis()->SetTitleSize(0.05);
729 te_aggregate_EtaCut_CircularCut_FEMC->GetXaxis()->SetTitle(
"te_{agg} (GeV)");
730 te_aggregate_EtaCut_CircularCut_FEMC->GetXaxis()->SetLabelSize(0.05);
731 te_aggregate_EtaCut_CircularCut_FEMC->GetXaxis()->SetTitleSize(0.05);
732 te_aggregate_EtaCut_CircularCut_FEMC->GetYaxis()->SetTitle(
"Counts");
733 te_aggregate_EtaCut_CircularCut_FEMC->GetYaxis()->SetLabelSize(0.05);
734 te_aggregate_EtaCut_CircularCut_FEMC->GetYaxis()->SetTitleSize(0.05);
736 te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
737 te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetLabelSize(0.05);
738 te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitleSize(0.05);
739 te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitle(
"te_{agg}/ge");
740 te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetLabelSize(0.05);
741 te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitleSize(0.05);
743 mean_te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
744 mean_te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetLabelSize(0.05);
745 mean_te_by_ge_ge_EtaCut_CircularCut->GetXaxis()->SetTitleSize(0.05);
746 mean_te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitle(
"Mean of te_{agg}/ge");
747 mean_te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetLabelSize(0.05);
748 mean_te_by_ge_ge_EtaCut_CircularCut->GetYaxis()->SetTitleSize(0.05);
750 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
751 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetXaxis()->SetLabelSize(0.05);
752 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetXaxis()->SetTitleSize(0.05);
753 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetYaxis()->SetTitle(
"Mean of te_{agg}/ge (FHCAL)");
754 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetYaxis()->SetLabelSize(0.05);
755 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->GetYaxis()->SetTitleSize(0.05);
757 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
758 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->GetXaxis()->SetLabelSize(0.05);
759 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->GetXaxis()->SetTitleSize(0.05);
760 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->GetYaxis()->SetTitle(
"Mean of te_{agg}/ge (FEMC)");
761 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->GetYaxis()->SetLabelSize(0.05);
762 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->GetYaxis()->SetTitleSize(0.05);
764 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
765 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetXaxis()->SetLabelSize(0.05);
766 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetXaxis()->SetTitleSize(0.05);
767 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetYaxis()->SetTitle(
"#sigma_{e_{agg}}");
768 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetYaxis()->SetLabelSize(0.05);
769 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->GetYaxis()->SetTitleSize(0.05);
772 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
773 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetXaxis()->SetLabelSize(0.05);
774 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetXaxis()->SetTitleSize(0.05);
775 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetYaxis()->SetTitle(
"Reduced_#chi^{2}_{e_{agg}}");
776 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetYaxis()->SetLabelSize(0.05);
777 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->GetYaxis()->SetTitleSize(0.04);
780 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetXaxis()->SetTitle(
"Generated Energy (GeV)");
781 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetXaxis()->SetLabelSize(0.05);
782 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetXaxis()->SetTitleSize(0.05);
783 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetYaxis()->SetTitle(
"Mean_{e_{agg}}");
784 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetYaxis()->SetLabelSize(0.05);
785 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->GetYaxis()->SetTitleSize(0.05);
788 for(
int sno = 0; sno < nSlicesx; sno++){
789 slices[sno]->GetXaxis()->SetTitle(
"#Delta e^{agg}/ ge");
790 slices[sno]->GetXaxis()->SetLabelSize(0.05);
791 slices[sno]->GetXaxis()->SetTitleSize(0.05);
792 slices[sno]->GetYaxis()->SetTitle(
"Counts");
793 slices[sno]->GetYaxis()->SetLabelSize(0.05);
794 slices[sno]->GetYaxis()->SetTitleSize(0.05);
798 std::cout<<
"\nWrite Histograms to File\n";
801 TFile *f =
new TFile(
"energy_verification_EtaCut_CircularCut_" + detector +
".root",
"RECREATE");
803 f->GetList()->Add(te_by_ge_ge_EtaCut);
804 f->GetList()->Add(te_by_ge_ge_EtaCut_CircularCut);
805 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut);
806 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut);
807 f->GetList()->Add(mean_te_by_ge_ge_EtaCut_CircularCut);
808 f->GetList()->Add(mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL);
809 f->GetList()->Add(mean_te_by_ge_ge_EtaCut_CircularCut_FEMC);
810 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated);
811 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2);
812 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1);
813 f->GetList()->Add(te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2);
814 f->GetList()->Add(te_aggregate_EtaCut_CircularCut_FEMC);
816 for(
int sno = 0; sno < nSlicesx; sno++){
817 f->GetList()->Add(slices[sno]);
822 gStyle -> SetOptFit(112);
847 std::cout<<
"\nSaving Histograms as .png\n";
852 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->SetAxisRange(mean_min,mean_max,
"Y");
853 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_1->Draw();
860 c->Print(detector +
"_meanE_ge_EtaCut_CircularCut.png");
862 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->SetAxisRange(chi2_min,chi2_max,
"Y");
863 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_chi2->Draw();
870 c->Print(detector +
"_chi2E_ge_EtaCut_CircularCut.png");
873 gStyle -> SetOptFit(0);
881 fExp->SetLineColor(4);
882 fTrue->SetLineColor(2);
884 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetMarkerStyle(kFullCircle);
885 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetMarkerColor(46);
886 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetMarkerSize(0.75);
887 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->SetAxisRange(sigma_min,sigma_max,
"Y");
889 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->Fit(
"fTrue",
"M+");
890 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated_temp_2->Draw(
"same");
896 TLegend* legend =
new TLegend(1.75,1.75);
897 legend->SetHeader(
"Legend",
"C");
900 legend->AddEntry(fTrue,
"p_{0} + p_{1}/#sqrt{ge} (Fitted)",
"l");
901 legend->AddEntry((
TObject*)0,
"",
"");
902 legend->AddEntry(fExp,
"0.1 + 0.5/#sqrt{ge} (Requirement)",
"l");
903 legend->SetTextSize(0.033);
906 std::cout<<
"reduced_chi2 of fit: "<<fTrue->GetChisquare()/fTrue->GetNDF()<<
"\n";
908 c->Print(detector +
"_sigmaE_ge_EtaCut_CircularCut.png");
912 gStyle -> SetOptFit(112);
914 for(
int sno = 0; sno < nSlicesx; sno++){
915 TString plusOne = (TString)(sno + 1);
916 TString nameF = detector +
"_sigmaE_slice" + arr[sno] +
"_EtaCut_CircularCut.png";
917 slices[sno] -> Fit(
"fit",
"M+");
918 slices[sno] ->
Draw(
"hist same");
922 te_aggregate_EtaCut_CircularCut_FEMC->Draw();
923 c->Print(
"te_aggregate_EtaCut_CircularCut_FEMC.png");
928 te_by_ge_ge_EtaCut->Draw(
"colz");
929 c->Print(detector +
"_te_by_ge_ge_EtaCut.png");
930 te_by_ge_ge_EtaCut_CircularCut->Draw(
"colz");
931 c->Print(detector +
"_te_by_ge_ge_EtaCut_CircularCut.png");
933 te_minus_ge_by_ge_ge_EtaCut->Draw(
"colz");
934 c->Print(detector +
"_te_minus_ge_by_ge_ge_EtaCut.png");
935 te_minus_ge_by_ge_ge_EtaCut_CircularCut->Draw(
"colz");
936 c->Print(detector +
"_te_minus_ge_by_ge_ge_EtaCut_CircularCut.png");
937 te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated->Draw(
"colz");
938 c->Print(detector +
"_te_minus_ge_by_ge_ge_EtaCut_CircularCut_Recalibrated.png");
942 mean_te_by_ge_ge_EtaCut_CircularCut->Draw();
943 c->Print(detector +
"_mean_te_by_ge_ge_EtaCut_CircularCut.png");
945 mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL->Draw();
946 c->Print(detector +
"_mean_te_by_ge_ge_EtaCut_CircularCut_FHCAL.png");
948 mean_te_by_ge_ge_EtaCut_CircularCut_FEMC->Draw();
949 c->Print(detector +
"_mean_te_by_ge_ge_EtaCut_CircularCut_FEMC.png");
956 std::cout <<
"The total te is: " << total_te << endl;
957 std::cout <<
"The total te_CircularCut is: " << total_te_CircularCut << endl;
958 std::cout <<
"The total ge is: " << total_ge << endl;
959 std::cout<<
"\n\nDone\n----------------------------------------------------------------------\n\n";