@@ -38,22 +38,27 @@ def get_yields(cfg):
3838 yields_err [f"{ pt_bin_min } _{ pt_bin_max } " ] = []
3939 trials [f"{ pt_bin_min } _{ pt_bin_max } " ] = []
4040 for filename in filenames :
41+ print (f"Reading { filename } " )
4142 with TFile .Open (filename ) as fin :
4243 hist = fin .Get (cfg ["histoname" ])
4344 hist_sel = fin .Get (cfg ["sel_histoname" ])
44- if hist is None :
45+ if hist . ClassName () != "TH1F" :
4546 print (f"No hist in { filename } " )
47+ if hist_sel .ClassName () != "TH1F" :
48+ print (f"No hist sel in { filename } " )
4649 dirname = re .split ("/" , filename )[4 ] # [-2] for D2H fitter
4750 trial_name = dirname .replace (cfg ["dir_pattern" ], "" )
4851 for ind , (pt_bin_min , pt_bin_max ) in enumerate (zip (cfg ["pt_bins_min" ],
4952 cfg ["pt_bins_max" ])):
50- if eval (cfg ["selection" ])(hist_sel .GetBinContent (ind + 1 )):
53+ if eval (cfg ["selection" ])(hist_sel .GetBinContent (ind + 1 )) \
54+ and hist .GetBinContent (ind + 1 ) > 1.0 :
5155 yields [f"{ pt_bin_min } _{ pt_bin_max } " ].append (hist .GetBinContent (ind + 1 ))
5256 yields_err [f"{ pt_bin_min } _{ pt_bin_max } " ].append (hist .GetBinError (ind + 1 ))
5357 trials [f"{ pt_bin_min } _{ pt_bin_max } " ].append (trial_name )
5458 else :
5559 print (f"Rejected: { hist_sel .GetBinContent (ind + 1 )} { trial_name } pt: { pt_bin_min } , { pt_bin_max } " )
56- #print(f"final yields:\n{yields}\ntrials:\n{trials}\nyields error:\n{yields_err}")
60+ if hist .GetBinContent (ind + 1 ) < 1.0 :
61+ print (f"Yield 0" )
5762 return yields , yields_err , trials
5863
5964
0 commit comments