Skip to content

Commit 1cd1e16

Browse files
DelloStrittoLuigi Dello Stritto
andauthored
Updated dbs and bug fixing (alisw#988)
* updated db and bug fixing * Dplus dbs * fix * fix * fix dbs * fix processer --------- Co-authored-by: Luigi Dello Stritto <[email protected]>
1 parent 52ab3de commit 1cd1e16

9 files changed

+1549
-740
lines changed

machine_learning_hep/analysis/analyzerdhadrons.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(self, datap, case, typean, period):
7979
self.lpt_finbinmax = datap["analysis"][self.typean]["sel_an_binmax"]
8080
self.bin_matching = datap["analysis"][self.typean]["binning_matching"]
8181
self.p_nptbins = len(self.lpt_finbinmin)
82-
self.lpt_probcutfin = datap["mlapplication"]["probcutoptimal"]
82+
self.lpt_probcutfin_tmp = datap["mlapplication"]["probcutoptimal"]
8383
self.triggerbit = datap["analysis"][self.typean].get("triggerbit", "")
8484

8585
dp = datap["analysis"][self.typean]
@@ -131,7 +131,7 @@ def __init__(self, datap, case, typean, period):
131131
self.fit_func_bkg = {}
132132
self.fit_range = {}
133133

134-
self.path_fig = Path(f"fig/{self.case}/{self.typean}")
134+
self.path_fig = Path(f'{os.path.expandvars(self.d_resultsallpdata)}/fig')
135135
for folder in ["qa", "fit", "roofit", "sideband", "signalextr", "fd", "uf"]:
136136
(self.path_fig / folder).mkdir(parents=True, exist_ok=True)
137137

@@ -160,7 +160,7 @@ def __init__(self, datap, case, typean, period):
160160
# region helpers
161161
def _save_canvas(self, canvas, filename):
162162
# folder = self.d_resultsallpmc if mcordata == 'mc' else self.d_resultsallpdata
163-
canvas.SaveAs(f"fig/{self.case}/{self.typean}/{filename}")
163+
canvas.SaveAs(f'{self.path_fig}/{filename}')
164164

165165
def _save_hist(self, hist, filename, option=""):
166166
if not hist:
@@ -290,25 +290,27 @@ def fit(self):
290290
signifhistos = TH1F("hsignifs0", "", len(self.lpt_finbinmin), array("d", self.bins_candpt))
291291
soverbhistos = TH1F("hSoverB0", "", len(self.lpt_finbinmin), array("d", self.bins_candpt))
292292

293+
lpt_probcutfin = [None] * self.nbins
293294
with TFile(rfilename) as rfile:
294295
for ipt in range(len(self.lpt_finbinmin)):
296+
lpt_probcutfin[ipt] = self.lpt_probcutfin_tmp[self.bin_matching[ipt]]
295297
self.logger.debug("fitting %s - %i", level, ipt)
296298
roows = self.roows.get(ipt)
297299
if self.mltype == "MultiClassification":
298300
suffix = "%s%d_%d_%.2f%.2f%.2f" % (
299301
self.v_var_binning,
300302
self.lpt_finbinmin[ipt],
301303
self.lpt_finbinmax[ipt],
302-
self.lpt_probcutfin[ipt][0],
303-
self.lpt_probcutfin[ipt][1],
304-
self.lpt_probcutfin[ipt][2],
304+
lpt_probcutfin[ipt][0],
305+
lpt_probcutfin[ipt][1],
306+
lpt_probcutfin[ipt][2],
305307
)
306308
else:
307309
suffix = "%s%d_%d_%.2f" % (
308310
self.v_var_binning,
309311
self.lpt_finbinmin[ipt],
310312
self.lpt_finbinmax[ipt],
311-
self.lpt_probcutfin[ipt],
313+
lpt_probcutfin[ipt],
312314
)
313315
h_invmass = rfile.Get("hmass" + suffix)
314316
# Rebin

machine_learning_hep/analysis/analyzerdhadrons_mult.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(self, datap, case, typean, period):
8181
self.lpt_finbinmax = datap["analysis"][self.typean]["sel_an_binmax"]
8282
self.bin_matching = datap["analysis"][self.typean]["binning_matching"]
8383
self.p_nptbins = len(self.lpt_finbinmin)
84-
self.lpt_probcutfin = datap["mlapplication"]["probcutoptimal"]
84+
self.lpt_probcutfin_tmp = datap["mlapplication"]["probcutoptimal"]
8585

8686
self.signal_loss = datap["analysis"][self.typean].get("signal_loss", "")
8787
self.lvar2_binmin = datap["analysis"][self.typean]["sel_binmin2"]
@@ -296,7 +296,7 @@ def _fit_mass(self, hist, filename=None):
296296

297297
return (fit_res, func_sig, func_bkg)
298298

299-
# pylint: disable=too-many-branches,too-many-statements,too-many-nested-blocks
299+
# pylint: disable=too-many-branches,too-many-statements,too-many-nested-blocks, too-many-locals
300300
def fit(self):
301301
self.logger.info("Fitting inclusive mass distributions")
302302
gStyle.SetOptFit(1111)
@@ -326,16 +326,18 @@ def fit(self):
326326
"hSoverB%d" % (ibin2), "", len(self.lpt_finbinmin), array("d", self.bins_candpt)
327327
)
328328

329+
lpt_probcutfin = [None] * self.nbins
329330
for ipt in range(len(self.lpt_finbinmin)):
331+
lpt_probcutfin[ipt] = self.lpt_probcutfin_tmp[self.bin_matching[ipt]]
330332
self.logger.debug("fitting %s - %i - %i", level, ipt, ibin2)
331333
roows = self.roows.get(ipt)
332334
if self.mltype == "MultiClassification":
333335
suffix = "%s%d_%d_%.2f%.2f%s_%.2f_%.2f" % (
334336
self.v_var_binning,
335337
self.lpt_finbinmin[ipt],
336338
self.lpt_finbinmax[ipt],
337-
self.lpt_probcutfin[ipt][0],
338-
self.lpt_probcutfin[ipt][1],
339+
lpt_probcutfin[ipt][0],
340+
lpt_probcutfin[ipt][1],
339341
self.v_var2_binning,
340342
self.lvar2_binmin[ibin2],
341343
self.lvar2_binmax[ibin2],
@@ -345,7 +347,7 @@ def fit(self):
345347
self.v_var_binning,
346348
self.lpt_finbinmin[ipt],
347349
self.lpt_finbinmax[ipt],
348-
self.lpt_probcutfin[ipt],
350+
lpt_probcutfin[ipt],
349351
self.v_var2_binning,
350352
self.lvar2_binmin[ibin2],
351353
self.lvar2_binmax[ibin2],

0 commit comments

Comments
 (0)