ATLAS Offline Software
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 
10 RatesHistoBase::RatesHistoBase(const std::string& name, IMessageSvc* msgSvc, const bool doHistograms) :
12  m_name(name),
13  m_doHistograms(doHistograms), m_rateVsMu(nullptr), m_rateVsTrain(nullptr), m_data(nullptr),
14  m_rateVsMuCachedPtr(nullptr), m_rateVsTrainCachedPtr(nullptr), m_dataCachedPtr(nullptr)
15 {
16  if (doHistograms) {
17  m_rateVsMu = std::make_unique<TH1D>("",TString(name + ";#mu;Rate / Unit #mu [Hz]"),226,-.5,225.5);
18  m_rateVsMu->Sumw2(true);
19  m_rateVsMu->SetName("rateVsMu");
21 
22  m_rateVsTrain = std::make_unique<TH1D>("",TString(name + ";Distance Into Train;Rate / BCID [Hz]"),100,-0.5,99.5);
23  m_rateVsTrain->Sumw2(true);
24  m_rateVsTrain->SetName("rateVsTrain");
26 
27  m_data = std::make_unique<TH1D>("",TString(";Variable;Raw Data"), RatesBinIdentifier_t::kNRATES_BINS, -.5, RatesBinIdentifier_t::kNRATES_BINS - .5);
28  m_data->Sumw2(true);
29  m_data->SetName("data");
30  // Set bin labels based on RatesBinIdentifier_t
31  m_data->GetXaxis()->SetBinLabel(1, "Actve Raw");
32  m_data->GetXaxis()->SetBinLabel(2, "Active Weighted");
33  m_data->GetXaxis()->SetBinLabel(3, "Pass Raw");
34  m_data->GetXaxis()->SetBinLabel(4, "Pass Weighted OR");
35  m_data->GetXaxis()->SetBinLabel(5, "Pass Weighted AND");
36  m_data->GetXaxis()->SetBinLabel(6, "Express");
37  m_data->GetXaxis()->SetBinLabel(7, "Unique");
38  m_dataCachedPtr = m_data.get();
39 
40  }
41 }
42 
43 
45 }
46 
48  if (!m_rateVsMu.get()) {
49  ATH_MSG_ERROR("RatesHistoBase::giveMuHist Warning requested histograms when histograming is OFF here.");
50  return StatusCode::FAILURE;
51  }
52  ATH_CHECK( svc->regHist(name, std::move(m_rateVsMu)) );
53  return StatusCode::SUCCESS;
54 }
55 
56 
58  if (!m_rateVsTrain.get()) {
59  ATH_MSG_ERROR("RatesHistoBase::giveTrainHist Warning requested histograms when histograming is OFF here.");
60  return StatusCode::FAILURE;
61  }
62  ATH_CHECK( svc->regHist(name, std::move(m_rateVsTrain)) );
63  return StatusCode::SUCCESS;
64 }
65 
66 
68  if (!m_data.get()) {
69  ATH_MSG_ERROR("RatesHistoBase::giveDataHist Warning requested histograms when histograming is OFF here.");
70  return StatusCode::FAILURE;
71  }
72  ATH_CHECK( svc->regHist(name, std::move(m_data)) );
73  return StatusCode::SUCCESS;
74 }
75 
76 
78  m_rateVsTrain.reset();
79  m_rateVsTrainCachedPtr = nullptr;
80 }
81 
82 
84  return m_dataCachedPtr; // Caller must be able to deal with nullptr (e.g unique rates groups calling on their trigger)
85 }
86 
87 
89  static const std::vector<std::string> values{"LINEAR_L","LINEAR_BUNCH_EXPO_MU","LINEAR_BUNCHES","LINEAR_MU","NONE"};
90  return values.at(static_cast<size_t>(strat));
91 }
92 
93 
95  switch (strat) {
96  case kLINEAR: return weights.m_linearLumiFactor;
97  case kEXPO_MU: return weights.m_expoMuFactor;
98  case kBUNCH_SCALING: return weights.m_bunchFactor;
99  case kMU_SCALING: return weights.m_muFactor;
100  case kNONE: return weights.m_noScaling;
101  default: ATH_MSG_ERROR("Error in getExtrapolationFactor. Unknown ExtrapStrat_t ENUM supplied " << strat);
102  }
103  return 0.;
104 }
RatesHistoBase::m_dataCachedPtr
TH1 * m_dataCachedPtr
Cached, non-owning pointer.
Definition: RatesHistoBase.h:115
AthCheckMacros.h
RatesHistoBase::clearTrainHist
void clearTrainHist()
In some jobs we don't want to do the rates vs.
Definition: RatesHistoBase.cxx:77
WeightingValuesSummary_t
Structure to hold per-event weights for distribution.
Definition: RatesHistoBase.h:55
m_data
std::vector< T > m_data
Definition: TrackTruthMatchingBaseAlg.cxx:660
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:57
ExtrapStrat_t
ExtrapStrat_t
Extrapolation strategy to apply to each emulated trigger.
Definition: RatesHistoBase.h:30
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
kLINEAR
@ kLINEAR
Scale trigger linearly with luminosity.
Definition: RatesHistoBase.h:31
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RatesHistoBase::getDataHist
TH1 * getDataHist()
Definition: RatesHistoBase.cxx:83
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
RatesHistoBase::~RatesHistoBase
virtual ~RatesHistoBase()
Definition: RatesHistoBase.cxx:44
RatesHistoBase::getExtrapolationFactor
double getExtrapolationFactor(const WeightingValuesSummary_t &weights, const ExtrapStrat_t strat) const
Definition: RatesHistoBase.cxx:94
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
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
RatesHistoBase.h
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
RatesHistoBase::giveMuHist
StatusCode giveMuHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
Definition: RatesHistoBase.cxx: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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RatesHistoBase::giveDataHist
StatusCode giveDataHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
Definition: RatesHistoBase.cxx:67
weights
Definition: herwig7_interface.h:44
RatesHistoBase::doHistograms
bool doHistograms() const
If histogramming was enabled in this rates object.
Definition: RatesHistoBase.h:99
kNRATES_BINS
@ kNRATES_BINS
Must always come last.
Definition: RatesHistoBase.h:49
ServiceHandle< ITHistSvc >
RatesHistoBase::getExtrapolationFactorString
const std::string & getExtrapolationFactorString(ExtrapStrat_t strat) const
Definition: RatesHistoBase.cxx:88
kNONE
@ kNONE
Do not scale this trigger for changes in luminosity.
Definition: RatesHistoBase.h:35