ATLAS Offline Software
Loading...
Searching...
No Matches
RatesHistoBase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
24class ITHistSvc; // Forward
25
37
51
56 // Event property weights
58 double m_eventMu;
59 double m_eventLumi;
63 // Lumi weights
65 double m_muFactor;
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
85 public:
86
87 RatesHistoBase(const std::string& name, IMessageSvc* msgSvc, const bool doHistograms = true);
88 virtual ~RatesHistoBase();
89
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;
102
103 static bool isZero(double v) { return abs(v) < std::numeric_limits<double>::min(); } //<! Helper fn
104 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
105 void setDataName(const std::string& newName);
106 void setRateVsMuName(const std::string& newName);
107 void setRateVsTrainName(const std::string& newName);
108
109 protected:
110
111 std::string m_name;
113 std::unique_ptr<TH1> m_rateVsMu;
114 std::unique_ptr<TH1> m_rateVsTrain;
115 std::unique_ptr<TH1> m_data;
119};
120
121#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()