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)
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 
44 }
45 
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 
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 
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 
77  m_rateVsTrain.reset();
78  m_rateVsTrainCachedPtr = nullptr;
79 }
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 
94  switch (strat) {
95  case kLINEAR: return weights.m_linearLumiFactor;
96  case kEXPO_MU: return weights.m_expoMuFactor;
97  case kBUNCH_SCALING: return weights.m_bunchFactor;
98  case kMU_SCALING: return weights.m_muFactor;
99  case kNONE: return weights.m_noScaling;
100  default: ATH_MSG_ERROR("Error in getExtrapolationFactor. Unknown ExtrapStrat_t ENUM supplied " << strat);
101  }
102  return 0.;
103 }
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:76
WeightingValuesSummary_t
Structure to hold per-event weights for distribution.
Definition: RatesHistoBase.h:55
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:56
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:82
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
RatesHistoBase::~RatesHistoBase
virtual ~RatesHistoBase()
Definition: RatesHistoBase.cxx:43
RatesHistoBase::getExtrapolationFactor
double getExtrapolationFactor(const WeightingValuesSummary_t &weights, const ExtrapStrat_t strat) const
Definition: RatesHistoBase.cxx:93
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:46
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:228
RatesHistoBase::giveDataHist
StatusCode giveDataHist(const ServiceHandle< ITHistSvc > &svc, const std::string &name)
Definition: RatesHistoBase.cxx:66
weights
Definition: herwig7_interface.h:38
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:87
kNONE
@ kNONE
Do not scale this trigger for changes in luminosity.
Definition: RatesHistoBase.h:35