239 def __call__(self, root_file):
240 hist = find_histo(root_file, self.histogram_name)
241 if not hist:
242 if crash_on_error:
243 raise RuntimeError(f"Histogram '{self.histogram_name}' not found.")
244 else:
245 logging.error(f"Histogram '{self.histogram_name}' not found.")
246 return
247
248
249 cum = [hist.GetBinContent(i) for i in range(0, hist.GetNbinsX() + 2)]
250 for i in range(1, len(cum)):
251 cum[i] += cum[i - 1]
252 total = cum[-1] or 1.0
253 cum = [x / total for x in cum]
254
255
256 s68 = self._compute_s(hist, cum, 0.683)
257 s90 = self._compute_s(hist, cum, 0.90)
258
259 logging.info(f"Resolution widths for {self.histogram_name} -> s68: {s68:.4f}, s90: {s90:.4f}")
260 logging.info("Todo: Take a 2D histo, take the quantity say xaxis, make its small intervals %s", "and then compute the Resolution widths and then save as a 1D histo with quantity on xaxis and Resolution widths on yaxis")
261