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

Public Member Functions

def __init__ (self, histo1, histo2, output, delete_inputs=False)
 
def __call__ (self, root_file)
 

Static Public Member Functions

def from_yaml (fragment)
 

Public Attributes

 histo1
 
 histo2
 
 output
 
 delete_inputs
 

Detailed Description

Definition at line 338 of file physvalPostProcessingTools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.physvalPostProcessingTools.HistogramAddition.__init__ (   self,
  histo1,
  histo2,
  output,
  delete_inputs = False 
)

Definition at line 339 of file physvalPostProcessingTools.py.

339  def __init__(self, histo1, histo2, output, delete_inputs=False):
340  self.histo1 = histo1
341  self.histo2 = histo2
342  self.output = output
343  self.delete_inputs = delete_inputs
344 

Member Function Documentation

◆ __call__()

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

Definition at line 345 of file physvalPostProcessingTools.py.

345  def __call__(self, root_file):
346  histo1 = find_histo(root_file, self.histo1)
347  histo2 = find_histo(root_file, self.histo2)
348  if not histo1 or not histo2:
349  if crash_on_error:
350  raise RuntimeError(f"Missing histograms: {self.histo1} or {self.histo2}")
351  else:
352  logging.error(f"Missing histograms: {self.histo1} or {self.histo2}")
353  return
354 
355  path_parts = self.output.strip("/").split("/")
356  *dir_path, output_name = path_parts
357  directory_path = "/".join(dir_path)
358  summed = histo1.Clone(output_name)
359  summed.Add(histo2)
360  ensure_directory_exists(root_file, directory_path)
361  root_file.cd(directory_path)
362  summed.Write(output_name, ROOT.TObject.kOverwrite)
363  logging.info(f"Saved added histogram '{output_name}' in '{directory_path}'.")
364  if self.delete_inputs:
365  # logging.info(f"Deleting input histograms '{self.histo1}' and '{self.histo2}' after addition.")
366  find_histo(root_file, self.histo1, should_delete=True)
367  find_histo(root_file, self.histo2, should_delete=True)
368 

◆ from_yaml()

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

Definition at line 370 of file physvalPostProcessingTools.py.

370  def from_yaml(fragment):
371  return HistogramAddition(
372  histo1=fragment["histo1_name"],
373  histo2=fragment["histo2_name"],
374  output=fragment["output"],
375  delete_inputs=fragment.get("delete_inputs", False)
376  )
377 

Member Data Documentation

◆ delete_inputs

python.physvalPostProcessingTools.HistogramAddition.delete_inputs

Definition at line 343 of file physvalPostProcessingTools.py.

◆ histo1

python.physvalPostProcessingTools.HistogramAddition.histo1

Definition at line 340 of file physvalPostProcessingTools.py.

◆ histo2

python.physvalPostProcessingTools.HistogramAddition.histo2

Definition at line 341 of file physvalPostProcessingTools.py.

◆ output

python.physvalPostProcessingTools.HistogramAddition.output

Definition at line 342 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