136 std::vector<double> npTbinning;
137 double original_ptmin = 0, original_ptmax = 0;
139 original_ptmin = 40, original_ptmax = 600;
140 npTbinning =
makeLogBins(560,original_ptmin,original_ptmax);
142 original_ptmin = 200, original_ptmax = 3000;
143 npTbinning =
makeLogBins(2800,original_ptmin,original_ptmax);
145 int npTbins = -1+npTbinning.size();
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";
153 std::cout <<
"\n > Input root file opened \n" << std::endl;
155 std::vector<std::string> UFO_JMR_uncertainties_histo_names = {};
156 std::vector<std::string> uncertainty_names = {};
157 std::vector<std::string> uncertainty_treatment = {};
159 if (uncmodel ==
"SimpleJMR"){
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"};
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%"};
165 uncertainty_treatment = {
"eLOGmOeAbsEta",
"eLOGmOeAbsEta",
"PtAbsMass",
"eLOGmOeAbsEta",
"eLOGmOeAbsEta",
"PtAbsMass"};
167 }
else if (uncmodel ==
"FullJMR"){
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"};
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"};
175 uncertainty_treatment = {
"eLOGmOeAbsEta",
"eLOGmOeAbsEta",
"PtAbsMass",
"eLOGmOeAbsEta",
"eLOGmOeAbsEta",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass",
"PtAbsMass"};
179 std::cout <<
" > Uncertainty model: " << uncmodel <<
"\n" << std::endl;
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";
186 std::cout <<
" > Input uncertainty names and histograms provided \n" << std::endl;
189 std::vector<TH3F*> JMR_uncertainties_hists_3d;
190 int histocount3d = 0;
191 std::vector<TH2D*> JMR_uncertainties_hists_2d;
192 int histocount2d = 0;
195 for (
int i=0;
i < std::ssize(uncertainty_names);
i++){
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){
201 if (unctreatment ==
"eLOGmOeAbsEta"){
202 JMR_uncertainties_hists_3d.push_back((TH3F*)f_JMR_uncertainties_histograms->Get(
histoname));
203 iprime[
i] = histocount3d;
205 }
else if (unctreatment ==
"PtAbsMass"){
206 JMR_uncertainties_hists_2d.push_back((TH2D*)f_JMR_uncertainties_histograms->Get(
histoname));
207 iprime[
i] = histocount2d;
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;
214 std::cout <<
"Can't read input histo." << UFO_JMR_uncertainties_histo_names[
i] <<
"\n";
220 std::cout <<
"\n > Input 2D and 3D histograms are read now \n" << std::endl;
223 std::vector<std::unique_ptr<TH1D>> JMR_uncertainties_1Dhists;
225 for (
int i=0;
i < std::ssize(uncertainty_names);
i++){
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();
230 TString unctreatment = uncertainty_treatment[
i].c_str();
231 float uncertainty_value = 0;
233 if (unctreatment ==
"eLOGmOeAbsEta"){
235 auto*
hist1 = JMR_uncertainties_hists_3d.at(iprime[
i]);
238 double j = hist0->GetBinCenter(
bin);
241 double cosh_eta = std::cosh(
eta_bin);
242 double energy_bin = sqrt((mass_bin*mass_bin) + (j*j)*
pow(cosh_eta,2));
245 double x = energy_bin,
y = TMath::Log(mass_bin/energy_bin),
z =
eta_bin;
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);
253 energy_bin = sqrt((j*j) + (mass_bin*mass_bin)*
pow(cosh_eta,2));
256 x = energy_bin,
y = TMath::Log(j/energy_bin),
z =
eta_bin;
258 bin_energy =
hist1->GetXaxis()->FindBin(
x);
259 bin_mass =
hist1->GetYaxis()->FindBin(
y);
260 bin_eta =
hist1->GetZaxis()->FindBin(
z);
267 uncertainty_value = fabs(
hist1->GetBinContent(bin_energy, bin_mass, bin_eta) );
271 hist0->SetBinContent(
bin, uncertainty_value);
275 }
else if (unctreatment ==
"PtAbsMass"){
277 auto*
hist2 = JMR_uncertainties_hists_2d.at(iprime[
i]);
281 double j = hist0->GetBinCenter(
bin);
284 double x = j,
y = mass_bin;
286 Int_t bin_pt =
hist2->GetXaxis()->FindBin(
x);
287 Int_t bin_mass =
hist2->GetYaxis()->FindBin(
y);
293 bin_pt =
hist2->GetXaxis()->FindBin(
x);
294 bin_mass =
hist2->GetYaxis()->FindBin(
y);
301 uncertainty_value = fabs(
hist2->GetBinContent(bin_pt, bin_mass) );
305 hist0->SetBinContent(
bin, uncertainty_value);
313 std::cout <<
" > Individual uncertainties evaluated \n" << std::endl;
317 std::unique_ptr<TH1D> JMR_All_uncertainties_1Dhist = std::make_unique<TH1D>(
"total_uncertainty",
"total_uncertainty", npTbins, &npTbinning[0]);
319 for (
int j=1; j<=JMR_All_uncertainties_1Dhist->GetXaxis()->GetNbins(); j++){
321 double total_uncertainty = 0;
323 for (
int i=0;
i < std::ssize(uncertainty_names);
i++){
325 double uncval = JMR_uncertainties_1Dhists.at(
i)->GetBinContent(j);
327 total_uncertainty += (uncval) * (uncval);
332 total_uncertainty = sqrt(total_uncertainty);
333 JMR_All_uncertainties_1Dhist->SetBinContent(j, total_uncertainty);
340 std::unique_ptr<TH1D> JMR_old_uncertainties_1Dhist = std::make_unique<TH1D>(
"Old_uncertainty",
"Old_uncertainty", npTbins, &npTbinning[0]);
342 for (
int j=1; j<=JMR_old_uncertainties_1Dhist->GetXaxis()->GetNbins(); j++){
343 JMR_old_uncertainties_1Dhist->SetBinContent(j, 0.2);
346 std::cout <<
" > Total uncertainty calculated \n" << std::endl;
350 gStyle->SetOptStat(0);
352 gROOT->SetStyle(
"ATLAS");
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);
360 std::unique_ptr<TCanvas>
canvas = std::make_unique<TCanvas>(
"c1",
"c1", 1200, 800);
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);
366 DrawHistogram->SetMinimum(0);
367 DrawHistogram->SetMaximum(1.0);
368 DrawHistogram->SetLineWidth(0);
373 DrawHistogram->GetXaxis()->SetTitle(
"p_{T}^{jet} [GeV]");
374 DrawHistogram->GetXaxis()->SetLabelOffset(0.0125);
375 DrawHistogram->GetXaxis()->SetNdivisions(510);
376 DrawHistogram->GetXaxis()->SetMoreLogLabels(
true);
378 DrawHistogram->GetXaxis()->SetTitle(
"m^{jet} [GeV]");
379 DrawHistogram->GetXaxis()->SetNdivisions(505);
380 DrawHistogram->GetXaxis()->SetMoreLogLabels(
false);
382 DrawHistogram->GetXaxis()->SetTitleOffset(1.50);
384 DrawHistogram->GetYaxis()->SetTitle(
"Fractional JMR uncertainty");
385 DrawHistogram->GetYaxis()->SetLabelOffset(0.0145);
386 DrawHistogram->GetYaxis()->SetTitleOffset(1.40);
389 DrawHistogram->Draw();
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");
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");
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;
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");
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 =
"";
445 l.DrawLatex(0.67,0.89,
"ATLAS");
446 p.DrawLatex(0.67+0.115,0.89,ATLAS_LABELLING);
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");
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");
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);
467 std::string jet_info_2_string =
"";
468 if (kind_of_mass ==
"UFO"){
470 jet_info_2_string =
"|#eta^{jet}| = "+TString(Form(
"%f",
eta_bin))+
", m_{UFO}^{jet} = "+TString(Form(
"%i",mass_bin))+
" GeV";
473 jet_info_2_string =
"|#eta^{jet}| = "+TString(Form(
"%f",
eta_bin))+
", p_{T}^{jet} = "+TString(Form(
"%i",mass_bin))+
" GeV";
477 jet_info_2_text.DrawLatex(0.18,0.89-2*0.06,jet_info_2_string.c_str());
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");
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");
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);
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");
511 legend1->Draw(
"same");
513 DrawHistogram->Draw(
"axis same");
515 std::cout <<
" > Plots are done now \n" << std::endl;
517 std::string outputdir =
"./source/JetUncertainties/util/output/";
522 if (std::filesystem::create_directory(outputdir)){
523 std::cout <<
"Output directory created successfully: " << outputdir << std::endl;
525 std::cerr <<
"Failed to create directory: " << outputdir << std::endl;
529 std::cout <<
"Output directory already exists: " << outputdir << std::endl;
531 }
catch (
const std::filesystem::filesystem_error&
e){
532 std::cerr <<
"Filesystem error: " <<
e.what() << std::endl;
536 std::string string_write;
537 std::string string_write_pdf;
538 std::string string_write_png;
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";
561 canvas->Print(string_write_pdf.c_str());