6 @file RatesScanTrigger.py
7 @brief Accumulator class to buffer data for a single scan trigger and export this to ROOT
10 from AthenaCommon.Logging
import logging
11 log = logging.getLogger(
'RatesScanTrigger')
15 """Apply pileup correction to cumulative histogram"""
17 BCR = metadata[
'bunchCrossingRate']
18 pileup = metadata[
'targetMu']
21 hist_pileup_corrected = hist_cumulative.Clone(f
"{hist_cumulative.GetName()}_pileup_corrected")
24 for bin
in range(1, hist_pileup_corrected.GetNbinsX() + 1):
25 bin_value = hist_cumulative.GetBinContent(bin)
26 P_scatter = bin_value / BCR / pileup
27 corrected_value = BCR * (1.0 -
pow(1.0 - P_scatter, pileup))
28 hist_pileup_corrected.SetBinContent(bin, corrected_value)
31 bin_error = hist_cumulative.GetBinError(bin)
33 error_scale = corrected_value / bin_value
34 hist_pileup_corrected.SetBinError(bin, bin_error * error_scale)
36 hist_pileup_corrected.SetBinError(bin, 0)
38 return hist_pileup_corrected
42 def __init__(self, name, metadata, numerators):
47 for key, histo
in numerators.items():
50 if metadata[
'multiSliceDiJet']:
51 denominator = metadata[
'n_evts_weighted'+key]
53 denominator = metadata[
'normalisation'+key]
55 log.error(f
"Key {key} not found in slice denominator dictionary")
56 histo.Scale(1/denominator)
67 exportdict[self.
name] = myDict