ATLAS Offline Software
Loading...
Searching...
No Matches
python.physvalPostProcessingTools.ProjectionComputation Class Reference
Collaboration diagram for python.physvalPostProcessingTools.ProjectionComputation:

Public Member Functions

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

Static Public Member Functions

 from_yaml (fragment)

Public Attributes

 input_hist = input_hist
 bins_x = bins_x
 bins_y = bins_y
str x_proj = "x"
str y_proj = "y"
 output = output

Detailed Description

Definition at line 365 of file physvalPostProcessingTools.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 366 of file physvalPostProcessingTools.py.

366 def __init__(self, input_hist, bins_x, bins_y, projection_axis, output=None):
367 self.input_hist = input_hist
368 self.bins_x = bins_x
369 self.bins_y = bins_y
370 self.x_proj = projection_axis == "x"
371 self.y_proj = projection_axis == "y"
372 self.output = output
373

Member Function Documentation

◆ __call__()

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

Definition at line 374 of file physvalPostProcessingTools.py.

374 def __call__(self, root_file):
375 hist = find_histo(root_file, self.input_hist)
376 if not hist:
377 if crash_on_error:
378 raise RuntimeError(f"Histogram '{self.input_hist}' not found.")
379 else:
380 logging.error(f"Histogram '{self.input_hist}' not found.")
381 return
382
383 b1, b2 = hist.GetYaxis().FindBin(self.bins_x[0]), hist.GetYaxis().FindBin(self.bins_x[1])
384 b3, b4 = hist.GetXaxis().FindBin(self.bins_y[0]), hist.GetXaxis().FindBin(self.bins_y[1])
385
386 path_parts = self.output.strip("/").split("/")
387 *dir_path, output_name = path_parts
388 directory_path = "/".join(dir_path)
389 ensure_directory_exists(root_file, directory_path)
390 root_file.cd(directory_path)
391
392 if self.x_proj:
393 proj_x = hist.ProjectionX(output_name, b1, b2).Clone(output_name)
394 self.project(proj_x, hist.GetXaxis().GetTitle(), "X")
395 if self.y_proj:
396 proj_y = hist.ProjectionY(output_name, b3, b4).Clone(output_name)
397 self.project(proj_y, hist.GetYaxis().GetTitle(), "Y")
398
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179

◆ from_yaml()

python.physvalPostProcessingTools.ProjectionComputation.from_yaml ( fragment)
static

Definition at line 406 of file physvalPostProcessingTools.py.

406 def from_yaml(fragment):
407 return ProjectionComputation(
408 input_hist=fragment["hist"],
409 bins_x=fragment.get("bins_projection_x", [10, 200]),
410 bins_y=fragment.get("bins_projection_y", [-2.47, 2.47]),
411 projection_axis=fragment.get("projection_axis", "x"),
412 output=fragment.get("output")
413 )
414

◆ project()

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

Definition at line 399 of file physvalPostProcessingTools.py.

399 def project(self, projection, axis_title, axis):
400 projection.SetTitle(f";{axis_title};Entries")
401 projection.SetStats(False)
402 projection.Write()
403 logging.info(f"Saved projection by integrating over {axis} axis as '{projection.GetName()}'.")
404
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)

Member Data Documentation

◆ bins_x

python.physvalPostProcessingTools.ProjectionComputation.bins_x = bins_x

Definition at line 368 of file physvalPostProcessingTools.py.

◆ bins_y

python.physvalPostProcessingTools.ProjectionComputation.bins_y = bins_y

Definition at line 369 of file physvalPostProcessingTools.py.

◆ input_hist

python.physvalPostProcessingTools.ProjectionComputation.input_hist = input_hist

Definition at line 367 of file physvalPostProcessingTools.py.

◆ output

python.physvalPostProcessingTools.ProjectionComputation.output = output

Definition at line 372 of file physvalPostProcessingTools.py.

◆ x_proj

str python.physvalPostProcessingTools.ProjectionComputation.x_proj = "x"

Definition at line 370 of file physvalPostProcessingTools.py.

◆ y_proj

str python.physvalPostProcessingTools.ProjectionComputation.y_proj = "y"

Definition at line 371 of file physvalPostProcessingTools.py.


The documentation for this class was generated from the following file: