@@ -62,7 +62,7 @@ def __init__(self, datap, case, typean, period):
6262 super ().__init__ (datap , case , typean , period )
6363
6464 # output directories
65- suffix = f"results.{ period } " if period is not None else "resultsallp"
65+ suffix = f"results.{ period } " if period is not None else "resultsallp"
6666 self .d_resultsallpmc = self .cfg (f"mc.{ suffix } " )
6767 self .d_resultsallpdata = self .cfg (f"data.{ suffix } " )
6868
@@ -114,6 +114,7 @@ def __init__(self, datap, case, typean, period):
114114 for param , symbol in zip (
115115 ("mean" , "sigma" , "significance" , "chi2" ),
116116 ("#it{#mu}" , "#it{#sigma}" , "significance" , "#it{#chi}^{2}" ),
117+ strict = False ,
117118 )
118119 }
119120 for level in self .fit_levels
@@ -130,8 +131,8 @@ def __init__(self, datap, case, typean, period):
130131 self .file_out_histo = TFile (self .n_fileresult , "recreate" )
131132
132133 self .fitter = RooFitter ()
133- self .roo_ws = {} # ROOT workspaces stored at various levels
134- self .roows = {} # ROOT workspaces at latest level
134+ self .roo_ws = {} # ROOT workspaces stored at various levels
135+ self .roows = {} # ROOT workspaces at latest level
135136
136137 # region helpers
137138 def _save_canvas (self , canvas , filename ):
@@ -512,7 +513,7 @@ def fit(self):
512513 if h_invmass .GetEntries () < 100 : # TODO: reconsider criterion
513514 self .logger .error ("Not enough entries to fit %s iptjet %s ipt %d" , level , iptjet , ipt )
514515 continue
515- fit_res , _ , func_bkg = self ._fit_mass (
516+ fit_res , _ , _ = self ._fit_mass (
516517 h_invmass , f"fit/h_mass_fitted_{ string_range_pthf (range_pthf )} _{ level } .png"
517518 )
518519 if fit_res and fit_res .Get () and fit_res .IsValid ():
@@ -522,12 +523,12 @@ def fit(self):
522523 self .logger .error ("Fit failed for %s bin %d" , level , ipt )
523524 if self .cfg ("mass_roofit" ):
524525 for entry in self .cfg ("mass_roofit" , []):
525- if lvl := entry .get ("level" ):
526- if lvl != level :
527- continue
528- if ptspec := entry . get ( "ptrange" ):
529- if ptspec [ 0 ] > range_pthf [ 0 ] or ptspec [ 1 ] < range_pthf [ 1 ] :
530- continue
526+ if ( lvl := entry .get ("level" )) and lvl != level :
527+ continue
528+ if ( ptspec := entry . get ( "ptrange" )) and (
529+ ptspec [ 0 ] > range_pthf [ 0 ] or ptspec [ 1 ] < range_pthf [ 1 ]
530+ ) :
531+ continue
531532 fitcfg = entry
532533 break
533534 self .logger .debug ("Using fit config for %i: %s" , ipt , fitcfg )
@@ -585,7 +586,9 @@ def fit(self):
585586 if iptjet is None :
586587 if not fitcfg .get ("per_ptjet" ):
587588 for jptjet in range (get_nbins (h , 1 )):
588- self .logger .info ('Overwriting roows_ptjet for %s iptjet %s ipt %d' , level , jptjet , ipt )
589+ self .logger .info (
590+ "Overwriting roows_ptjet for %s iptjet %s ipt %d" , level , jptjet , ipt
591+ )
589592 self .roows [(jptjet , ipt )] = roo_ws .Clone ()
590593 self .roo_ws [(level , jptjet , ipt )] = roo_ws .Clone ()
591594 if level in ("data" , "mc" ):
@@ -638,12 +641,12 @@ def _subtract_sideband(self, hist, var, mcordata, ipt):
638641 return None
639642
640643 for entry in self .cfg ("sidesub" , []):
641- if level := entry .get ("level" ):
642- if level != mcordata :
643- continue
644- if ptrange_sel := entry . get ( "ptrange" ):
645- if ptrange_sel [ 0 ] > self . bins_candpt [ ipt ] or ptrange_sel [ 1 ] < self . bins_candpt [ ipt + 1 ] :
646- continue
644+ if ( level := entry .get ("level" )) and level != mcordata :
645+ continue
646+ if ( ptrange_sel := entry . get ( "ptrange" )) and (
647+ ptrange_sel [ 0 ] > self . bins_candpt [ ipt ] or ptrange_sel [ 1 ] < self . bins_candpt [ ipt + 1 ]
648+ ) :
649+ continue
647650 regcfg = entry ["regions" ]
648651 break
649652 regions = {
@@ -706,10 +709,10 @@ def _subtract_sideband(self, hist, var, mcordata, ipt):
706709 continue
707710 rws = self .roo_ws .get ((mcordata , iptjet , ipt ))
708711 if not rws :
709- self .logger .error ("Could not retrieve roows for %s-iptjet%i-ipt%i using incl. ws instead " , mcordata , iptjet , ipt )
712+ self .logger .error ("Falling back to incl. roows for %s-iptjet%i-ipt%i" , mcordata , iptjet , ipt )
710713 rws = self .roo_ws .get ((mcordata , None , ipt ))
711714 if not rws :
712- self .logger .critical ("Could not retrieve roows for %s-iptjet%i-ipt%i using incl. ws instead " , mcordata , iptjet , ipt )
715+ self .logger .critical ("Could not retrieve roows for %s-iptjet%i-ipt%i" , mcordata , iptjet , ipt )
713716 f = rws .pdf ("bkg" ).asTF (rws .var ("m" ))
714717 area = {region : f .Integral (* limits [region ]) for region in regions }
715718 self .logger .info ("areas for %s-iptjet%s-ipt%s: %s" , mcordata , iptjet , ipt , area )
0 commit comments