Skip to content

Commit c4c5686

Browse files
committed
draw title of each plot on user's request
1 parent 8d5e966 commit c4c5686

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

PWGHF/D2H/Macros/compute_fraction_cutvar.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def main(config):
6161
if (pt_bin_to_process != -1 and pt_bin_to_process < 1) or pt_bin_to_process > hist_rawy[0].GetNbinsX():
6262
sys.exit("Fatal error: pt_bin_to_process must be a positive value up to number of bins in raw yield histogram. Exit.")
6363

64+
is_draw_title_rawy = cfg.get("is_draw_title", {}).get("rawy", True)
65+
is_draw_title_eff = cfg.get("is_draw_title", {}).get("eff", False)
66+
is_draw_title_frac = cfg.get("is_draw_title", {}).get("frac", False)
67+
is_draw_title_cov = cfg.get("is_draw_title", {}).get("cov", False)
68+
is_draw_title_unc = cfg.get("is_draw_title", {}).get("unc", True)
69+
6470
if cfg["central_efficiency"]["computerawfrac"]:
6571
infile_name = os.path.join(cfg["central_efficiency"]["inputdir"], cfg["central_efficiency"]["inputfile"])
6672
infile_central_eff = ROOT.TFile.Open(infile_name)
@@ -211,31 +217,36 @@ def main(config):
211217

212218
hist_bin_title = f"bin # {ipt+1}; {pt_axis_title}#in ({pt_min}; {pt_max})"
213219

214-
canv_rawy, histos_rawy, leg_r = minimiser.plot_result(f"_pt{pt_min}_{pt_max}", hist_bin_title)
220+
hist_bin_title_rawy = hist_bin_title if is_draw_title_rawy else ""
221+
canv_rawy, histos_rawy, leg_r = minimiser.plot_result(f"_pt{pt_min}_{pt_max}", hist_bin_title_rawy)
215222
output.cd()
216223
canv_rawy.Write()
217224
for _, hist in histos_rawy.items():
218225
hist.Write()
219226

220-
canv_unc, histos_unc, leg_unc = minimiser.plot_uncertainties(f"_pt{pt_min}_{pt_max}", hist_bin_title)
227+
hist_bin_title_unc = hist_bin_title if is_draw_title_unc else ""
228+
canv_unc, histos_unc, leg_unc = minimiser.plot_uncertainties(f"_pt{pt_min}_{pt_max}", hist_bin_title_unc)
221229
output.cd()
222230
canv_unc.Write()
223231
for _, hist in histos_unc.items():
224232
hist.Write()
225233

226-
canv_eff, histos_eff, leg_e = minimiser.plot_efficiencies(f"_pt{pt_min}_{pt_max}", hist_bin_title)
234+
hist_bin_title_eff = hist_bin_title if is_draw_title_eff else ""
235+
canv_eff, histos_eff, leg_e = minimiser.plot_efficiencies(f"_pt{pt_min}_{pt_max}", hist_bin_title_eff)
227236
output.cd()
228237
canv_eff.Write()
229238
for _, hist in histos_eff.items():
230239
hist.Write()
231240

232-
canv_frac, histos_frac, leg_f = minimiser.plot_fractions(f"_pt{pt_min}_{pt_max}", hist_bin_title)
241+
hist_bin_title_frac = hist_bin_title if is_draw_title_frac else ""
242+
canv_frac, histos_frac, leg_f = minimiser.plot_fractions(f"_pt{pt_min}_{pt_max}", hist_bin_title_frac)
233243
output.cd()
234244
canv_frac.Write()
235245
for _, hist in histos_frac.items():
236246
hist.Write()
237247

238-
canv_cov, histo_cov = minimiser.plot_cov_matrix(True, f"_pt{pt_min}_{pt_max}", hist_bin_title)
248+
hist_bin_title_cov = hist_bin_title if is_draw_title_cov else ""
249+
canv_cov, histo_cov = minimiser.plot_cov_matrix(True, f"_pt{pt_min}_{pt_max}", hist_bin_title_cov)
239250
output.cd()
240251
canv_cov.Write()
241252
histo_cov.Write()

PWGHF/D2H/Macros/config_cutvar_example.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
"minimisation": {
5858
"correlated": true
5959
},
60+
"is_draw_title": {
61+
"rawy": true,
62+
"frac": false,
63+
"eff": false,
64+
"cov": false,
65+
"unc": true
66+
},
6067
"central_efficiency": {
6168
"computerawfrac": true,
6269
"inputdir": "path/to/central/efficiency",

0 commit comments

Comments
 (0)