ATLAS Offline Software
Loading...
Searching...
No Matches
RatesHistoBase Class Reference

Basic base class for any common functionality between RatesTrigger and RatesGroup This means that everyone has access to the same histograms. More...

#include <RatesHistoBase.h>

Inheritance diagram for RatesHistoBase:
Collaboration diagram for RatesHistoBase:

Public Member Functions

 RatesHistoBase (const std::string &name, IMessageSvc *msgSvc, const bool doHistograms=true)
virtual ~RatesHistoBase ()
 RatesHistoBase (const RatesHistoBase &)=delete
RatesHistoBaseoperator= (const RatesHistoBase &)=delete
StatusCode giveMuHist (const ServiceHandle< ITHistSvc > &svc, const std::string &name)
StatusCode giveTrainHist (const ServiceHandle< ITHistSvc > &svc, const std::string &name)
StatusCode giveDataHist (const ServiceHandle< ITHistSvc > &svc, const std::string &name)
void clearTrainHist ()
 In some jobs we don't want to do the rates vs.
TH1 * getDataHist ()
bool doHistograms () const
 If histogramming was enabled in this rates object.
const std::string & getExtrapolationFactorString (ExtrapStrat_t strat) const
double getExtrapolationFactor (const WeightingValuesSummary_t &weights, const ExtrapStrat_t strat) const
void setDataName (const std::string &newName)
void setRateVsMuName (const std::string &newName)
void setRateVsTrainName (const std::string &newName)
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static bool isZero (double v)
static bool isNotPositive (double v)

Protected Attributes

std::string m_name
 My name.
bool m_doHistograms
 If histogramming is switched on.
std::unique_ptr< TH1 > m_rateVsMu
 Histogram of rate as a fn.
std::unique_ptr< TH1 > m_rateVsTrain
 Histogram of rate as a fn.
std::unique_ptr< TH1 > m_data
 Histogram of raw rates quantites, for when we need to normalise offline (e.g.
TH1 * m_rateVsMuCachedPtr {}
 Cached, non-owning pointer.
TH1 * m_rateVsTrainCachedPtr {}
 Cached, non-owning pointer.
TH1 * m_dataCachedPtr {}
 Cached, non-owning pointer.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Basic base class for any common functionality between RatesTrigger and RatesGroup This means that everyone has access to the same histograms.

Definition at line 84 of file RatesHistoBase.h.

Constructor & Destructor Documentation

◆ RatesHistoBase() [1/2]

RatesHistoBase::RatesHistoBase ( const std::string & name,
IMessageSvc * msgSvc,
const bool doHistograms = true )

Definition at line 10 of file RatesHistoBase.cxx.

10 :
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}
@ kNRATES_BINS
Must always come last.
AthMessaging()
Default constructor:
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.
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.
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.

◆ ~RatesHistoBase()

RatesHistoBase::~RatesHistoBase ( )
virtual

Definition at line 43 of file RatesHistoBase.cxx.

43 {
44}

◆ RatesHistoBase() [2/2]

RatesHistoBase::RatesHistoBase ( const RatesHistoBase & )
delete

Member Function Documentation

◆ clearTrainHist()

void RatesHistoBase::clearTrainHist ( )

In some jobs we don't want to do the rates vs.

position in train

Definition at line 76 of file RatesHistoBase.cxx.

76 {
77 m_rateVsTrain.reset();
78 m_rateVsTrainCachedPtr = nullptr;
79}

◆ doHistograms()

bool RatesHistoBase::doHistograms ( ) const
inline

If histogramming was enabled in this rates object.

Definition at line 99 of file RatesHistoBase.h.

◆ getDataHist()

TH1 * RatesHistoBase::getDataHist ( )
Returns
cached, non-owning, histogram pointer or nullptr. Does not cause error

Definition at line 82 of file RatesHistoBase.cxx.

82 {
83 return m_dataCachedPtr; // Caller must be able to deal with nullptr (e.g unique rates groups calling on their trigger)
84}

◆ getExtrapolationFactor()

double RatesHistoBase::getExtrapolationFactor ( const WeightingValuesSummary_t & weights,
const ExtrapStrat_t strat ) const

