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

Public Member Functions

def __init__ (self, input_hist, bins_x, bins_y, projection_axis, output=None)
 
def __call__ (self, root_file)
 
def project (self, projection, axis_title, axis)
 

Static Public Member Functions

def from_yaml (fragment)
 

Public Attributes

 input_hist
 
 bins_x
 
 bins_y
 
 x_proj
 
 y_proj
 
 output
 

Detailed Description

Definition at line 288 of file physvalPostProcessingTools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.physvalPostProcessingTools.ProjectionComputation.__init__ (   self,
  input_hist,
  bins_x,
  bins_y,
  projection_axis,
  output = None 
)

Definition at line 289 of file physvalPostProcessingTools.py.

289  def __init__(self, input_hist, bins_x, bins_y, projection_axis, output=None):
290  self.input_hist = input_hist
291  self.bins_x = bins_x
292  self.bins_y = bins_y
293  self.x_proj = projection_axis == "x"
294  self.y_proj = projection_axis == "y"
295  self.output = output
296 

Member Function Documentation

◆ __call__()

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

Definition at line 297 of file physvalPostProcessingTools.py.

297  def __call__(self, root_file):
298  hist = find_histo(root_file, self.input_hist)
299  if not hist:
300  if crash_on_error:
301  raise RuntimeError(f"Histogram '{self.input_hist}' not found.")
302  else:
303  logging.error(f"Histogram '{self.input_hist}' not found.")
304  return
305 
306  b1, b2 = hist.GetYaxis().FindBin(self.bins_x[0]), hist.GetYaxis().FindBin(self.bins_x[1])
307  b3, b4 = hist.GetXaxis().FindBin(self.bins_y[0]), hist.GetXaxis().FindBin(self.bins_y[1])
308 
309  path_parts = self.output.strip("/").split("/")
310  *dir_path, output_name = path_parts
311  directory_path = "/".join(dir_path)
312  ensure_directory_exists(root_file, directory_path)
313  root_file.cd(directory_path)
314 
315  if self.x_proj:
316  proj_x = hist.ProjectionX(output_name, b1, b2).Clone(output_name)
317  self.project(proj_x, hist.GetXaxis().GetTitle(), "X")
318  if self.y_proj:
319  proj_y = hist.ProjectionY(output_name, b3, b4).Clone(output_name)
320  self.project(proj_y, hist.GetYaxis().GetTitle(), "Y")
321 

◆ from_yaml()

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

Definition at line 329 of file physvalPostProcessingTools.py.

329  def from_yaml(fragment):
330  return ProjectionComputation(
331  input_hist=fragment["hist"],
332  bins_x=fragment.get("bins_projection_x", [10, 200]),
333  bins_y=fragment.get("bins_projection_y", [-2.47, 2.47]),
334  projection_axis=fragment.get("projection_axis", "x"),
335  output=fragment.get("output")
336  )
337 

◆ project()

def python.physvalPostProcessingTools.ProjectionComputation.project (   self,
  projection,
  axis_title,
  axis 
)

Definition at line 322 of file physvalPostProcessingTools.py.

322  def project(self, projection, axis_title, axis):
323  projection.SetTitle(f";{axis_title};Entries")
324  projection.SetStats(False)
325  projection.Write()
326  logging.info(f"Saved projection by integrating over {axis} axis as '{projection.GetName()}'.")
327 

Member Data Documentation

◆ bins_x

python.physvalPostProcessingTools.ProjectionComputation.bins_x

Definition at line 291 of file physvalPostProcessingTools.py.

◆ bins_y

python.physvalPostProcessingTools.ProjectionComputation.bins_y

Definition at line 292 of file physvalPostProcessingTools.py.

◆ input_hist

python.physvalPostProcessingTools.ProjectionComputation.input_hist

Definition at line 290 of file physvalPostProcessingTools.py.

◆ output

python.physvalPostProcessingTools.ProjectionComputation.output

Definition at line 295 of file physvalPostProcessingTools.py.

◆ x_proj

python.physvalPostProcessingTools.ProjectionComputation.x_proj

Definition at line 293 of file physvalPostProcessingTools.py.

◆ y_proj

python.physvalPostProcessingTools.ProjectionComputation.y_proj

Definition at line 294 of file physvalPostProcessingTools.py.


The documentation for this class was generated from the following file:
RootHelpers::FindBin
Int_t FindBin(const TAxis *axis, const double x)
Definition: RootHelpers.cxx:14
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
project
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
Definition: MeasurementSelector.h:149
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