ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
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. More...
 
TH1getDataHist ()
 
bool doHistograms () const
 If histogramming was enabled in this rates object. More...
 
const std::string & getExtrapolationFactorString (ExtrapStrat_t strat) const
 
double getExtrapolationFactor (const WeightingValuesSummary_t &weights, const ExtrapStrat_t strat) const
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Static Public Member Functions

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

Protected Attributes

std::string m_name
 My name. More...
 
bool m_doHistograms
 If histogramming is switched on. More...
 
std::unique_ptr< TH1m_rateVsMu
 Histogram of rate as a fn. More...
 
std::unique_ptr< TH1m_rateVsTrain
 Histogram of rate as a fn. More...
 
std::unique_ptr< TH1m_data
 Histogram of raw rates quantites, for when we need to normalise offline (e.g. More...
 
TH1m_rateVsMuCachedPtr
 Cached, non-owning pointer. More...
 
TH1m_rateVsTrainCachedPtr
 Cached, non-owning pointer. More...
 
TH1m_dataCachedPtr
 Cached, non-owning pointer. More...
 
bool m_givenRateVsMu
 m_rateVsMu has been given to the THistSvc and should not be deleted More...
 
bool m_givenRateVsTrain
 m_rateVsTrain has been given to the THistSvc and should not be deleted More...
 
bool m_givenData
 m_data has been given to the THistSvc and should not be deleted More...
 

Private Member Functions

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

Private Attributes

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

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  :
12  m_name(name),
13  m_doHistograms(doHistograms), m_rateVsMu(nullptr), m_rateVsTrain(nullptr), m_data(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 }

◆ ~RatesHistoBase()

RatesHistoBase::~RatesHistoBase ( )
virtual

Definition at line 44 of file RatesHistoBase.cxx.

44  {
45 }

◆ 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 78 of file RatesHistoBase.cxx.

78  {
79  m_rateVsTrain.reset();
80  m_rateVsTrainCachedPtr = nullptr;
81 }

◆ 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 84 of file RatesHistoBase.cxx.

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

◆ getExtrapolationFactor()

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

Definition at line 95 of file RatesHistoBase.cxx.

95  {
96  switch (strat) {
97  case kLINEAR: return weights.m_linearLumiFactor;
98  case kEXPO_MU: return weights.m_expoMuFactor;
99  case kBUNCH_SCALING: return weights.m_bunchFactor;
100  case kMU_SCALING: return weights.m_muFactor;
101  case kNONE: return weights.m_noScaling;
102  default: ATH_MSG_ERROR("Error in getExtrapolationFactor. Unknown ExtrapStrat_t ENUM supplied " << strat);
103  }
104  return 0.;
105 }

◆ getExtrapolationFactorString()

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

Definition at line 89 of file RatesHistoBase.cxx.

89  {
90  static const std::vector<std::string> values{"LINEAR_L","LINEAR_BUNCH_EXPO_MU","LINEAR_BUNCHES","LINEAR_MU","NONE"};
91  return values.at(static_cast<size_t>(strat));
92 }

◆ giveDataHist()

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

Definition at line 68 of file RatesHistoBase.cxx.

68  {
69  if (!m_data.get()) {
70  ATH_MSG_ERROR("RatesHistoBase::giveDataHist Warning requested histograms when histograming is OFF here.");
71  return StatusCode::FAILURE;
72  }
73  ATH_CHECK( svc->regHist(name, std::move(m_data), m_dataCachedPtr) );
74  return StatusCode::SUCCESS;
75 }

◆ giveMuHist()

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

Definition at line 47 of file RatesHistoBase.cxx.

47  {
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), m_rateVsMuCachedPtr) );
53  ATH_MSG_DEBUG("For " << m_name << "(" << this << ") m_rateVsMuCachedPtr is updated to " << (uint64_t) m_rateVsMuCachedPtr);
54  return StatusCode::SUCCESS;
55 }

◆ giveTrainHist()

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

Definition at line 58 of file RatesHistoBase.cxx.

58  {
59  if (!m_rateVsTrain.get()) {
60  ATH_MSG_ERROR("RatesHistoBase::giveTrainHist Warning requested histograms when histograming is OFF here.");
61  return StatusCode::FAILURE;
62  }
63  ATH_CHECK( svc->regHist(name, std::move(m_rateVsTrain), m_rateVsTrainCachedPtr) );
64  return StatusCode::SUCCESS;
65 }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ isNotPositive()

static bool RatesHistoBase::isNotPositive ( double  v)
inlinestatic

Definition at line 104 of file RatesHistoBase.h.

104 { return v < 1e-10; } //<! Helper fn to check if the value is non positive = trigger is disabled

◆ isZero()

static bool RatesHistoBase::isZero ( double  v)
inlinestatic

Definition at line 103 of file RatesHistoBase.h.

103 { return fabs(v) < 1e-10; } //<! 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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ operator=()

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

◆ 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 }

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 112 of file RatesHistoBase.h.

◆ m_dataCachedPtr

TH1* RatesHistoBase::m_dataCachedPtr
protected

Cached, non-owning pointer.

Definition at line 115 of file RatesHistoBase.h.

◆ m_doHistograms

bool RatesHistoBase::m_doHistograms
protected

If histogramming is switched on.

Definition at line 109 of file RatesHistoBase.h.

◆ m_givenData

bool RatesHistoBase::m_givenData
protected

m_data has been given to the THistSvc and should not be deleted

Definition at line 118 of file RatesHistoBase.h.

◆ m_givenRateVsMu

bool RatesHistoBase::m_givenRateVsMu
protected

m_rateVsMu has been given to the THistSvc and should not be deleted

Definition at line 116 of file RatesHistoBase.h.

◆ m_givenRateVsTrain

bool RatesHistoBase::m_givenRateVsTrain
protected

m_rateVsTrain has been given to the THistSvc and should not be deleted

Definition at line 117 of file RatesHistoBase.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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 108 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 110 of file RatesHistoBase.h.

◆ m_rateVsMuCachedPtr

TH1* RatesHistoBase::m_rateVsMuCachedPtr
protected

Cached, non-owning pointer.

Definition at line 113 of file RatesHistoBase.h.

◆ m_rateVsTrain

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

Histogram of rate as a fn.

of position in bunch train

Definition at line 111 of file RatesHistoBase.h.

◆ m_rateVsTrainCachedPtr

TH1* RatesHistoBase::m_rateVsTrainCachedPtr
protected

Cached, non-owning pointer.

Definition at line 114 of file RatesHistoBase.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
RatesHistoBase::m_dataCachedPtr
TH1 * m_dataCachedPtr
Cached, non-owning pointer.
Definition: RatesHistoBase.h:115
WeightingValuesSummary_t::m_linearLumiFactor
double m_linearLumiFactor
What weight needs to be applied to extrapolate rates linear in mu and bunches.
Definition: RatesHistoBase.h:66
kMU_SCALING
@ kMU_SCALING
Scale trigger linearly but only in the change in <mu>
Definition: RatesHistoBase.h:34
RatesHistoBase::m_doHistograms
bool m_doHistograms
If histogramming is switched on.
Definition: RatesHistoBase.h:109
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
kLINEAR
@ kLINEAR
Scale trigger linearly with luminosity.
Definition: RatesHistoBase.h:31
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
RatesHistoBase::m_rateVsTrain
std::unique_ptr< TH1 > m_rateVsTrain
Histogram of rate as a fn.
Definition: RatesHistoBase.h:111
kBUNCH_SCALING
@ kBUNCH_SCALING
Scale trigger linearly but only in the number of bunches.
Definition: RatesHistoBase.h:33
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WeightingValuesSummary_t::m_expoMuFactor
double m_expoMuFactor
What weight needs to be applied to extrapolate rates linear in bunches and exponential in mu.
Definition: RatesHistoBase.h:67
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
RatesHistoBase::m_rateVsTrainCachedPtr
TH1 * m_rateVsTrainCachedPtr
Cached, non-owning pointer.
Definition: RatesHistoBase.h:114
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
RatesHistoBase::m_rateVsMuCachedPtr
TH1 * m_rateVsMuCachedPtr
Cached, non-owning pointer.
Definition: RatesHistoBase.h:113
WeightingValuesSummary_t::m_bunchFactor
double m_bunchFactor
What weight needs to be applied to extrapolate rates linear in number of bunches.
Definition: RatesHistoBase.h:64
RatesHistoBase::m_name
std::string m_name
My name.
Definition: RatesHistoBase.h:108
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.PyAthena.v
v
Definition: PyAthena.py:157
RatesHistoBase::doHistograms
bool doHistograms() const
If histogramming was enabled in this rates object.
Definition: RatesHistoBase.h:99
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
kNRATES_BINS
@ kNRATES_BINS
Must always come last.
Definition: RatesHistoBase.h:49
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
WeightingValuesSummary_t::m_muFactor
double m_muFactor
What weight needs to be applied to extrapolate rates linear in mu.
Definition: RatesHistoBase.h:65
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
kNONE
@ kNONE
Do not scale this trigger for changes in luminosity.
Definition: RatesHistoBase.h:35
WeightingValuesSummary_t::m_noScaling
const double m_noScaling
Weight for no scaling.
Definition: RatesHistoBase.h:68