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

Public Member Functions

def __init__ (self, histogram_name)
 
def __call__ (self, root_file)
 

Static Public Member Functions

def from_yaml (fragment)
 

Public Attributes

 histogram_name
 

Private Member Functions

def _compute_s (self, hist, cum, prob)
 

Detailed Description

Definition at line 161 of file physvalPostProcessingTools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.physvalPostProcessingTools.ResolutionComputation.__init__ (   self,
  histogram_name 
)

Definition at line 163 of file physvalPostProcessingTools.py.

163  def __init__(self, histogram_name):
164  self.histogram_name = histogram_name
165 

Member Function Documentation

◆ __call__()

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

Definition at line 166 of file physvalPostProcessingTools.py.

166  def __call__(self, root_file):
167  hist = find_histo(root_file, self.histogram_name)
168  if not hist:
169  if crash_on_error:
170  raise RuntimeError(f"Histogram '{self.histogram_name}' not found.")
171  else:
172  logging.error(f"Histogram '{self.histogram_name}' not found.")
173  return
174 
175  # Step 1: Compute normalized cumulative sum
176  cum = [hist.GetBinContent(i) for i in range(0, hist.GetNbinsX() + 2)]
177  for i in range(1, len(cum)):
178  cum[i] += cum[i - 1]
179  total = cum[-1] or 1.0
180  cum = [x / total for x in cum]
181 
182  # Step 2: Compute smallest intervals
183  s68 = self._compute_s(hist, cum, 0.683)
184  s90 = self._compute_s(hist, cum, 0.90)
185 
186  logging.info(f"Resolution widths for {self.histogram_name} -> s68: {s68:.4f}, s90: {s90:.4f}")
187  logging.info("Todo: Take a 2D histo, take the quantity say xaxis, make its small intervals %s", "and then compute the Resolution widths and then save as a 1D histo with quantity on xaxis and Resolution widths on yaxis")
188 

◆ _compute_s()

def python.physvalPostProcessingTools.ResolutionComputation._compute_s (   self,
  hist,
  cum,
  prob 
)
private

Definition at line 189 of file physvalPostProcessingTools.py.

189  def _compute_s(self, hist, cum, prob):
190  # Compute the smallest interval that contains the given probability.
191  min_width = float("inf")
192  best = (0, 0)
193  for i in range(len(cum)):
194  target = cum[i] + prob
195  if target > 1:
196  break
197  for j in range(i + 1, len(cum)):
198  if cum[j] >= target:
199  width = hist.GetBinCenter(j) - hist.GetBinCenter(i)
200  if width < min_width:
201  min_width = width
202  best = (i, j)
203  break
204  return 0.5 * (hist.GetBinCenter(best[1]) - hist.GetBinCenter(best[0]))
205 

◆ from_yaml()

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

Definition at line 207 of file physvalPostProcessingTools.py.

207  def from_yaml(fragment):
208  return ResolutionComputation(
209  histogram_name=fragment["histogram"]
210  )
211 

Member Data Documentation

◆ histogram_name

python.physvalPostProcessingTools.ResolutionComputation.histogram_name

Definition at line 164 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
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.physvalPostProcessingTools.find_histo
def find_histo(root_file, path, should_delete=False)
— HELPER — ###
Definition: physvalPostProcessingTools.py:10
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65