ATLAS Offline Software
Loading...
Searching...
No Matches
RatesHistoBase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 <cmath>
20#include <iostream>
21#include <iomanip>
22#include <memory>
23#include <limits>
24
25class ITHistSvc; // Forward
26
38
52
57 // Event property weights
59 double m_eventMu{};
60 double m_eventLumi{};
61 bool m_isUnbiased{};
62 uint32_t m_distanceInTrain{};
63 double m_eventLiveTime{};
64 // Lumi weights
65 double m_bunchFactor{};
66 double m_muFactor{};
68 double m_expoMuFactor{};
69 const double m_noScaling = 1.;
70 const std::string print() {
71 std::stringstream ss;
72 ss << "WeightSummary: wEB:" << m_enhancedBiasWeight << " mu:" << m_eventMu << " lumi:" << m_eventLumi;
73 ss << " isUnbiased:" << m_isUnbiased << " distanceInTrain:" << m_distanceInTrain;
74 ss << " liveTime:" << m_eventLiveTime;
75 ss << " lwBunch:" << m_bunchFactor << " lwMu:" << m_muFactor;
76 ss << " lwExpoMu:" << m_expoMuFactor << " lwLin:" << m_linearLumiFactor;
77 return ss.str();
78 }
79};
80
86 public:
87
88 RatesHistoBase(const std::string& name, IMessageSvc* msgSvc, const bool doHistograms = true);
89 virtual ~RatesHistoBase();
90
92
94
95 StatusCode giveMuHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name);
96 StatusCode giveTrainHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name);
97 StatusCode giveDataHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name);
98 void clearTrainHist();
99 TH1* getDataHist();
100 bool doHistograms() const { return m_doHistograms; }
101 const std::string& getExtrapolationFactorString(ExtrapStrat_t strat) const;
103
104 static bool isZero(double v) { return std::abs(v) < std::numeric_limits<double>::min(); } //<! Helper fn
105 static bool isNotPositive(double v) { return v < std::numeric_limits<double>::min(); } //<! Helper fn to check if the value is non positive = trigger is disabled
106 void setDataName(const std::string& newName);
107 void setRateVsMuName(const std::string& newName);
108 void setRateVsTrainName(const std::string& newName);
109
110 protected:
111
112 std::string m_name;
114 std::unique_ptr<TH1> m_rateVsMu;
115 std::unique_ptr<TH1> m_rateVsTrain;
116 std::unique_ptr<TH1> m_data;
120};
121
122#endif //> !RATESANALYSIS_RATESHISTOBASE_H
static Double_t ss
RatesBinIdentifier_t
Lables a bin in a histogram.
@ kPASS_RAW_BIN
Bin used to store the raw total events in which the trigger passed.
@ kEXPRESS_BIN
Bin used to store the express rate.
@ kPASS_WEIGHTED_AND_BIN
Bin used to store the total rate (AND).
@ kPASS_WEIGHTED_OR_BIN
Bin used to store the total rate (OR).
@ kACTIVE_RAW_BIN
Bin used to store the raw total events in which the trigger was active.
@ kACTIVE_WEIGHTED_BIN
Bin used to store the weighted events in which the trigger was active.
@ kUNIQUE_BIN
Bin used to store data needed to get the unique rate.
@ kNRATES_BINS
Must always come last.
ExtrapStrat_t
Extrapolation strategy to apply to each emulated trigger.
@ kMU_SCALING
Scale trigger linearly but only in the change in <mu>.
@ kBUNCH_SCALING
Scale trigger linearly but only in the number of bunches.
@ kLINEAR
Scale trigger linearly with luminosity.
@ kNONE
Do not scale this trigger for changes in luminosity.
@ kEXPO_MU
Scale trigger linearly in bunches and exponentially in mu.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
const std::string & getExtrapolationFactorString(ExtrapStrat_t strat) const
void setDataName(const std::string &newName)
double getExtrapolationFactor(const WeightingValuesSummary_t &weights, const ExtrapStrat_t strat) const
void setRateVsTrainName(const std::string &newName)
void clearTrainHist()
In some jobs we don't want to do the rates vs.
RatesHistoBase & operator=(const RatesHistoBase &)=delete
StatusCode giveDataHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
std::unique_ptr< TH1 > m_rateVsMu
Histogram of rate as a fn.
bool doHistograms() const
If histogramming was enabled in this rates object.
TH1 * m_rateVsTrainCachedPtr
Cached, non-owning pointer.
RatesHistoBase(const std::string &name, IMessageSvc *msgSvc, const bool doHistograms=true)
virtual ~RatesHistoBase()
StatusCode giveTrainHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
RatesHistoBase(const RatesHistoBase &)=delete
StatusCode giveMuHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
TH1 * m_rateVsMuCachedPtr
Cached, non-owning pointer.
std::unique_ptr< TH1 > m_data
Histogram of raw rates quantites, for when we need to normalise offline (e.g.
static bool isNotPositive(double v)
void setRateVsMuName(const std::string &newName)
std::unique_ptr< TH1 > m_rateVsTrain
Histogram of rate as a fn.
static bool isZero(double v)
bool m_doHistograms
If histogramming is switched on.
TH1 * m_dataCachedPtr
Cached, non-owning pointer.
std::string m_name
My name.
Structure to hold per-event weights for distribution.
double m_enhancedBiasWeight
A property of the event derived from online enhanced bias prescales.
bool m_isUnbiased
If the event was taken online with a RD trigger.
uint32_t m_distanceInTrain
How far into the bunch train the event was, in bunch crossings.
double m_eventLumi
The instantaneous lumi in cm-2s-1.
const double m_noScaling
Weight for no scaling.
double m_eventMu
The actual number of interactions in the event.
double m_muFactor
What weight needs to be applied to extrapolate rates linear in mu.
double m_expoMuFactor
What weight needs to be applied to extrapolate rates linear in bunches and exponential in mu.
double m_linearLumiFactor
What weight needs to be applied to extrapolate rates linear in mu and bunches.
double m_eventLiveTime
How much wall-time at P1 did this event represent.
double m_bunchFactor
What weight needs to be applied to extrapolate rates linear in number of bunches.
const std::string print()