Definition at line 96 of file RatesHistoBase.cxx.

96 {
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_MSG_ERROR(x)
@ 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.
const double m_noScaling
Weight for no scaling.
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_bunchFactor
What weight needs to be applied to extrapolate rates linear in number of bunches.

◆ getExtrapolationFactorString()

const std::string & RatesHistoBase::getExtrapolationFactorString ( ExtrapStrat_t strat) const

Definition at line 87 of file RatesHistoBase.cxx.

87 {
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}

◆ giveDataHist()

StatusCode RatesHistoBase::giveDataHist ( const ServiceHandle< ITHistSvc > & svc,
const std::string & name )

Definition at line 66 of file RatesHistoBase.cxx.

66 {
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
AthROOTErrorHandlerSvc * svc

◆ giveMuHist()

StatusCode RatesHistoBase::giveMuHist ( const ServiceHandle< ITHistSvc > & svc,
const std::string & name )

Definition at line 46 of file RatesHistoBase.cxx.

46 {
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}

◆ giveTrainHist()

StatusCode RatesHistoBase::giveTrainHist ( const ServiceHandle< ITHistSvc > & svc,
const std::string & name )

Definition at line 56 of file RatesHistoBase.cxx.

56 {
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}

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ isNotPositive()

bool RatesHistoBase::isNotPositive ( double v)
inlinestatic

Definition at line 104 of file RatesHistoBase.h.

104{ return v < std::numeric_limits<double>::min(); } //<! Helper fn to check if the value is non positive = trigger is disabled

◆ isZero()

bool RatesHistoBase::isZero ( double v)
inlinestatic

Definition at line 103 of file RatesHistoBase.h.

103{ return abs(v) < std::numeric_limits<double>::min(); } //<! Helper fn

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ operator=()

RatesHistoBase & RatesHistoBase::operator= ( const RatesHistoBase & )
delete

◆ setDataName()

void RatesHistoBase::setDataName ( const std::string & newName)

Definition at line 92 of file RatesHistoBase.cxx.

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setRateVsMuName()

void RatesHistoBase::setRateVsMuName ( const std::string & newName)

Definition at line 93 of file RatesHistoBase.cxx.

93{if (m_rateVsMu) m_rateVsMu->SetName(newName.c_str());}

◆ setRateVsTrainName()

void RatesHistoBase::setRateVsTrainName ( const std::string & newName)

Definition at line 94 of file RatesHistoBase.cxx.

94{if (m_rateVsTrain) m_rateVsTrain->SetName(newName.c_str());}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_data

std::unique_ptr<TH1> RatesHistoBase::m_data
protected

Histogram of raw rates quantites, for when we need to normalise offline (e.g.

grid processing)

Definition at line 115 of file RatesHistoBase.h.

◆ m_dataCachedPtr

TH1* RatesHistoBase::m_dataCachedPtr {}
protected

Cached, non-owning pointer.

Definition at line 118 of file RatesHistoBase.h.

118{};

◆ m_doHistograms

bool RatesHistoBase::m_doHistograms
protected

If histogramming is switched on.

Definition at line 112 of file RatesHistoBase.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_name

std::string RatesHistoBase::m_name
protected

My name.

Definition at line 111 of file RatesHistoBase.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_rateVsMu

std::unique_ptr<TH1> RatesHistoBase::m_rateVsMu
protected

Histogram of rate as a fn.

of the input event's mu

Definition at line 113 of file RatesHistoBase.h.

◆ m_rateVsMuCachedPtr

TH1* RatesHistoBase::m_rateVsMuCachedPtr {}
protected

Cached, non-owning pointer.

Definition at line 116 of file RatesHistoBase.h.

116{};

◆ m_rateVsTrain

std::unique_ptr<TH1> RatesHistoBase::m_rateVsTrain
protected

Histogram of rate as a fn.

of position in bunch train

Definition at line 114 of file RatesHistoBase.h.

◆ m_rateVsTrainCachedPtr

TH1* RatesHistoBase::m_rateVsTrainCachedPtr {}
protected

Cached, non-owning pointer.

Definition at line 117 of file RatesHistoBase.h.

117{};

The documentation for this class was generated from the following files: