ATLAS Offline Software
Loading...
Searching...
No Matches
RatesHistoBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "GaudiKernel/ITHistSvc.h"
9
10RatesHistoBase::RatesHistoBase(const std::string& name, IMessageSvc* msgSvc, const bool doHistograms) :
11 AthMessaging(msgSvc, name),
12 m_name(name),
14{
15 if (doHistograms) {
16 m_rateVsMu = std::make_unique<TH1D>("",TString(name + ";#mu;Rate / Unit #mu [Hz]"),226,-.5,225.5);
17 m_rateVsMu->Sumw2(true);
18 m_rateVsMu->SetName("rateVsMu");
20
21 m_rateVsTrain = std::make_unique<TH1D>("",TString(name + ";Distance Into Train;Rate / BCID [Hz]"),100,-0.5,99.5);
22 m_rateVsTrain->Sumw2(true);
23 m_rateVsTrain->SetName("rateVsTrain");
25
26 m_data = std::make_unique<TH1D>("",TString(";Variable;Raw Data"), RatesBinIdentifier_t::kNRATES_BINS, -.5, RatesBinIdentifier_t::kNRATES_BINS - .5);
27 m_data->Sumw2(true);
28 m_data->SetName("data");
29 // Set bin labels based on RatesBinIdentifier_t
30 m_data->GetXaxis()->SetBinLabel(1, "Actve Raw");
31 m_data->GetXaxis()->SetBinLabel(2, "Active Weighted");
32 m_data->GetXaxis()->SetBinLabel(3, "Pass Raw");
33 m_data->GetXaxis()->SetBinLabel(4, "Pass Weighted OR");
34 m_data->GetXaxis()->SetBinLabel(5, "Pass Weighted AND");
35 m_data->GetXaxis()->SetBinLabel(6, "Express");
36 m_data->GetXaxis()->SetBinLabel(7, "Unique");
37 m_dataCachedPtr = m_data.get();
38
39 }
40}
41
42
45
46StatusCode RatesHistoBase::giveMuHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name) {
47 if (!m_rateVsMu.get()) {
48 ATH_MSG_ERROR("RatesHistoBase::giveMuHist Warning requested histograms when histograming is OFF here.");
49 return StatusCode::FAILURE;
50 }
51 ATH_CHECK( svc->regHist(name, std::move(m_rateVsMu)) );
52 return StatusCode::SUCCESS;
53}
54
55
56StatusCode RatesHistoBase::giveTrainHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name) {
57 if (!m_rateVsTrain.get()) {
58 ATH_MSG_ERROR("RatesHistoBase::giveTrainHist Warning requested histograms when histograming is OFF here.");
59 return StatusCode::FAILURE;
60 }
61 ATH_CHECK( svc->regHist(name, std::move(m_rateVsTrain)) );
62 return StatusCode::SUCCESS;
63}
64
65
66StatusCode RatesHistoBase::giveDataHist(const ServiceHandle<ITHistSvc>& svc, const std::string& name) {
67 if (!m_data.get()) {
68 ATH_MSG_ERROR("RatesHistoBase::giveDataHist Warning requested histograms when histograming is OFF here.");
69 return StatusCode::FAILURE;
70 }
71 ATH_CHECK( svc->regHist(name, std::move(m_data)) );
72 return StatusCode::SUCCESS;
73}
74
75
80
81
83 return m_dataCachedPtr; // Caller must be able to deal with nullptr (e.g unique rates groups calling on their trigger)
84}
85
86
88 static const std::vector<std::string> values{"LINEAR_L","LINEAR_BUNCH_EXPO_MU","LINEAR_BUNCHES","LINEAR_MU","NONE"};
89 return values.at(static_cast<size_t>(strat));
90}
91
92 void RatesHistoBase::setDataName(const std::string& newName){if (m_data) m_data->SetName(newName.c_str());}
93 void RatesHistoBase::setRateVsMuName(const std::string& newName){if (m_rateVsMu) m_rateVsMu->SetName(newName.c_str());}
94 void RatesHistoBase::setRateVsTrainName(const std::string& newName){if (m_rateVsTrain) m_rateVsTrain->SetName(newName.c_str());}
95
97 switch (strat) {
98 case kLINEAR: return weights.m_linearLumiFactor;
99 case kEXPO_MU: return weights.m_expoMuFactor;
100 case kBUNCH_SCALING: return weights.m_bunchFactor;
101 case kMU_SCALING: return weights.m_muFactor;
102 case kNONE: return weights.m_noScaling;
103 default: ATH_MSG_ERROR("Error in getExtrapolationFactor. Unknown ExtrapStrat_t ENUM supplied " << strat);
104 }
105 return 0.;
106}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
@ 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.
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)
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.
void setRateVsMuName(const std::string &newName)
std::unique_ptr< TH1 > m_rateVsTrain
Histogram of rate as a fn.
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.