|
14 | 14 |
|
15 | 15 | import numpy as np # pylint: disable=import-error |
16 | 16 | import ROOT # pylint: disable=import-error |
| 17 | +from enum import IntEnum, auto |
17 | 18 | sys.path.insert(0, '..') |
18 | 19 | from cut_variation import CutVarMinimiser |
19 | 20 | from cut_variation import MinimisationStatus |
20 | 21 | from style_formatter import set_object_style |
21 | 22 |
|
22 | 23 | # pylint: disable=no-member,too-many-locals,too-many-statements |
23 | 24 |
|
| 25 | +class PlotType(IntEnum): |
| 26 | + Rawy = 0 |
| 27 | + Eff = auto() |
| 28 | + Frac = auto() |
| 29 | + Cov = auto() |
| 30 | + Unc = auto() |
| 31 | + N = auto() |
24 | 32 |
|
25 | 33 | def main(config): |
26 | 34 | """ |
@@ -62,17 +70,19 @@ def main(config): |
62 | 70 | if (pt_bin_to_process != -1 and pt_bin_to_process < 1) or pt_bin_to_process > hist_rawy[0].GetNbinsX(): |
63 | 71 | sys.exit("\33[31mFatal error: pt_bin_to_process must be a positive value up to number of bins in raw yield histogram. Exit.") |
64 | 72 |
|
65 | | - is_draw_title_rawy = cfg.get("is_draw_title", {}).get("rawy", True) |
66 | | - is_draw_title_eff = cfg.get("is_draw_title", {}).get("eff", False) |
67 | | - is_draw_title_frac = cfg.get("is_draw_title", {}).get("frac", False) |
68 | | - is_draw_title_cov = cfg.get("is_draw_title", {}).get("cov", False) |
69 | | - is_draw_title_unc = cfg.get("is_draw_title", {}).get("unc", True) |
| 73 | + is_draw_title = [False] * PlotType.N |
| 74 | + is_draw_title[PlotType.Rawy] = cfg.get("is_draw_title", {}).get("rawy", True) |
| 75 | + is_draw_title[PlotType.Eff] = cfg.get("is_draw_title", {}).get("eff", False) |
| 76 | + is_draw_title[PlotType.Frac] = cfg.get("is_draw_title", {}).get("frac", False) |
| 77 | + is_draw_title[PlotType.Cov] = cfg.get("is_draw_title", {}).get("cov", False) |
| 78 | + is_draw_title[PlotType.Unc] = cfg.get("is_draw_title", {}).get("unc", True) |
70 | 79 |
|
71 | | - is_save_canvas_as_macro_rawy = cfg.get("is_save_canvas_as_macro", {}).get("rawy", False) |
72 | | - is_save_canvas_as_macro_eff = cfg.get("is_save_canvas_as_macro", {}).get("eff", False) |
73 | | - is_save_canvas_as_macro_frac = cfg.get("is_save_canvas_as_macro", {}).get("frac", False) |
74 | | - is_save_canvas_as_macro_cov = cfg.get("is_save_canvas_as_macro", {}).get("cov", False) |
75 | | - is_save_canvas_as_macro_unc = cfg.get("is_save_canvas_as_macro", {}).get("unc", False) |
| 80 | + is_save_canvas_as_macro = [False] * PlotType.N |
| 81 | + is_save_canvas_as_macro[PlotType.Rawy] = cfg.get("is_save_canvas_as_macro", {}).get("rawy", False) |
| 82 | + is_save_canvas_as_macro[PlotType.Eff] = cfg.get("is_save_canvas_as_macro", {}).get("eff", False) |
| 83 | + is_save_canvas_as_macro[PlotType.Frac] = cfg.get("is_save_canvas_as_macro", {}).get("frac", False) |
| 84 | + is_save_canvas_as_macro[PlotType.Cov] = cfg.get("is_save_canvas_as_macro", {}).get("cov", False) |
| 85 | + is_save_canvas_as_macro[PlotType.Unc] = cfg.get("is_save_canvas_as_macro", {}).get("unc", False) |
76 | 86 |
|
77 | 87 | if cfg["central_efficiency"]["computerawfrac"]: |
78 | 88 | infile_name = os.path.join(cfg["central_efficiency"]["inputdir"], cfg["central_efficiency"]["inputfile"]) |
@@ -240,48 +250,48 @@ def main(config): |
240 | 250 |
|
241 | 251 | hist_bin_title = f"bin # {ipt+1}; {pt_axis_title}#in ({pt_min}; {pt_max})" |
242 | 252 |
|
243 | | - hist_bin_title_rawy = hist_bin_title if is_draw_title_rawy else "" |
| 253 | + hist_bin_title_rawy = hist_bin_title if is_draw_title[PlotType.Rawy] else "" |
244 | 254 | canv_rawy, histos_rawy, leg_r = minimiser.plot_result(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_rawy) |
245 | 255 | output.cd() |
246 | 256 | canv_rawy.Write() |
247 | 257 | for _, hist in histos_rawy.items(): |
248 | 258 | hist.Write() |
249 | | - if (is_save_canvas_as_macro_rawy): |
| 259 | + if (is_save_canvas_as_macro[PlotType.Rawy]): |
250 | 260 | canv_rawy.SaveAs(f"canv_rawy_{ipt+1}.C") |
251 | 261 |
|
252 | | - hist_bin_title_unc = hist_bin_title if is_draw_title_unc else "" |
| 262 | + hist_bin_title_unc = hist_bin_title if is_draw_title[PlotType.Unc] else "" |
253 | 263 | canv_unc, histos_unc, leg_unc = minimiser.plot_uncertainties(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_unc) |
254 | 264 | output.cd() |
255 | 265 | canv_unc.Write() |
256 | 266 | for _, hist in histos_unc.items(): |
257 | 267 | hist.Write() |
258 | | - if (is_save_canvas_as_macro_unc): |
| 268 | + if (is_save_canvas_as_macro[PlotType.Unc]): |
259 | 269 | canv_unc.SaveAs(f"canv_unc_{ipt+1}.C") |
260 | 270 |
|
261 | | - hist_bin_title_eff = hist_bin_title if is_draw_title_eff else "" |
| 271 | + hist_bin_title_eff = hist_bin_title if is_draw_title[PlotType.Eff] else "" |
262 | 272 | canv_eff, histos_eff, leg_e = minimiser.plot_efficiencies(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_eff) |
263 | 273 | output.cd() |
264 | 274 | canv_eff.Write() |
265 | 275 | for _, hist in histos_eff.items(): |
266 | 276 | hist.Write() |
267 | | - if (is_save_canvas_as_macro_eff): |
| 277 | + if (is_save_canvas_as_macro[PlotType.Eff]): |
268 | 278 | canv_eff.SaveAs(f"canv_eff_{ipt+1}.C") |
269 | 279 |
|
270 | | - hist_bin_title_frac = hist_bin_title if is_draw_title_frac else "" |
| 280 | + hist_bin_title_frac = hist_bin_title if is_draw_title[PlotType.Frac] else "" |
271 | 281 | canv_frac, histos_frac, leg_f = minimiser.plot_fractions(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_frac) |
272 | 282 | output.cd() |
273 | 283 | canv_frac.Write() |
274 | 284 | for _, hist in histos_frac.items(): |
275 | 285 | hist.Write() |
276 | | - if (is_save_canvas_as_macro_frac): |
| 286 | + if (is_save_canvas_as_macro[PlotType.Frac]): |
277 | 287 | canv_frac.SaveAs(f"canv_frac_{ipt+1}.C") |
278 | 288 |
|
279 | | - hist_bin_title_cov = hist_bin_title if is_draw_title_cov else "" |
| 289 | + hist_bin_title_cov = hist_bin_title if is_draw_title[PlotType.Cov] else "" |
280 | 290 | canv_cov, histo_cov = minimiser.plot_cov_matrix(True, f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_cov) |
281 | 291 | output.cd() |
282 | 292 | canv_cov.Write() |
283 | 293 | histo_cov.Write() |
284 | | - if (is_save_canvas_as_macro_cov): |
| 294 | + if (is_save_canvas_as_macro[PlotType.Cov]): |
285 | 295 | canv_cov.SaveAs(f"canv_cov_{ipt+1}.C") |
286 | 296 | else: |
287 | 297 | print(f"Minimization for pT {pt_min}, {pt_max} not successful") |
|
0 commit comments