Skip to content

Commit 32fabcc

Browse files
committed
place if-statement and 1-line-expression into same line
1 parent 33d92de commit 32fabcc

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

PWGHF/D2H/Macros/compute_fraction_cutvar.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,14 @@ def main(config):
202202
)
203203

204204
pt_bin_to_process_name_suffix = ""
205-
if pt_bin_to_process != -1:
206-
pt_bin_to_process_name_suffix = "_bin_" + str(pt_bin_to_process)
205+
if pt_bin_to_process != -1: pt_bin_to_process_name_suffix = "_bin_" + str(pt_bin_to_process)
207206

208207
output_name_template = cfg['output']['file'].replace(".root", "") + pt_bin_to_process_name_suffix + ".root"
209208
output = ROOT.TFile(os.path.join(cfg["output"]["directory"], output_name_template), "recreate")
210209
n_sets = len(hist_rawy)
211210
pt_axis_title = hist_rawy[0].GetXaxis().GetTitle()
212211
for ipt in range(hist_rawy[0].GetNbinsX()):
213-
if pt_bin_to_process !=-1 and ipt+1 != pt_bin_to_process:
214-
continue
212+
if pt_bin_to_process !=-1 and ipt+1 != pt_bin_to_process: continue
215213
all_vectors_monotonous = MinimisationStatus.Success
216214
pt_min = hist_rawy[0].GetXaxis().GetBinLowEdge(ipt + 1)
217215
pt_max = hist_rawy[0].GetXaxis().GetBinUpEdge(ipt + 1)
@@ -282,8 +280,7 @@ def main(config):
282280
if is_save_to_root_file[ObjectToSave.RawYield]:
283281
for _, hist in histos_rawy.items():
284282
hist.Write()
285-
if (is_save_canvas_as_macro[PlotType.Rawy]):
286-
canv_rawy.SaveAs(f"canv_rawy_{ipt+1}.C")
283+
if is_save_canvas_as_macro[PlotType.Rawy]: canv_rawy.SaveAs(f"canv_rawy_{ipt+1}.C")
287284

288285
hist_bin_title_unc = hist_bin_title if is_draw_title[PlotType.Unc] else ""
289286
canv_unc, histos_unc, leg_unc = minimiser.plot_uncertainties(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_unc)
@@ -292,8 +289,7 @@ def main(config):
292289
if is_save_to_root_file[ObjectToSave.Uncertainty]:
293290
for _, hist in histos_unc.items():
294291
hist.Write()
295-
if (is_save_canvas_as_macro[PlotType.Unc]):
296-
canv_unc.SaveAs(f"canv_unc_{ipt+1}.C")
292+
if is_save_canvas_as_macro[PlotType.Unc]: canv_unc.SaveAs(f"canv_unc_{ipt+1}.C")
297293

298294
hist_bin_title_eff = hist_bin_title if is_draw_title[PlotType.Eff] else ""
299295
canv_eff, histos_eff, leg_e = minimiser.plot_efficiencies(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_eff)
@@ -302,8 +298,7 @@ def main(config):
302298
if is_save_to_root_file[ObjectToSave.Efficiency]:
303299
for _, hist in histos_eff.items():
304300
hist.Write()
305-
if (is_save_canvas_as_macro[PlotType.Eff]):
306-
canv_eff.SaveAs(f"canv_eff_{ipt+1}.C")
301+
if is_save_canvas_as_macro[PlotType.Eff]: canv_eff.SaveAs(f"canv_eff_{ipt+1}.C")
307302

308303
hist_bin_title_frac = hist_bin_title if is_draw_title[PlotType.Frac] else ""
309304
canv_frac, histos_frac, leg_f = minimiser.plot_fractions(f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_frac)
@@ -312,16 +307,14 @@ def main(config):
312307
if is_save_to_root_file[ObjectToSave.Fraction]:
313308
for _, hist in histos_frac.items():
314309
hist.Write()
315-
if (is_save_canvas_as_macro[PlotType.Frac]):
316-
canv_frac.SaveAs(f"canv_frac_{ipt+1}.C")
310+
if is_save_canvas_as_macro[PlotType.Frac]: canv_frac.SaveAs(f"canv_frac_{ipt+1}.C")
317311

318312
hist_bin_title_cov = hist_bin_title if is_draw_title[PlotType.Cov] else ""
319313
canv_cov, histo_cov = minimiser.plot_cov_matrix(True, f"_pt_{pt_min}_to_{pt_max}", hist_bin_title_cov)
320314
output.cd()
321315
if is_save_to_root_file[ObjectToSave.Canvas]: canv_cov.Write()
322316
if is_save_to_root_file[ObjectToSave.CorrelationMatrix]: histo_cov.Write()
323-
if (is_save_canvas_as_macro[PlotType.Cov]):
324-
canv_cov.SaveAs(f"canv_cov_{ipt+1}.C")
317+
if is_save_canvas_as_macro[PlotType.Cov]: canv_cov.SaveAs(f"canv_cov_{ipt+1}.C")
325318
else:
326319
print(f"Minimization for pT {pt_min}, {pt_max} not successful")
327320
hist_minimisation_status.SetBinContent(ipt + 1, MinimisationStatus.Fail)

0 commit comments

Comments
 (0)