diff --git a/machine_learning_hep/analysis/analyzer_jets.py b/machine_learning_hep/analysis/analyzer_jets.py index af3857a81e..8e844875b3 100644 --- a/machine_learning_hep/analysis/analyzer_jets.py +++ b/machine_learning_hep/analysis/analyzer_jets.py @@ -531,13 +531,14 @@ def fit(self): self.roo_ws_ptjet[level][jptjet][ipt] = roo_ws.Clone() # TODO: take parameter names from DB if level in ('data', 'mc'): - varname_mean = fitcfg.get('var_mean', param_names["gauss_mean"]) - varname_sigma = fitcfg.get('var_sigma', param_names["gauss_sigma"]) + varname_mean = fitcfg.get('var_mean', self.p_param_names["gauss_mean"]) + varname_sigma = fitcfg.get('var_sigma', self.p_param_names["gauss_sigma"]) self.fit_mean[level][ipt] = roo_ws.var(varname_mean).getValV() self.fit_sigma[level][ipt] = roo_ws.var(varname_sigma).getValV() - varname_m = fitcfg.get('var', param_names["mass"]) - if roo_ws.pdf(self.p_pdfnames["pdf_bkg"]): - self.fit_func_bkg[level][ipt] = roo_ws.pdf(self.p_pdfnames["pdf_bkg"]).asTF(roo_ws.var(varname_m)) + varname_m = fitcfg.get('var', self.p_param_names["mass"]) + pdf_bkg = roo_ws.pdf(self.p_pdfnames["pdf_bkg"]) + if pdf_bkg: + self.fit_func_bkg[level][ipt] = pdf_bkg.asTF(roo_ws.var(varname_m)) self.fit_range[level][ipt] = (roo_ws.var(varname_m).getMin('fit'), roo_ws.var(varname_m).getMax('fit')) self.logger.debug('fit range for %s-%i: %s', level, ipt, self.fit_range[level][ipt]) diff --git a/machine_learning_hep/analysis/analyzerdhadrons.py b/machine_learning_hep/analysis/analyzerdhadrons.py index 5f9296b5c2..31fcd5a720 100644 --- a/machine_learning_hep/analysis/analyzerdhadrons.py +++ b/machine_learning_hep/analysis/analyzerdhadrons.py @@ -313,8 +313,9 @@ def fit(self): self.fit_mean[level][ipt] = roo_ws.var('mean').getValV() self.fit_sigma[level][ipt] = roo_ws.var('sigma_g1').getValV() var_m = fitcfg.get('var', 'm') - if roo_ws.pdf(self.p_pdfnames["pdf_bkg"]): - self.fit_func_bkg[level][ipt] = roo_ws.pdf(self.p_pdfnames["pdf_bkg"]).asTF(roo_ws.var(var_m)) + pdf_bkg = roo_ws.pdf(self.p_pdfnames["pdf_bkg"]) + if pdf_bkg: + self.fit_func_bkg[level][ipt] = pdf_bkg.asTF(roo_ws.var(var_m)) self.fit_range[level][ipt] = (roo_ws.var(var_m).getMin(), roo_ws.var(var_m).getMax()) else: self.logger.error('RooFit failed for %s bin %d', level, ipt)