ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
python.physvalPostProcessingTools.RebinningOperation Class Reference
Collaboration diagram for python.physvalPostProcessingTools.RebinningOperation:

Public Member Functions

def __init__ (self, input, output, rebin_factor, delete_original=False)
 
def __call__ (self, root_file)
 

Static Public Member Functions

def from_yaml (fragment)
 

Public Attributes

 input
 
 output
 
 rebin_factor
 
 delete_original
 

Detailed Description

Definition at line 65 of file physvalPostProcessingTools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.physvalPostProcessingTools.RebinningOperation.__init__ (   self,
  input,
  output,
  rebin_factor,
  delete_original = False 
)

Definition at line 66 of file physvalPostProcessingTools.py.

66  def __init__(self, input, output, rebin_factor, delete_original=False):
67  self.input = input
68  self.output = output
69  self.rebin_factor = rebin_factor
70  self.delete_original = delete_original
71 

Member Function Documentation

◆ __call__()

def python.physvalPostProcessingTools.RebinningOperation.__call__ (   self,
  root_file 
)

Definition at line 72 of file physvalPostProcessingTools.py.

72  def __call__(self, root_file):
73  hist = find_histo(root_file, self.input)
74  if not hist:
75  if crash_on_error:
76  raise RuntimeError(f"Histogram '{self.input}' not found for rebinning.")
77  else:
78  logging.error(f"Histogram '{self.input}' not found for rebinning.")
79  return
80 
81  path_parts = self.output.strip("/").split("/")
82  *dir_parts, output_name = path_parts
83  directory_path = "/".join(dir_parts)
84  ensure_directory_exists(root_file, directory_path)
85  root_file.cd(directory_path)
86 
87  if hist.GetDimension() == 1:
88  rebinned = hist.Rebin(self.rebin_factor, output_name)
89  rebinned.Write(output_name, ROOT.TObject.kOverwrite)
90  logging.info(f"Rebinned 1D histogram and saved as '{output_name}' in '{directory_path}'.")
91  elif hist.GetDimension() == 2:
92  hist.RebinX(self.rebin_factor)
93  hist.RebinY(self.rebin_factor)
94  hist.SetName(output_name)
95  hist.Write(output_name, ROOT.TObject.kOverwrite)
96  logging.info(f"Rebinned 2D histogram and saved as '{output_name}' in '{directory_path}'.")
97  if self.delete_original:
98  find_histo(root_file, self.input, should_delete=True)
99 

◆ from_yaml()

def python.physvalPostProcessingTools.RebinningOperation.from_yaml (   fragment)
static

Definition at line 101 of file physvalPostProcessingTools.py.

101  def from_yaml(fragment):
102  return RebinningOperation(
103  input=fragment["input"],
104  output=fragment["output"],
105  rebin_factor=fragment["rebin"],
106  delete_original=fragment.get("delete_original", False)
107  )

Member Data Documentation

◆ delete_original

python.physvalPostProcessingTools.RebinningOperation.delete_original

Definition at line 70 of file physvalPostProcessingTools.py.

◆ input

python.physvalPostProcessingTools.RebinningOperation.input

Definition at line 67 of file physvalPostProcessingTools.py.

◆ output

python.physvalPostProcessingTools.RebinningOperation.output

Definition at line 68 of file physvalPostProcessingTools.py.

◆ rebin_factor

python.physvalPostProcessingTools.RebinningOperation.rebin_factor

Definition at line 69 of file physvalPostProcessingTools.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
python.physvalPostProcessingTools.ensure_directory_exists
def ensure_directory_exists(root_file, path)
— HELPER — ###
Definition: physvalPostProcessingTools.py:37
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.physvalPostProcessingTools.find_histo
def find_histo(root_file, path, should_delete=False)
— HELPER — ###
Definition: physvalPostProcessingTools.py:10
Trk::split
@ split
Definition: LayerMaterialProperties.h:38