ATLAS Offline Software
Loading...
Searching...
No Matches
JMR_MakeUncertaintyPlots.cxx File Reference
#include <filesystem>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <cmath>
#include <memory>
#include <print>
#include <TROOT.h>
#include <TStyle.h>
#include <TFile.h>
#include <TTree.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TGraphErrors.h>
#include <TLorentzVector.h>
#include <TMath.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TH2F.h>
#include <TH3D.h>
#include <TH3F.h>
#include <TRandom3.h>
#include <TString.h>
#include <TLatex.h>
#include <TLine.h>
#include <TPave.h>
#include <TPad.h>
#include <TMarker.h>
#include <TSystem.h>
#include <Math/Interpolator.h>
#include <JetUncertainties/JetHelpers.h>

Go to the source code of this file.

Functions

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)
void MakeJMRPlot (int atlas_approved, const std::string &histofile, const std::string &uncmodel, const std::string &kind_of_mass, const std::string &kind_of_mc, bool dointerpol, int mass_bin, double eta_bin, bool pTbin=false)
int main (int argc, char *argv[])

Function Documentation

◆ Interpolate2D()

double Interpolate2D ( const TH2 * histo,
double x,
double y )

Definition at line 52 of file JMR_MakeUncertaintyPlots.cxx.

52 {
53
54 if (not histo){
55 std::cout << "Histogram pointer is null in FFJetSmearingTool::Interpolate2D" << std::endl;
56 return 0.;
57 }
58
59 double aux_x = x;
60 double aux_y = y;
61
63 // If the value is outside the histogram region, we take the closest value to that one
64
65 double xMax = histo->GetXaxis()->GetBinLowEdge(histo->GetNbinsX()+1);
66 double xMin = histo->GetXaxis()->GetBinLowEdge(1);
67 double yMax = histo->GetYaxis()->GetBinLowEdge(histo->GetNbinsY()+1);
68 double yMin = histo->GetYaxis()->GetBinLowEdge(1);
69
70 if (x >= xMax) aux_x = xMax-1e-6 ; //so it fits the up-most x-bin
71 if (x <= xMin) aux_x = xMin+1e-6 ; //so it fits the low-most x-bin
72 if (y >= yMax) aux_y = yMax-1e-6 ; //so it fits the up-most y-bin
73 if (y <= yMin) aux_y = yMin+1e-6 ; //so it fits the low-most y-bin
74
75 Int_t bin_x = histo->GetXaxis()->FindFixBin(aux_x);
76 Int_t bin_y = histo->GetYaxis()->FindFixBin(aux_y);
77 if (bin_x<1 || bin_x>histo->GetNbinsX() || bin_y<1 || bin_y>histo->GetNbinsY()){
78 std::cout << "The point is outside the histogram domain." << std::endl;
79 return 0.;
80 }
81
82 double interpolated_value = JetHelpers::Interpolate(histo, aux_x, aux_y);
83 return interpolated_value;
84
85}
#define y
#define x
double Interpolate(const TH1 *histo, const double x)

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 573 of file JMR_MakeUncertaintyPlots.cxx.

573 {
574
575 // Check if enough arguments are passed
576 if (argc < 5){
577 std::cerr << "Usage: " << argv[0] << " <input1: unc. model> <input2: kind_of_mc> <input3: dointerpol> <input4: eta_bin> <input5: histograms file>" << std::endl;
578 return 1; // Exit with an error code
579 }
580
581 std::cout << "\n Inputs instructions:" << std::endl;
582 std::cout << " * <input1: unc. model> : can be 'SimpleJMR' or 'FullJMR' " << std::endl;
583 std::cout << " * <input2: kind_of_mc> : can be 'MC20', 'MC21', 'MC23', 'MC20AF3' " << std::endl;
584 std::cout << " * <input3: dointerpol> : can be 'true' or 'false' " << std::endl;
585 std::cout << " * <input4: eta_bin> : can be any positive decimal number below 2.0 " << std::endl;
586 std::cout << " * <input5: histograms file> : your '.root' conatining the uncertainties " << std::endl;
587
588 // Example: "JMR_MakeUncertaintyPlots SimpleJMR MC20 true 0.1 ./source/JetUncertainties/share/DCM_240502_new/R10_JMR_AllComponents_Phase1.root"
589
591 // Daniel's settings - JMR Phase-I R22 2024 recommendation //
593
598
599 // Type of label ---> 0="Internal", 1= "Preliminar", 2="ATLASLabel"(only "ATLAS")
600 int atlas_approved = 0;
601
602 // Define uncertainty model and conditions
603 std::string kind_of_mass = "UFO";
604 std::string uncmodel = argv[1]; // "SimpleJMR" or "FullJMR"
605 std::string kind_of_mc = argv[2]; // "MC20", "MC21", "MC23", or "MC20AF3"
606 std::string stinterpol = argv[3]; // "true", "false"
607
608 bool dointerpol = true;
609 if (stinterpol == "true"){
610 dointerpol = true;
611 }else{
612 dointerpol = false;
613 }
614
615 // - The |eta| value between [the input has 16 bins from 0 and 3.0]
616 double eta_bin = std::stod(argv[4]); //0.1, 0.5, 1.05, 1.55, 1.99
617
619 // - If false (true) the plot is done as a function of jet pT (mass)
620 bool pTbin = false;
621 // - The mass bin (FF has 2 measurements with 50 < mass < 120 GeV or 120 < mass < 300 GeV)
622 int mass_bin = 0;
623
625 // Note: this has to be your custom input root file, user and calibration dependent.
626 std::string histofile = argv[5];
627
629 // Plotting functions //
631
632 // Plots as a function of jet pT
633 pTbin = false;
634 mass_bin = 40;
635 MakeJMRPlot(atlas_approved, histofile, uncmodel, kind_of_mass, kind_of_mc, dointerpol, mass_bin, eta_bin, pTbin);
636
637 // Plots as a function of jet mass
638 pTbin = true;
639 mass_bin = 200;
640 MakeJMRPlot(atlas_approved, histofile, uncmodel, kind_of_mass, kind_of_mc, dointerpol, mass_bin, eta_bin, pTbin);
641
642 return 0;
643
644}
void MakeJMRPlot(int atlas_approved, const std::string &histofile, const std::string &uncmodel, const std::string &kind_of_mass, const std::string &kind_of_mc, bool dointerpol, int mass_bin, double eta_bin, bool pTbin=false)

◆ MakeJMRPlot()

void MakeJMRPlot ( int atlas_approved,
const std::string & histofile,
const std::string & uncmodel,
const std::string & kind_of_mass,
const std::string & kind_of_mc,
bool dointerpol,
int mass_bin,
double eta_bin,
bool pTbin = false )

Definition at line 134 of file JMR_MakeUncertaintyPlots.cxx.

134 {
135
136 // Make a log-binned histogram: used to read the uncertainties originally
137 std::vector<double> npTbinning;
138 double original_ptmin = 0, original_ptmax = 0;
139 if (pTbin){
140 original_ptmin = 40, original_ptmax = 600;
141 npTbinning = makeLogBins(560,original_ptmin,original_ptmax);
142 }else{
143 original_ptmin = 200, original_ptmax = 3000;
144 npTbinning = makeLogBins(2800,original_ptmin,original_ptmax);
145 }
146 int npTbins = -1+npTbinning.size();
147
148 std::unique_ptr<TFile> f_JMR_uncertainties_histograms = std::make_unique<TFile>(histofile.c_str(), "READ");
149 if (f_JMR_uncertainties_histograms == 0){
150 std::cout << "Can't find input file.\n";
151 return;
152 }
153
154 std::cout << "\n > Input root file opened \n" << std::endl;
155
156 std::vector<std::string> UFO_JMR_uncertainties_histo_names = {};
157 std::vector<std::string> uncertainty_names = {};
158 std::vector<std::string> uncertainty_treatment = {};
159
160 if (uncmodel == "SimpleJMR"){
161
162 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
164 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
166 uncertainty_treatment = {"eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass", "eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass"};
167
168 }else if (uncmodel == "FullJMR"){
169
170 // Not including the Topology as it is only applied for QCD-like jets
171
172 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
174 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
176 uncertainty_treatment = {"eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass", "eLOGmOeAbsEta", "eLOGmOeAbsEta", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass", "PtAbsMass"};
177
178 }
179
180 std::cout << " > Uncertainty model: " << uncmodel << "\n" << std::endl;
181
182 if (uncertainty_names.size() != UFO_JMR_uncertainties_histo_names.size()){
183 std::cout << "List of syst histograms and syst names of different sizes.\n";
184 return;
185 }
186
187 std::cout << " > Input uncertainty names and histograms provided \n" << std::endl;
188
189 // A vector with all the histograms for the large-R jet JMR uncertainties (from the tool)
190 std::vector<TH3F*> JMR_uncertainties_hists_3d;
191 int histocount3d = 0;
192 std::vector<TH2D*> JMR_uncertainties_hists_2d;
193 int histocount2d = 0;
194 int iprime[50] = {};
195
196 for (int i=0; i < std::ssize(uncertainty_names); i++){
197
198 TString histoname = UFO_JMR_uncertainties_histo_names[i].c_str();
199 TString unctreatment = uncertainty_treatment[i].c_str();
200 if (f_JMR_uncertainties_histograms->Get(histoname) != 0){
201
202 if (unctreatment == "eLOGmOeAbsEta"){
203 JMR_uncertainties_hists_3d.push_back((TH3F*)f_JMR_uncertainties_histograms->Get(histoname));
204 iprime[i] = histocount3d;
205 histocount3d += 1;
206 }else if (unctreatment == "PtAbsMass"){
207 JMR_uncertainties_hists_2d.push_back((TH2D*)f_JMR_uncertainties_histograms->Get(histoname));
208 iprime[i] = histocount2d;
209 histocount2d += 1;
210 }
211 std::cout << " >> NP read '" << UFO_JMR_uncertainties_histo_names[i] << "' with iprime["<<i<<"] = " <<iprime[i]<< std::endl;
212 std::cout << " >>> Uncertainty treatment = " << unctreatment << std::endl;
213
214 }else{
215 std::cout << "Can't read input histo." << UFO_JMR_uncertainties_histo_names[i] << "\n";
216 return;
217 }
218
219 }
220
221 std::cout << "\n > Input 2D and 3D histograms are read now \n" << std::endl;
222
223 // Make histogram in 1Dim for the plots
224 std::vector<std::unique_ptr<TH1D>> JMR_uncertainties_1Dhists;
225
226 for (int i=0; i < std::ssize(uncertainty_names); i++){
227
228 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]));
229 auto* hist0 = JMR_uncertainties_1Dhists.at(i).get(); // Cache the pointer
230
231 TString unctreatment = uncertainty_treatment[i].c_str();
232 float uncertainty_value = 0;
233
234 if (unctreatment == "eLOGmOeAbsEta"){
235
236 auto* hist1 = JMR_uncertainties_hists_3d.at(iprime[i]); // Cache the pointer
237
238 for (int bin=1; bin<=npTbins; ++bin){
239 double j = hist0->GetBinCenter(bin);
240
241 // Calculate the hyperbolic cosine of eta and the energy
242 double cosh_eta = std::cosh(eta_bin);
243 double energy_bin = sqrt((mass_bin*mass_bin) + (j*j)*pow(cosh_eta,2));
244
245 // If we are out of the range of the input histograms we just take the last value
246 double x = energy_bin, y = TMath::Log(mass_bin/energy_bin), z = eta_bin;
247
248 Int_t bin_energy = hist1->GetXaxis()->FindBin(x);
249 Int_t bin_mass = hist1->GetYaxis()->FindBin(y);
250 Int_t bin_eta = hist1->GetZaxis()->FindBin(z);
251
252 // If true, the plot is done as a function of mass instead, and we interprete "mass_bin" as "pT_bin"
253 if (pTbin){
254 energy_bin = sqrt((j*j) + (mass_bin*mass_bin)*pow(cosh_eta,2));
255
256 // If we are out of the range of the input histograms we just take the last value
257 x = energy_bin, y = TMath::Log(j/energy_bin), z = eta_bin;
258
259 bin_energy = hist1->GetXaxis()->FindBin(x);
260 bin_mass = hist1->GetYaxis()->FindBin(y);
261 bin_eta = hist1->GetZaxis()->FindBin(z);
262 }
263
264 // In principle we should not take the fabs(), since there's UP and DOWN, but this is just for illustration
265 if (dointerpol){
266 uncertainty_value = fabs( Read3DHistogram(hist1, x, y, z) ); // Interpolating as in the tool
267 }else{
268 uncertainty_value = fabs( hist1->GetBinContent(bin_energy, bin_mass, bin_eta) ); // No interpolation
269 }
270
271 // Save the systematic uncertainty
272 hist0->SetBinContent(bin, uncertainty_value);
273
274 }
275
276 }else if (unctreatment == "PtAbsMass"){
277
278 auto* hist2 = JMR_uncertainties_hists_2d.at(iprime[i]); // Cache the pointer
279
280 for (int bin=1; bin<=npTbins; ++bin){
281
282 double j = hist0->GetBinCenter(bin);
283
284 // If we are out of the range of the input histograms we just take the last value
285 double x = j, y = mass_bin;
286
287 Int_t bin_pt = hist2->GetXaxis()->FindBin(x);
288 Int_t bin_mass = hist2->GetYaxis()->FindBin(y);
289
290 // If true, the plot is done as a function of mass instead and the value provided as "mass_bin" is pT
291 if (pTbin){
292 x = mass_bin, y = j;
293
294 bin_pt = hist2->GetXaxis()->FindBin(x);
295 bin_mass = hist2->GetYaxis()->FindBin(y);
296 }
297
298 // In principle we should not take the fabs(), since there's UP and DOWN, but this is just for illustration
299 if (dointerpol){
300 uncertainty_value = fabs( Interpolate2D(hist2, x, y) ); // Interpolating as in the tool
301 }else{
302 uncertainty_value = fabs( hist2->GetBinContent(bin_pt, bin_mass) ); // No interpolation
303 }
304
305 // Save the systematic uncertainty
306 hist0->SetBinContent(bin, uncertainty_value);
307
308 }
309
310 }
311
312 }
313
314 std::cout << " > Individual uncertainties evaluated \n" << std::endl;
315
317
318 std::unique_ptr<TH1D> JMR_All_uncertainties_1Dhist = std::make_unique<TH1D>("total_uncertainty", "total_uncertainty", npTbins, &npTbinning[0]);
319
320 for (int j=1; j<=JMR_All_uncertainties_1Dhist->GetXaxis()->GetNbins(); j++){
321
322 double total_uncertainty = 0;
323
324 for (int i=0; i < std::ssize(uncertainty_names); i++){
325
326 double uncval = JMR_uncertainties_1Dhists.at(i)->GetBinContent(j);
327
328 total_uncertainty += (uncval) * (uncval);
329 //std::cout << " total error bin (comp: i = "<<i<<", j = "<<j<<") = " << uncval << std::endl;
330
331 }
332
333 total_uncertainty = sqrt(total_uncertainty);
334 JMR_All_uncertainties_1Dhist->SetBinContent(j, total_uncertainty);
335 //std::cout << " total error bin (j = "<<j<<") = " << total_uncertainty << std::endl;
336
337 }
338
339 // The constant plot with the old uncertainty (0.2 for all pt bins)
340
341 std::unique_ptr<TH1D> JMR_old_uncertainties_1Dhist = std::make_unique<TH1D>("Old_uncertainty","Old_uncertainty", npTbins, &npTbinning[0]);
342
343 for (int j=1; j<=JMR_old_uncertainties_1Dhist->GetXaxis()->GetNbins(); j++){
344 JMR_old_uncertainties_1Dhist->SetBinContent(j, 0.2);
345 }
346
347 std::cout << " > Total uncertainty calculated \n" << std::endl;
348
349 // We will also need a total graph with the sum
350
351 gStyle->SetOptStat(0);
352 gROOT->Reset();
353 gROOT->SetStyle("ATLAS");
354 gROOT->ForceStyle();
355 gStyle->SetPadLeftMargin(0.15);
356 gStyle->SetPadRightMargin(0.08);
357 gStyle->SetEndErrorSize(4);
358 gStyle->SetPaintTextFormat("4.3f");
359 gStyle->SetPalette(8,0, 0.3);
360
361 std::unique_ptr<TCanvas> canvas = std::make_unique<TCanvas>("c1", "c1", 1200, 800);
362
363 // An invisible graph to set the limits of the canvas
364 int nbins = (original_ptmax - original_ptmin)/(1.);
365 std::unique_ptr<TH1D> DrawHistogram = std::make_unique<TH1D>("draw_hist","draw_hist_title",nbins, original_ptmin, original_ptmax);
366
367 DrawHistogram->SetMinimum(0);
368 DrawHistogram->SetMaximum(1.0);
369 DrawHistogram->SetLineWidth(0);//invisible histogram to set the limits of the plot
370 if (!pTbin){
371 canvas->SetLogx();//Logaritmic scale in the X axis
372 }
373
374 DrawHistogram->GetXaxis()->SetTitle("p_{T}^{jet} [GeV]");
375 DrawHistogram->GetXaxis()->SetLabelOffset(0.0125);
376 DrawHistogram->GetXaxis()->SetNdivisions(510);
377 DrawHistogram->GetXaxis()->SetMoreLogLabels(true);
378 if (pTbin){
379 DrawHistogram->GetXaxis()->SetTitle("m^{jet} [GeV]");
380 DrawHistogram->GetXaxis()->SetNdivisions(505);
381 DrawHistogram->GetXaxis()->SetMoreLogLabels(false);
382 }
383 DrawHistogram->GetXaxis()->SetTitleOffset(1.50);
384
385 DrawHistogram->GetYaxis()->SetTitle("Fractional JMR uncertainty");
386 DrawHistogram->GetYaxis()->SetLabelOffset(0.0145);
387 DrawHistogram->GetYaxis()->SetTitleOffset(1.40);
388
389 // The numbers in the axis are still wrong
390 DrawHistogram->Draw();
391
393
394 JMR_old_uncertainties_1Dhist->SetLineColor(kTeal+5);
395 JMR_old_uncertainties_1Dhist->SetLineStyle(1);
396 JMR_old_uncertainties_1Dhist->SetLineWidth(2);
397 JMR_old_uncertainties_1Dhist->SetFillStyle(4000);
398 JMR_old_uncertainties_1Dhist->SetFillColor(kTeal-9);
399 JMR_old_uncertainties_1Dhist->Draw("hist same");
400
401 JMR_All_uncertainties_1Dhist->SetLineColor(kBlue+2);
402 JMR_All_uncertainties_1Dhist->SetLineStyle(1);
403 JMR_All_uncertainties_1Dhist->SetLineWidth(2);
404 JMR_All_uncertainties_1Dhist->SetFillStyle(4000);
405 JMR_All_uncertainties_1Dhist->SetFillColor(590);
406 JMR_All_uncertainties_1Dhist->Draw("hist same");
407
408 for (int index=0; index < std::ssize(uncertainty_names); index++){
409 int indexp = index + 2;
410 if (index == 8) indexp = 14;
411 if (index == 9) indexp = 30;
412 if (index == 10) indexp = 43;
413 if (index == 11) indexp = 46;
414
415 auto* hist0 = JMR_uncertainties_1Dhists.at(index).get(); // Cache the pointer
416 hist0->SetLineColor(indexp);
417 hist0->SetLineStyle(index+2);
418 hist0->SetLineWidth(2);
419 hist0->Draw("hist same");
420 }
421
423
424 // ATLAS label
425
426 TString ATLAS_LABELLING="";
427 if (atlas_approved==0){
428 ATLAS_LABELLING = "Internal";
429 }else if (atlas_approved==1)
430 ATLAS_LABELLING = "Preliminary";
431 else if (atlas_approved==2){
432 ATLAS_LABELLING = "";
433 }
434
435 TLatex p;
436 TLatex l;
437 l.SetNDC();
438 l.SetTextFont(72);
439 l.SetTextSize(0.05);
440 //l.SetTextColor(color);
441 p.SetNDC();
442 p.SetTextFont(42);
443 p.SetTextSize(0.05);
444 //ATLAS_LABEL(0.2,0.6,kBlack);
445
446 l.DrawLatex(0.67,0.89,"ATLAS");
447 p.DrawLatex(0.67+0.115,0.89,ATLAS_LABELLING);
448
449 // Other information
450
451 TLatex data_text;
452 data_text.SetNDC();
453 data_text.SetTextFont(42);
454 data_text.SetTextSize(0.04);
455 data_text.DrawLatex(0.18,0.89,"Data 2015-2017, #sqrt{s} = 13 TeV");
456
457 TLatex jet_info_1_text;
458 jet_info_1_text.SetNDC();
459 jet_info_1_text.SetTextFont(42);
460 jet_info_1_text.SetTextSize(0.04);
461 jet_info_1_text.DrawLatex(0.18,0.89-0.06,"Phase-I unc. for UFO R = 1.0 jets");
462
463 TLatex jet_info_2_text;
464 jet_info_2_text.SetNDC();
465 jet_info_2_text.SetTextFont(42);
466 jet_info_2_text.SetTextSize(0.04);
467
468 std::string jet_info_2_string = "";
469 if (kind_of_mass == "UFO"){
470
471 jet_info_2_string = "|#eta^{jet}| = "+TString(Form("%f",eta_bin))+", m_{UFO}^{jet} = "+TString(Form("%i",mass_bin))+" GeV";
472
473 if (pTbin){
474 jet_info_2_string = "|#eta^{jet}| = "+TString(Form("%f",eta_bin))+", p_{T}^{jet} = "+TString(Form("%i",mass_bin))+" GeV";
475 }
476
477 }
478 jet_info_2_text.DrawLatex(0.18,0.89-2*0.06,jet_info_2_string.c_str());
479
481
482 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);
483 legend0_1->SetTextSize(0.035);
484 legend0_1->SetTextFont(42);
485 legend0_1->SetBorderSize(0);
486 legend0_1->SetFillStyle(0);
487 legend0_1->AddEntry(JMR_All_uncertainties_1Dhist.get(), "Tot. uncert.","f");
488 legend0_1->Draw("same");
489
490 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);
491 legend0_2->SetTextSize(0.035);
492 legend0_2->SetTextFont(42);
493 legend0_2->SetBorderSize(0);
494 legend0_2->SetFillStyle(0);
495 legend0_2->AddEntry(JMR_old_uncertainties_1Dhist.get(), "Tot. uncert. (previous)","f");
496 legend0_2->Draw("same");
497
498 // List all the uncertainty components
499 std::unique_ptr<TLegend> legend1;
500 if (uncmodel == "SimpleJMR"){
501 legend1 = std::make_unique<TLegend>(0.55,0.70,0.85,0.88);
502 }else if (uncmodel == "FullJMR"){
503 legend1 = std::make_unique<TLegend>(0.55,0.55,0.85,0.88);
504 }
505 else {
506 std::println (std::cerr, "Unknown uncertainty model: {}", uncmodel);
507 return;
508 }
509 legend1->SetTextSize(0.035);
510 legend1->SetTextFont(42);
511 legend1->SetBorderSize(0);
512 legend1->SetFillStyle(0);
513 for (int index=0; index < std::ssize(uncertainty_names); index++){
514 legend1->AddEntry(JMR_uncertainties_1Dhists.at(index).get(), uncertainty_names[index].c_str(),"l");
515 }
516 legend1->Draw("same");
517
518 DrawHistogram->Draw("axis same");
519
520 std::cout << " > Plots are done now \n" << std::endl;
521
522 std::string outputdir = "./source/JetUncertainties/util/output/";
523
524 try{
525 // Check if the directory exists; if not, create it
526 if (!std::filesystem::exists(outputdir)) {
527 if (std::filesystem::create_directory(outputdir)){
528 std::cout << "Output directory created successfully: " << outputdir << std::endl;
529 }else{
530 std::cerr << "Failed to create directory: " << outputdir << std::endl;
531 return; // Exit with error code
532 }
533 } else {
534 std::cout << "Output directory already exists: " << outputdir << std::endl;
535 }
536 }catch (const std::filesystem::filesystem_error& e){
537 std::cerr << "Filesystem error: " << e.what() << std::endl;
538 return; // Exit with error code
539 }
540
541 std::string string_write;
542 std::string string_write_pdf;
543 std::string string_write_png;
544
545 TString mBinStr = "mass"+std::to_string(mass_bin);
546 if (pTbin){
547 mBinStr = "pT"+std::to_string(mass_bin);
548 }
549
550 TString EtaBinStr = "Eta"+std::to_string(eta_bin);
551
552 if (atlas_approved == 0){
553 string_write = outputdir+"FractionalJMRuncertainty_"+kind_of_mc+"_"+kind_of_mass+"_"+uncmodel+"_"+EtaBinStr+"_"+mBinStr+ "GeV_ATLASint";
554 string_write_pdf = string_write+".pdf";
555 string_write_png = string_write+".png";
556 }else if (atlas_approved == 1){
557 string_write = outputdir+"FractionalJMRuncertainty_"+kind_of_mc+"_"+kind_of_mass+"_"+uncmodel+"_"+EtaBinStr+"_"+mBinStr+ "GeV_ATLASprel";
558 string_write_pdf = string_write+".pdf";
559 string_write_png = string_write+".png";
560 }else if (atlas_approved == 2){
561 string_write = outputdir+"FractionalJMRuncertainty_"+kind_of_mc+"_"+kind_of_mass+"_"+uncmodel+"_"+EtaBinStr+"_"+mBinStr+ "GeV_ATLAS";
562 string_write_pdf = string_write+".pdf";
563 string_write_png = string_write+".png";
564 }
565
566 canvas->Print(string_write_pdf.c_str());
567 //canvas->Print(string_write_png.c_str());
568
569 return;
570
571}
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)
#define z
l
Printing final latex table to .tex output file.
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
constexpr int pow(int x)
Definition conifer.h:27
Definition index.py:1

◆ makeLogBins()

std::vector< double > makeLogBins ( int nbins,
double min,
double max )

Definition at line 124 of file JMR_MakeUncertaintyPlots.cxx.

124 {
125 std::vector<double> bins;
126 double lmin = log(min), k=(log(max)-log(min))/nbins;
127 for (int i=0;i<=nbins;++i){
128 bins.push_back(exp(lmin+k*i));
129 //std::cout << " bins.at("<<i<<") = " << exp(lmin+k*i) << std::endl;
130 }
131 return bins;
132}
static const std::vector< std::string > bins
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41

◆ Read3DHistogram()

double Read3DHistogram ( const TH3 * histo,
double x,
double y,
double z )

Definition at line 88 of file JMR_MakeUncertaintyPlots.cxx.

88 {
89
90 if (not histo){
91 std::cout << "Histogram pointer is null in FFJetSmearingTool::Read3DHistogram" << std::endl;
92 return 0.;
93 }
94
95 double aux_x = x;
96 double aux_y = y;
97 double aux_z = z;
98
100 // If the value is outside the histogram region, we take the closest value to that one
101
102 double xMax = histo->GetXaxis()->GetBinLowEdge(histo->GetNbinsX()+1);
103 double xMin = histo->GetXaxis()->GetBinLowEdge(1);
104 double yMax = histo->GetYaxis()->GetBinLowEdge(histo->GetNbinsY()+1);
105 double yMin = histo->GetYaxis()->GetBinLowEdge(1);
106 double zMax = histo->GetZaxis()->GetBinLowEdge(histo->GetNbinsZ()+1);
107 double zMin = histo->GetZaxis()->GetBinLowEdge(1);
108
109 if (x >= xMax) aux_x = xMax-1e-6 ; //so it fits the up-most x-bin
110 if (x <= xMin) aux_x = xMin+1e-6 ; //so it fits the low-most x-bin
111 if ( std::isnan(y)) return 0; // no weight if the input is NaN, can happen for log(X)
112 if (y >= yMax) aux_y = yMax-1e-6 ; //so it fits the up-most y-bin
113 if (y <= yMin) aux_y = yMin+1e-6 ; //so it fits the low-most y-bin
114 if (z >= zMax) aux_z = zMax-1e-6 ; //so it fits the up-most z-bin
115 if (z <= zMin) aux_z = zMin+1e-6 ; //so it fits the low-most z-bin
116
117 //Use the interpolate function from JetHelpers.cxx
118 double interpolated_value = JetHelpers::Interpolate(histo, aux_x, aux_y, aux_z);
119 return interpolated_value;
120
121}