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 288 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 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__()

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
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ from_yaml()

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()

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
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 291 of file physvalPostProcessingTools.py.

◆ bins_y

python.physvalPostProcessingTools.ProjectionComputation.bins_y = bins_y

Definition at line 292 of file physvalPostProcessingTools.py.

◆ input_hist

python.physvalPostProcessingTools.ProjectionComputation.input_hist = input_hist

Definition at line 290 of file physvalPostProcessingTools.py.

◆ output

python.physvalPostProcessingTools.ProjectionComputation.output = output

Definition at line 295 of file physvalPostProcessingTools.py.

◆ x_proj

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

Definition at line 293 of file physvalPostProcessingTools.py.

◆ y_proj

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

Definition at line 294 of file physvalPostProcessingTools.py.


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