133 {
134
135
136 std::vector<double> npTbinning;
137 double original_ptmin = 0, original_ptmax = 0;
138 if (pTbin){
139 original_ptmin = 40, original_ptmax = 600;
140 npTbinning =
makeLogBins(560,original_ptmin,original_ptmax);
141 }else{
142 original_ptmin = 200, original_ptmax = 3000;
143 npTbinning =
makeLogBins(2800,original_ptmin,original_ptmax);
144 }
145 int npTbins = -1+npTbinning.size();
146
147 std::unique_ptr<TFile> f_JMR_uncertainties_histograms = std::make_unique<TFile>(histofile.c_str(), "READ");
148 if (f_JMR_uncertainties_histograms == 0){
149 std::cout << "Can't find input file.\n";
150 return;
151 }
152
153 std::cout << "\n > Input root file opened \n" << std::endl;
154
155 std::vector<std::string> UFO_JMR_uncertainties_histo_names = {};
156 std::vector<std::string> uncertainty_names = {};
157 std::vector<std::string> uncertainty_treatment = {};
158
159 if (uncmodel == "SimpleJMR"){
160
161 UFO_JMR_uncertainties_histo_names = {"JMRUnc_mc20vsmc21_"+kind_of_mc+"_PreRec", "JMRUnc_mc20vsmc23_"+kind_of_mc+"_PreRec", "JMRUnc_mc20FullSimvsmc20AF3_"+kind_of_mc+"_PreRec", "JMRUnc_Noise_PreRec", "JMRUnc_mc20UFOvsmc16UFO_PreRec", "JMR_FlatSmearing20_AntiKt10UFOCSSKSoftDropBeta100Zcut10"};
162
163 uncertainty_names = {"MC20 vs MC21 ("+kind_of_mc+")", "MC20 vs MC23 ("+kind_of_mc+")", "FullSim vs AF3 ("+kind_of_mc+")", "Noise", "MC20 UFO vs MC16 UFO", "Flat smearing 20%"};
164
165 uncertainty_treatment = {"eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass", "eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass"};
166
167 }else if (uncmodel == "FullJMR"){
168
169
170
171 UFO_JMR_uncertainties_histo_names = {"JMRUnc_mc20vsmc21_"+kind_of_mc+"_PreRec", "JMRUnc_mc20vsmc23_"+kind_of_mc+"_PreRec", "JMRUnc_mc20FullSimvsmc20AF3_"+kind_of_mc+"_PreRec", "JMRUnc_Noise_PreRec", "JMRUnc_mc20UFOvsmc16UFO_PreRec", "JMR_UncertaintiesOutsideCalibratedRegion_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_Smoothing_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_Nom_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_Stat_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_Det_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_MCisr_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_MCfsr_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_MCps_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_MCcr_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_MCrecoil_AntiKt10UFOCSSKSoftDropBeta100Zcut10", "JMR_FF_MCpthard_AntiKt10UFOCSSKSoftDropBeta100Zcut10"};
172
173 uncertainty_names = {"MC20 vs MC21 ("+kind_of_mc+")", "MC20 vs MC23 ("+kind_of_mc+")", "FullSim vs AF3 ("+kind_of_mc+")", "Noise", "MC20 UFO vs MC16 UFO", "Flat smearing 20% (outside)", "FF smoothing", "FF nom.", "FF stat.", "FF Detector", "FF ISR", "FF FSR", "FF PS", "FF Color recon.", "FF recoil", "FF pthard"};
174
175 uncertainty_treatment = {"eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass", "eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass"};
176
177 }
178
179 std::cout << " > Uncertainty model: " << uncmodel << "\n" << std::endl;
180
181 if (uncertainty_names.size() != UFO_JMR_uncertainties_histo_names.size()){
182 std::cout << "List of syst histograms and syst names of different sizes.\n";
183 return;
184 }
185
186 std::cout << " > Input uncertainty names and histograms provided \n" << std::endl;
187
188
189 std::vector<TH3F*> JMR_uncertainties_hists_3d;
190 int histocount3d = 0;
191 std::vector<TH2D*> JMR_uncertainties_hists_2d;
192 int histocount2d = 0;
193 int iprime[50] = {};
194
195 for (
int i=0;
i < std::ssize(uncertainty_names);
i++){
196
197 TString
histoname = UFO_JMR_uncertainties_histo_names[
i].c_str();
198 TString unctreatment = uncertainty_treatment[
i].c_str();
199 if (f_JMR_uncertainties_histograms->Get(histoname) != 0){
200
201 if (unctreatment == "eLOGmOeAbsEta"){
202 JMR_uncertainties_hists_3d.push_back((TH3F*)f_JMR_uncertainties_histograms->Get(histoname));
203 iprime[
i] = histocount3d;
204 histocount3d += 1;
205 }else if (unctreatment == "PtAbsMass"){
206 JMR_uncertainties_hists_2d.push_back((TH2D*)f_JMR_uncertainties_histograms->Get(histoname));
207 iprime[
i] = histocount2d;
208 histocount2d += 1;
209 }
210 std::cout <<
" >> NP read '" << UFO_JMR_uncertainties_histo_names[
i] <<
"' with iprime["<<
i<<
"] = " <<iprime[
i]<< std::endl;
211 std::cout << " >>> Uncertainty treatment = " << unctreatment << std::endl;
212
213 }else{
214 std::cout <<
"Can't read input histo." << UFO_JMR_uncertainties_histo_names[
i] <<
"\n";
215 return;
216 }
217
218 }
219
220 std::cout << "\n > Input 2D and 3D histograms are read now \n" << std::endl;
221
222
223 std::vector<std::unique_ptr<TH1D>> JMR_uncertainties_1Dhists;
224
225 for (
int i=0;
i < std::ssize(uncertainty_names);
i++){
226
227 JMR_uncertainties_1Dhists.push_back(std::make_unique<TH1D>(("UFO_"+std::to_string(i)).c_str(),("UFO_"+std::to_string(i)).c_str(), npTbins, &npTbinning[0]));
228 auto* hist0 = JMR_uncertainties_1Dhists.at(i).get();
229
230 TString unctreatment = uncertainty_treatment[
i].c_str();
231 float uncertainty_value = 0;
232
233 if (unctreatment == "eLOGmOeAbsEta"){
234
235 auto*
hist1 = JMR_uncertainties_hists_3d.at(iprime[i]);
236
238 double j = hist0->GetBinCenter(
bin);
239
240
241 double cosh_eta = std::cosh(eta_bin);
242 double energy_bin = sqrt((mass_bin*mass_bin) + (j*j)*
pow(cosh_eta,2));
243
244
245 double x = energy_bin,
y = TMath::Log(mass_bin/energy_bin),
z =
eta_bin;
246
247 Int_t bin_energy =
hist1->GetXaxis()->FindBin(
x);
248 Int_t bin_mass =
hist1->GetYaxis()->FindBin(
y);
249 Int_t bin_eta =
hist1->GetZaxis()->FindBin(
z);
250
251
252 if (pTbin){
253 energy_bin = sqrt((j*j) + (mass_bin*mass_bin)*
pow(cosh_eta,2));
254
255
256 x = energy_bin,
y = TMath::Log(j/energy_bin),
z =
eta_bin;
257
258 bin_energy =
hist1->GetXaxis()->FindBin(
x);
259 bin_mass =
hist1->GetYaxis()->FindBin(
y);
260 bin_eta =
hist1->GetZaxis()->FindBin(
z);
261 }
262
263
264 if (dointerpol){
266 }else{
267 uncertainty_value = fabs(
hist1->GetBinContent(bin_energy, bin_mass, bin_eta) );
268 }
269
270
271 hist0->SetBinContent(
bin, uncertainty_value);
272
273 }
274
275 }else if (unctreatment == "PtAbsMass"){
276
277 auto*
hist2 = JMR_uncertainties_hists_2d.at(iprime[i]);
278
280
281 double j = hist0->GetBinCenter(
bin);
282
283
284 double x = j,
y = mass_bin;
285
286 Int_t bin_pt =
hist2->GetXaxis()->FindBin(
x);
287 Int_t bin_mass =
hist2->GetYaxis()->FindBin(
y);
288
289
290 if (pTbin){
292
293 bin_pt =
hist2->GetXaxis()->FindBin(
x);
294 bin_mass =
hist2->GetYaxis()->FindBin(
y);
295 }
296
297
298 if (dointerpol){
300 }else{
301 uncertainty_value = fabs(
hist2->GetBinContent(bin_pt, bin_mass) );
302 }
303
304
305 hist0->SetBinContent(
bin, uncertainty_value);
306
307 }
308
309 }
310
311 }
312
313 std::cout << " > Individual uncertainties evaluated \n" << std::endl;
314
316
317 std::unique_ptr<TH1D> JMR_All_uncertainties_1Dhist = std::make_unique<TH1D>("total_uncertainty", "total_uncertainty", npTbins, &npTbinning[0]);
318
319 for (int j=1; j<=JMR_All_uncertainties_1Dhist->GetXaxis()->GetNbins(); j++){
320
321 double total_uncertainty = 0;
322
323 for (
int i=0;
i < std::ssize(uncertainty_names);
i++){
324
325 double uncval = JMR_uncertainties_1Dhists.at(i)->GetBinContent(j);
326
327 total_uncertainty += (uncval) * (uncval);
328
329
330 }
331
332 total_uncertainty = sqrt(total_uncertainty);
333 JMR_All_uncertainties_1Dhist->SetBinContent(j, total_uncertainty);
334
335
336 }
337
338
339
340 std::unique_ptr<TH1D> JMR_old_uncertainties_1Dhist = std::make_unique<TH1D>("Old_uncertainty","Old_uncertainty", npTbins, &npTbinning[0]);
341
342 for (int j=1; j<=JMR_old_uncertainties_1Dhist->GetXaxis()->GetNbins(); j++){
343 JMR_old_uncertainties_1Dhist->SetBinContent(j, 0.2);
344 }
345
346 std::cout << " > Total uncertainty calculated \n" << std::endl;
347
348
349
350 gStyle->SetOptStat(0);
351 gROOT->Reset();
352 gROOT->SetStyle("ATLAS");
353 gROOT->ForceStyle();
354 gStyle->SetPadLeftMargin(0.15);
355 gStyle->SetPadRightMargin(0.08);
356 gStyle->SetEndErrorSize(4);
357 gStyle->SetPaintTextFormat("4.3f");
358 gStyle->SetPalette(8,0, 0.3);
359
360 std::unique_ptr<TCanvas>
canvas = std::make_unique<TCanvas>(
"c1",
"c1", 1200, 800);
361
362
363 int nbins = (original_ptmax - original_ptmin)/(1.);
364 std::unique_ptr<TH1D> DrawHistogram = std::make_unique<TH1D>("draw_hist","draw_hist_title",nbins, original_ptmin, original_ptmax);
365
366 DrawHistogram->SetMinimum(0);
367 DrawHistogram->SetMaximum(1.0);
368 DrawHistogram->SetLineWidth(0);
369 if (!pTbin){
371 }
372
373 DrawHistogram->GetXaxis()->SetTitle("p_{T}^{jet} [GeV]");
374 DrawHistogram->GetXaxis()->SetLabelOffset(0.0125);
375 DrawHistogram->GetXaxis()->SetNdivisions(510);
376 DrawHistogram->GetXaxis()->SetMoreLogLabels(true);
377 if (pTbin){
378 DrawHistogram->GetXaxis()->SetTitle("m^{jet} [GeV]");
379 DrawHistogram->GetXaxis()->SetNdivisions(505);
380 DrawHistogram->GetXaxis()->SetMoreLogLabels(false);
381 }
382 DrawHistogram->GetXaxis()->SetTitleOffset(1.50);
383
384 DrawHistogram->GetYaxis()->SetTitle("Fractional JMR uncertainty");
385 DrawHistogram->GetYaxis()->SetLabelOffset(0.0145);
386 DrawHistogram->GetYaxis()->SetTitleOffset(1.40);
387
388
389 DrawHistogram->Draw();
390
392
393 JMR_old_uncertainties_1Dhist->SetLineColor(kTeal+5);
394 JMR_old_uncertainties_1Dhist->SetLineStyle(1);
395 JMR_old_uncertainties_1Dhist->SetLineWidth(2);
396 JMR_old_uncertainties_1Dhist->SetFillStyle(4000);
397 JMR_old_uncertainties_1Dhist->SetFillColor(kTeal-9);
398 JMR_old_uncertainties_1Dhist->Draw("hist same");
399
400 JMR_All_uncertainties_1Dhist->SetLineColor(kBlue+2);
401 JMR_All_uncertainties_1Dhist->SetLineStyle(1);
402 JMR_All_uncertainties_1Dhist->SetLineWidth(2);
403 JMR_All_uncertainties_1Dhist->SetFillStyle(4000);
404 JMR_All_uncertainties_1Dhist->SetFillColor(590);
405 JMR_All_uncertainties_1Dhist->Draw("hist same");
406
408 int indexp =
index + 2;
409 if (
index == 8) indexp = 14;
410 if (
index == 9) indexp = 30;
411 if (
index == 10) indexp = 43;
412 if (
index == 11) indexp = 46;
413
414 auto* hist0 = JMR_uncertainties_1Dhists.at(
index).get();
415 hist0->SetLineColor(indexp);
416 hist0->SetLineStyle(
index+2);
417 hist0->SetLineWidth(2);
418 hist0->Draw("hist same");
419 }
420
422
423
424
425 TString ATLAS_LABELLING="";
426 if (atlas_approved==0){
427 ATLAS_LABELLING = "Internal";
428 }else if (atlas_approved==1)
429 ATLAS_LABELLING = "Preliminary";
430 else if (atlas_approved==2){
431 ATLAS_LABELLING = "";
432 }
433
439
443
444
445 l.DrawLatex(0.67,0.89,
"ATLAS");
446 p.DrawLatex(0.67+0.115,0.89,ATLAS_LABELLING);
447
448
449
450 TLatex data_text;
451 data_text.SetNDC();
452 data_text.SetTextFont(42);
453 data_text.SetTextSize(0.04);
454 data_text.DrawLatex(0.18,0.89,"Data 2015-2017, #sqrt{s} = 13 TeV");
455
456 TLatex jet_info_1_text;
457 jet_info_1_text.SetNDC();
458 jet_info_1_text.SetTextFont(42);
459 jet_info_1_text.SetTextSize(0.04);
460 jet_info_1_text.DrawLatex(0.18,0.89-0.06,"Phase-I unc. for UFO R = 1.0 jets");
461
462 TLatex jet_info_2_text;
463 jet_info_2_text.SetNDC();
464 jet_info_2_text.SetTextFont(42);
465 jet_info_2_text.SetTextSize(0.04);
466
467 std::string jet_info_2_string = "";
468 if (kind_of_mass == "UFO"){
469
470 jet_info_2_string = "|#eta^{jet}| = "+TString(Form("%f",eta_bin))+", m_{UFO}^{jet} = "+TString(Form("%i",mass_bin))+" GeV";
471
472 if (pTbin){
473 jet_info_2_string = "|#eta^{jet}| = "+TString(Form("%f",eta_bin))+", p_{T}^{jet} = "+TString(Form("%i",mass_bin))+" GeV";
474 }
475
476 }
477 jet_info_2_text.DrawLatex(0.18,0.89-2*0.06,jet_info_2_string.c_str());
478
480
481 std::unique_ptr<TLegend> legend0_1 = std::make_unique<TLegend>(0.17,0.89-3.33*0.06,0.45,0.89-2.33*0.06);
482 legend0_1->SetTextSize(0.035);
483 legend0_1->SetTextFont(42);
484 legend0_1->SetBorderSize(0);
485 legend0_1->SetFillStyle(0);
486 legend0_1->AddEntry(JMR_All_uncertainties_1Dhist.get(), "Tot. uncert.","f");
487 legend0_1->Draw("same");
488
489 std::unique_ptr<TLegend> legend0_2 = std::make_unique<TLegend>(0.17,0.89-4.33*0.06,0.45,0.89-3.33*0.06);
490 legend0_2->SetTextSize(0.035);
491 legend0_2->SetTextFont(42);
492 legend0_2->SetBorderSize(0);
493 legend0_2->SetFillStyle(0);
494 legend0_2->AddEntry(JMR_old_uncertainties_1Dhist.get(), "Tot. uncert. (previous)","f");
495 legend0_2->Draw("same");
496
497
498 std::unique_ptr<TLegend> legend1;
499 if (uncmodel == "SimpleJMR"){
500 legend1 = std::make_unique<TLegend>(0.55,0.70,0.85,0.88);
501 }else if (uncmodel == "FullJMR"){
502 legend1 = std::make_unique<TLegend>(0.55,0.55,0.85,0.88);
503 }
504 legend1->SetTextSize(0.035);
505 legend1->SetTextFont(42);
506 legend1->SetBorderSize(0);
507 legend1->SetFillStyle(0);
509 legend1->AddEntry(JMR_uncertainties_1Dhists.at(
index).get(), uncertainty_names[
index].c_str(),
"l");
510 }
511 legend1->Draw("same");
512
513 DrawHistogram->Draw("axis same");
514
515 std::cout << " > Plots are done now \n" << std::endl;
516
517 std::string outputdir = "./source/JetUncertainties/util/output/";
518
519 try{
520
521 if (!std::filesystem::exists(outputdir)) {
522 if (std::filesystem::create_directory(outputdir)){
523 std::cout << "Output directory created successfully: " << outputdir << std::endl;
524 }else{
525 std::cerr << "Failed to create directory: " << outputdir << std::endl;
526 return;
527 }
528 } else {
529 std::cout << "Output directory already exists: " << outputdir << std::endl;
530 }
531 }catch (const std::filesystem::filesystem_error& e){
532 std::cerr <<
"Filesystem error: " <<
e.what() << std::endl;
533 return;
534 }
535
536 std::string string_write;
537 std::string string_write_pdf;
538 std::string string_write_png;
539
540 TString mBinStr = "mass"+std::to_string(mass_bin);
541 if (pTbin){
542 mBinStr = "pT"+std::to_string(mass_bin);
543 }
544
545 TString EtaBinStr = "Eta"+std::to_string(eta_bin);
546
547 if (atlas_approved == 0){
548 string_write = outputdir+"FractionalJMRuncertainty_"+kind_of_mc+"_"+kind_of_mass+"_"+uncmodel+"_"+EtaBinStr+"_"+mBinStr+ "GeV_ATLASint";
549 string_write_pdf = string_write+".pdf";
550 string_write_png = string_write+".png";
551 }else if (atlas_approved == 1){
552 string_write = outputdir+"FractionalJMRuncertainty_"+kind_of_mc+"_"+kind_of_mass+"_"+uncmodel+"_"+EtaBinStr+"_"+mBinStr+ "GeV_ATLASprel";
553 string_write_pdf = string_write+".pdf";
554 string_write_png = string_write+".png";
555 }else if (atlas_approved == 2){
556 string_write = outputdir+"FractionalJMRuncertainty_"+kind_of_mc+"_"+kind_of_mass+"_"+uncmodel+"_"+EtaBinStr+"_"+mBinStr+ "GeV_ATLAS";
557 string_write_pdf = string_write+".pdf";
558 string_write_png = string_write+".png";
559 }
560
561 canvas->Print(string_write_pdf.c_str());
562
563
564 return;
565
566}
double Interpolate2D(const TH2 *histo, double x, double y)
double Read3DHistogram(const TH3 *histo, double x, double y, double z)
std::vector< double > makeLogBins(int nbins, double min, double max)
constexpr int pow(int base, int exp) noexcept
l
Printing final latex table to .tex output file.