@@ -696,14 +696,21 @@ def _subtract_sideband(self, hist, var, mcordata, ipt):
696696 ensure_sumw2 (fh_sideband )
697697 if mcordata == "data" :
698698 bins_ptjet = list (range (get_nbins (fh_subtracted , 0 ))) if self .cfg ("sidesub_per_ptjet" ) else [None ]
699- self .logger .info ("Scaling sidebands in ptjet bins: %s" , bins_ptjet )
699+ self .logger .info ("Scaling sidebands in ptjet-%s bins: %s using %s" , label , bins_ptjet , fh_sideband )
700+ hx = project_hist (fh_sideband , (0 ,), {}) if get_dim (fh_sideband ) > 1 else fh_sideband
700701 for iptjet in bins_ptjet :
701- if rws := self .roo_ws .get ((mcordata , iptjet , ipt )):
702- f = rws .pdf ("bkg" ).asTF (rws .var ("m" ))
703- else :
704- # FIXME: What to do?
705- self .logger .error ("Could not retrieve roows for %s-iptjet%i-ipt%i" , mcordata , iptjet , ipt )
706- continue
702+ if iptjet :
703+ n = hx .GetBinContent (iptjet )
704+ self .logger .info ("Need to scale in ptjet %i: %g" , iptjet , n )
705+ if n <= 0 :
706+ continue
707+ rws = self .roo_ws .get ((mcordata , iptjet , ipt ))
708+ if not rws :
709+ self .logger .error ("Could not retrieve roows for %s-iptjet%i-ipt%i using incl. ws instead" , mcordata , iptjet , ipt )
710+ rws = self .roo_ws .get ((mcordata , None , ipt ))
711+ if not rws :
712+ self .logger .critical ("Could not retrieve roows for %s-iptjet%i-ipt%i using incl. ws instead" , mcordata , iptjet , ipt )
713+ f = rws .pdf ("bkg" ).asTF (rws .var ("m" ))
707714 area = {region : f .Integral (* limits [region ]) for region in regions }
708715 self .logger .info ("areas for %s-iptjet%s-ipt%s: %s" , mcordata , iptjet , ipt , area )
709716 if (area ["sideband_left" ] + area ["sideband_right" ]) > 0.0 :
0 commit comments