◆ __init__()
def python.physvalPostProcessingTools.HistogramAdjustment.__init__ |
( |
|
self, |
|
|
|
input_hist, |
|
|
|
new_path, |
|
|
|
x_label = None , |
|
|
|
y_label = None , |
|
|
|
xlow = None , |
|
|
|
xhigh = None |
|
) |
| |
Definition at line 379 of file physvalPostProcessingTools.py.
379 def __init__(self, input_hist, new_path, x_label=None, y_label=None, xlow=None, xhigh=None):
380 self.input_hist = input_hist
381 self.new_path = new_path
382 self.x_label = x_label
383 self.y_label = y_label
◆ __call__()
def python.physvalPostProcessingTools.HistogramAdjustment.__call__ |
( |
|
self, |
|
|
|
root_file |
|
) |
| |
Definition at line 387 of file physvalPostProcessingTools.py.
387 def __call__(self, root_file):
388 ROOT.TH1.AddDirectory(
False)
392 raise RuntimeError(f
"Histogram '{self.input_hist}' not found.")
394 logging.error(f
"Histogram '{self.input_hist}' not found.")
397 path_parts = self.new_path.strip(
"/").
split(
"/")
398 *dir_path, new_name = path_parts
399 directory_path =
"/".
join(dir_path)
401 root_file.cd(directory_path)
403 if self.xlow
is None or self.xhigh
is None:
404 h_out = hist.Clone(new_name)
407 bin_low =
max(1,
min(ax.FindBin(self.xlow), ax.GetNbins()))
408 bin_high =
max(1,
min(ax.FindBin(self.xhigh), ax.GetNbins()))
409 nbins = bin_high - bin_low
410 h_out = ROOT.TH1D(new_name, hist.GetTitle(), nbins + 1,
float(self.xlow),
float(self.xhigh))
411 for i
in range(nbins + 1):
412 h_out.SetBinContent(i + 1, hist.GetBinContent(i + bin_low))
415 h_out.GetXaxis().SetTitle(self.x_label)
417 h_out.GetYaxis().SetTitle(self.y_label)
418 h_out.Write(new_name, ROOT.TObject.kOverwrite)
419 logging.info(f
"Renamed and updated histogram '{self.input_hist}' → '{self.new_path}' in '{directory_path}' | X-axis: '{self.x_label}' | Y-axis: '{self.y_label}' | Range: ({self.xlow}, {self.xhigh})")
◆ from_yaml()
def python.physvalPostProcessingTools.HistogramAdjustment.from_yaml |
( |
|
fragment | ) |
|
|
static |
Definition at line 422 of file physvalPostProcessingTools.py.
422 def from_yaml(fragment):
423 return HistogramAdjustment(
424 input_hist=fragment[
"hist"],
425 new_path=fragment.get(
"final_histo_name", fragment[
"hist"]),
426 x_label=fragment.get(
"x_axis_label"),
427 y_label=fragment.get(
"y_axis_label"),
428 xlow=fragment.get(
"xlow"),
429 xhigh=fragment.get(
"xhigh")
◆ input_hist
python.physvalPostProcessingTools.HistogramAdjustment.input_hist |
◆ new_path
python.physvalPostProcessingTools.HistogramAdjustment.new_path |
◆ x_label
python.physvalPostProcessingTools.HistogramAdjustment.x_label |
◆ xhigh
python.physvalPostProcessingTools.HistogramAdjustment.xhigh |
◆ xlow
python.physvalPostProcessingTools.HistogramAdjustment.xlow |
◆ y_label
python.physvalPostProcessingTools.HistogramAdjustment.y_label |
The documentation for this class was generated from the following file: