ATLAS Offline Software
RatesHistoBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef RATESANALYSIS_RATESHISTOBASE_H
6 #define RATESANALYSIS_RATESHISTOBASE_H 1
7 
8 #include "TH1.h"
9 #include "TString.h"
10 
11 #include "GaudiKernel/ServiceHandle.h"
12 
14 
15 #include <string>
16 #include <unordered_map>
17 #include <set>
18 #include <sstream>
19 #include <math.h>
20 #include <iostream>
21 #include <iomanip>
22 #include <memory>
23 
24 class ITHistSvc; // Forward
25 
35  kNONE
36 };
37 
50 };
51 
56  // Event property weights
58  double m_eventMu;
59  double m_eventLumi;
60  bool m_isUnbiased;
62  double m_eventLiveTime;
63  // Lumi weights
64  double m_bunchFactor;
65  double m_muFactor;
67  double m_expoMuFactor;
68  const double m_noScaling = 1.;
69  const std::string print() {
70  std::stringstream ss;
71  ss << "WeightSummary: wEB:" << m_enhancedBiasWeight << " mu:" << m_eventMu << " lumi:" << m_eventLumi;
72  ss << " isUnbiased:" << m_isUnbiased << " distanceInTrain:" << m_distanceInTrain;
73  ss << " liveTime:" << m_eventLiveTime;
74  ss << " lwBunch:" << m_bunchFactor << " lwMu:" << m_muFactor;
75  ss << " lwExpoMu:" << m_expoMuFactor << " lwLin:" << m_linearLumiFactor;
76  return ss.str();
77  }
78 };
79 
84 class RatesHistoBase : public AthMessaging {
85  public:
86 
87  RatesHistoBase(const std::string& name, IMessageSvc* msgSvc, const bool doHistograms = true);
88  virtual ~RatesHistoBase();
89 
90  RatesHistoBase(const RatesHistoBase&) = delete;
91 
93 
94  StatusCode giveMuHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name);
95  StatusCode giveTrainHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name);
96  StatusCode giveDataHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name);
97  void clearTrainHist();
98  TH1* getDataHist();
99  bool doHistograms() const { return m_doHistograms; }
100  const std::string& getExtrapolationFactorString(ExtrapStrat_t strat) const;
101  double getExtrapolationFactor(const WeightingValuesSummary_t& weights, const ExtrapStrat_t strat) const;
102 
103  static bool isZero(double v) { return fabs(v) < 1e-10; } //<! Helper fn
104  static bool isNotPositive(double v) { return v < 1e-10; } //<! Helper fn to check if the value is non positive = trigger is disabled
105 
106  protected:
107 
108  std::string m_name;
110  std::unique_ptr<TH1> m_rateVsMu;
111  std::unique_ptr<TH1> m_rateVsTrain;
112  std::unique_ptr<TH1> m_data;
118  bool m_givenData;
119 };
120 
121 #endif //> !RATESANALYSIS_RATESHISTOBASE_H
RatesHistoBase::m_givenRateVsTrain
bool m_givenRateVsTrain
m_rateVsTrain has been given to the THistSvc and should not be deleted
Definition: RatesHistoBase.h:117
WeightingValuesSummary_t::m_eventLiveTime
double m_eventLiveTime
How much wall-time at P1 did this event represent.
Definition: RatesHistoBase.h:62
kACTIVE_RAW_BIN
@ kACTIVE_RAW_BIN
Bin used to store the raw total events in which the trigger was active.
Definition: RatesHistoBase.h:42
kUNIQUE_BIN
@ kUNIQUE_BIN
Bin used to store data needed to get the unique rate.
Definition: RatesHistoBase.h:48
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
RatesHistoBase::m_dataCachedPtr
TH1 * m_dataCachedPtr
Cached, non-owning pointer.
Definition: RatesHistoBase.h:115
RatesHistoBase::clearTrainHist
void clearTrainHist()
In some jobs we don't want to do the rates vs.
Definition: RatesHistoBase.cxx:78
WeightingValuesSummary_t
Structure to hold per-event weights for distribution.
Definition: RatesHistoBase.h:55
RatesHistoBase::m_givenData
bool m_givenData
m_data has been given to the THistSvc and should not be deleted
Definition: RatesHistoBase.h:118
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
WeightingValuesSummary_t::m_isUnbiased
bool m_isUnbiased
If the event was taken online with a RD trigger.
Definition: RatesHistoBase.h:60
WeightingValuesSummary_t::m_eventLumi
double m_eventLumi
The instantaneous lumi in cm-2s-1.
Definition: RatesHistoBase.h:59
WeightingValuesSummary_t::print
const std::string print()
Definition: RatesHistoBase.h:69
WeightingValuesSummary_t::m_linearLumiFactor
double m_linearLumiFactor
What weight needs to be applied to extrapolate rates linear in mu and bunches.
Definition: RatesHistoBase.h:66
WeightingValuesSummary_t::m_distanceInTrain
uint32_t m_distanceInTrain
How far into the bunch train the event was, in bunch crossings.
Definition: RatesHistoBase.h:61
kMU_SCALING
@ kMU_SCALING
Scale trigger linearly but only in the change in <mu>
Definition: RatesHistoBase.h:34
RatesHistoBase::giveTrainHist
StatusCode giveTrainHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
Definition: RatesHistoBase.cxx:58
RatesHistoBase::m_doHistograms
bool m_doHistograms
If histogramming is switched on.
Definition: RatesHistoBase.h:109
RatesHistoBase::operator=
RatesHistoBase & operator=(const RatesHistoBase &)=delete
RatesHistoBase::isNotPositive
static bool isNotPositive(double v)
Definition: RatesHistoBase.h:104
ExtrapStrat_t
ExtrapStrat_t
Extrapolation strategy to apply to each emulated trigger.
Definition: RatesHistoBase.h:30
kPASS_WEIGHTED_OR_BIN
@ kPASS_WEIGHTED_OR_BIN
Bin used to store the total rate (OR)
Definition: RatesHistoBase.h:45
WeightingValuesSummary_t::m_enhancedBiasWeight
double m_enhancedBiasWeight
A property of the event derived from online enhanced bias prescales.
Definition: RatesHistoBase.h:57
kLINEAR
@ kLINEAR
Scale trigger linearly with luminosity.
Definition: RatesHistoBase.h:31
RatesHistoBase::RatesHistoBase
RatesHistoBase(const RatesHistoBase &)=delete
RatesHistoBase::getDataHist
TH1 * getDataHist()
Definition: RatesHistoBase.cxx:84
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
RatesHistoBase::~RatesHistoBase
virtual ~RatesHistoBase()
Definition: RatesHistoBase.cxx:44
RatesHistoBase::m_data
std::unique_ptr< TH1 > m_data
Histogram of raw rates quantites, for when we need to normalise offline (e.g.
Definition: RatesHistoBase.h:112
RatesHistoBase::getExtrapolationFactor
double getExtrapolationFactor(const WeightingValuesSummary_t &weights, const ExtrapStrat_t strat) const
Definition: RatesHistoBase.cxx:95
kEXPO_MU
@ kEXPO_MU
Scale trigger linearly in bunches and exponentially in mu.
Definition: RatesHistoBase.h:32
RatesHistoBase::m_rateVsMu
std::unique_ptr< TH1 > m_rateVsMu
Histogram of rate as a fn.
Definition: RatesHistoBase.h:110
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
RatesHistoBase::m_rateVsTrain
std::unique_ptr< TH1 > m_rateVsTrain
Histogram of rate as a fn.
Definition: RatesHistoBase.h:111
kBUNCH_SCALING
@ kBUNCH_SCALING
Scale trigger linearly but only in the number of bunches.
Definition: RatesHistoBase.h:33
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
WeightingValuesSummary_t::m_expoMuFactor
double m_expoMuFactor
What weight needs to be applied to extrapolate rates linear in bunches and exponential in mu.
Definition: RatesHistoBase.h:67
RatesHistoBase::giveMuHist
StatusCode giveMuHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
Definition: RatesHistoBase.cxx:47
kEXPRESS_BIN
@ kEXPRESS_BIN
Bin used to store the express rate.
Definition: RatesHistoBase.h:47
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
RatesHistoBase::m_rateVsTrainCachedPtr
TH1 * m_rateVsTrainCachedPtr
Cached, non-owning pointer.
Definition: RatesHistoBase.h:114
RatesHistoBase::RatesHistoBase
RatesHistoBase(const std::string &name, IMessageSvc *msgSvc, const bool doHistograms=true)
Definition: RatesHistoBase.cxx:10
RatesHistoBase::m_rateVsMuCachedPtr
TH1 * m_rateVsMuCachedPtr
Cached, non-owning pointer.
Definition: RatesHistoBase.h:113
WeightingValuesSummary_t::m_bunchFactor
double m_bunchFactor
What weight needs to be applied to extrapolate rates linear in number of bunches.
Definition: RatesHistoBase.h:64
kPASS_WEIGHTED_AND_BIN
@ kPASS_WEIGHTED_AND_BIN
Bin used to store the total rate (AND)
Definition: RatesHistoBase.h:46
RatesHistoBase
Basic base class for any common functionality between RatesTrigger and RatesGroup This means that eve...
Definition: RatesHistoBase.h:84
RatesHistoBase::m_name
std::string m_name
My name.
Definition: RatesHistoBase.h:108
RatesHistoBase::isZero
static bool isZero(double v)
Definition: RatesHistoBase.h:103
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
RatesHistoBase::giveDataHist
StatusCode giveDataHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
Definition: RatesHistoBase.cxx:68
python.PyAthena.v
v
Definition: PyAthena.py:157
RatesHistoBase::doHistograms
bool doHistograms() const
If histogramming was enabled in this rates object.
Definition: RatesHistoBase.h:99
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
kNRATES_BINS
@ kNRATES_BINS
Must always come last.
Definition: RatesHistoBase.h:49
TH1
Definition: rootspy.cxx:268
AthMessaging.h
kPASS_RAW_BIN
@ kPASS_RAW_BIN
Bin used to store the raw total events in which the trigger passed.
Definition: RatesHistoBase.h:44
WeightingValuesSummary_t::m_muFactor
double m_muFactor
What weight needs to be applied to extrapolate rates linear in mu.
Definition: RatesHistoBase.h:65
kACTIVE_WEIGHTED_BIN
@ kACTIVE_WEIGHTED_BIN
Bin used to store the weighted events in which the trigger was active.
Definition: RatesHistoBase.h:43
RatesBinIdentifier_t
RatesBinIdentifier_t
Lables a bin in a histogram.
Definition: RatesHistoBase.h:41
RatesHistoBase::m_givenRateVsMu
bool m_givenRateVsMu
m_rateVsMu has been given to the THistSvc and should not be deleted
Definition: RatesHistoBase.h:116
ServiceHandle< ITHistSvc >
RatesHistoBase::getExtrapolationFactorString
const std::string & getExtrapolationFactorString(ExtrapStrat_t strat) const
Definition: RatesHistoBase.cxx:89
kNONE
@ kNONE
Do not scale this trigger for changes in luminosity.
Definition: RatesHistoBase.h:35
WeightingValuesSummary_t::m_noScaling
const double m_noScaling
Weight for no scaling.
Definition: RatesHistoBase.h:68
WeightingValuesSummary_t::m_eventMu
double m_eventMu
The actual number of interactions in the event.
Definition: RatesHistoBase.h:58