◆ __init__()
def python.physvalPostProcessingTools.ROCCurveComputation.__init__ |
( |
|
self, |
|
|
|
signal_path, |
|
|
|
background_path, |
|
|
|
output |
|
) |
| |
Definition at line 213 of file physvalPostProcessingTools.py.
213 def __init__(self, signal_path, background_path, output):
214 self.signal_path = signal_path
215 self.background_path = background_path
◆ __call__()
def python.physvalPostProcessingTools.ROCCurveComputation.__call__ |
( |
|
self, |
|
|
|
root_file |
|
) |
| |
Definition at line 218 of file physvalPostProcessingTools.py.
218 def __call__(self, root_file):
220 bkg =
find_histo(root_file, self.background_path)
222 if not sig
or not bkg:
224 raise RuntimeError(f
"Missing histogram: {self.signal_path} or {self.background_path}")
226 logging.error(f
"Missing histogram: {self.signal_path} or {self.background_path}")
229 graph = self.compute_roc(sig, bkg)
231 logging.error(
"ROC graph is empty or could not be constructed.")
234 path_parts = self.output.strip(
"/").
split(
"/")
235 *dir_path, obj_name = path_parts
236 directory_path =
"/".
join(dir_path)
238 graph.SetName(obj_name)
239 graph.SetTitle(f
"{obj_name};Signal Efficiency;Background Rejection")
242 root_file.cd(directory_path)
244 logging.info(f
"Saved ROC curve '{obj_name}' in '{directory_path}'.")
◆ compute_roc()
def python.physvalPostProcessingTools.ROCCurveComputation.compute_roc |
( |
|
self, |
|
|
|
sig, |
|
|
|
bkg |
|
) |
| |
Definition at line 246 of file physvalPostProcessingTools.py.
246 def compute_roc(self, sig, bkg):
247 n_bins = sig.GetNbinsX()
248 total_sig = sig.Integral()
249 total_bkg = bkg.Integral()
251 x_vals, y_vals = [], []
252 if total_sig == 0
or total_bkg == 0:
253 logging.error(
"Zero total signal or background counts; cannot compute ROC.")
256 for cut_bin
in range(1, n_bins + 1):
257 sig_pass = sig.Integral(cut_bin, n_bins)
258 bkg_pass = bkg.Integral(cut_bin, n_bins)
260 eff = sig_pass / total_sig
266 rej = total_bkg / bkg_pass
274 graph = ROOT.TGraphErrors(len(x_vals))
275 for i, (x, y)
in enumerate(zip(x_vals, y_vals)):
276 graph.SetPoint(i, x, y)
◆ from_yaml()
def python.physvalPostProcessingTools.ROCCurveComputation.from_yaml |
( |
|
fragment | ) |
|
|
static |
Definition at line 281 of file physvalPostProcessingTools.py.
281 def from_yaml(fragment):
282 return ROCCurveComputation(
283 signal_path=fragment[
"signal"],
284 background_path=fragment[
"background"],
285 output=fragment[
"output"]
◆ background_path
python.physvalPostProcessingTools.ROCCurveComputation.background_path |
◆ output
python.physvalPostProcessingTools.ROCCurveComputation.output |
◆ signal_path
python.physvalPostProcessingTools.ROCCurveComputation.signal_path |
The documentation for this class was generated from the following file: