166 def __call__(self, root_file):
167 hist = find_histo(root_file, self.histogram_name)
168 if not hist:
169 if crash_on_error:
170 raise RuntimeError(f"Histogram '{self.histogram_name}' not found.")
171 else:
172 logging.error(f"Histogram '{self.histogram_name}' not found.")
173 return
174
175
176 cum = [hist.GetBinContent(i) for i in range(0, hist.GetNbinsX() + 2)]
177 for i in range(1, len(cum)):
178 cum[i] += cum[i - 1]
179 total = cum[-1] or 1.0
180 cum = [x / total for x in cum]
181
182
183 s68 = self._compute_s(hist, cum, 0.683)
184 s90 = self._compute_s(hist, cum, 0.90)
185
186 logging.info(f"Resolution widths for {self.histogram_name} -> s68: {s68:.4f}, s90: {s90:.4f}")
187 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")
188