ATLAS Offline Software
AthMonitorAlgorithm.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
17 #ifndef ATHMONITORALGORITHM_H
18 #define ATHMONITORALGORITHM_H
19 
21 
26 
35 
37 public:
38 
42  AthMonitorAlgorithm(const std::string& name, ISvcLocator* pSvcLocator );
43 
44 
48  virtual ~AthMonitorAlgorithm();
49 
50 
56  virtual StatusCode initialize() override;
57 
58 
65  virtual StatusCode execute(const EventContext& ctx) const override;
66 
67 
77  virtual StatusCode fillHistograms(const EventContext& ctx) const = 0;
78 
97  void fill( const ToolHandle<GenericMonitoringTool>& groupHandle,
98  std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>&& variables ) const;
99 
113  void fill( const ToolHandle<GenericMonitoringTool>& groupHandle,
114  const std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>& variables ) const {
115  fill(groupHandle, std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>{variables});
116  };
117 
124  template <typename... T>
125  void fill( const ToolHandle<GenericMonitoringTool>& groupHandle, T&&... variables ) const {
126  fill(groupHandle, std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>{std::forward<T>(variables)...});
127  }
128 
137  void fill( const std::string& groupName,
138  std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>&& variables ) const;
139 
146  void fill( const std::string& groupName,
147  const std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>& variables ) const {
148  fill( getGroup(groupName), std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>{variables});
149  }
150 
157  template <typename... T>
158  void fill( const std::string& groupName, T&&... variables ) const {
159  fill(getGroup(groupName), std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>>{std::forward<T>(variables)...});
160  } // end of fill group
162 
163 
172  enum class Environment_t {
173  user = 0,
174  online,
175  tier0,
176  tier0Raw,
177  tier0ESD,
178  AOD,
179  altprod,
180  };
181 
182 
191  enum class DataType_t {
192  userDefined = 0,
193  monteCarlo,
194  collisions,
195  cosmics,
197  };
198 
199 
206 
207 
213  Environment_t envStringToEnum( const std::string& str ) const;
214 
215 
221  DataType_t dataType() const { return m_dataType; }
222 
223 
229  DataType_t dataTypeStringToEnum( const std::string& str ) const;
230 
231 
242  const ToolHandle<GenericMonitoringTool>& getGroup( const std::string& name ) const;
243 
244 
253  const ToolHandle<Trig::TrigDecisionTool>& getTrigDecisionTool() const;
254 
265  bool trigChainsArePassed( const std::vector<std::string>& vTrigNames ) const;
266 
273  SG::ReadHandle<xAOD::EventInfo> GetEventInfo( const EventContext& ) const;
274 
283  virtual float lbAverageInteractionsPerCrossing( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
284 
288  virtual float lbInteractionsPerCrossing( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
289 
293  virtual float lbAverageLuminosity( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
294 
298  virtual float lbLuminosityPerBCID( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
299 
303  virtual double lbDuration( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
304 
308  virtual float lbAverageLivefraction( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
309 
313  virtual float livefractionPerBCID( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
314 
318  virtual double lbLumiWeight( const EventContext& ctx = Gaudi::Hive::currentContext() ) const;
319  // end of lumi group
321 
322 
333  virtual StatusCode parseList( const std::string& line, std::vector<std::string>& result ) const;
334 
335 
336 protected:
337  // Using the new way to declare JO properties: Gaudi::Property<int> m_myProperty {this,"MyProperty",0};
338  ToolHandleArray<GenericMonitoringTool> m_tools {this,"GMTools",{}};
339  // Keep TDT public until final decision from trigger on interface
340  PublicToolHandle<Trig::TrigDecisionTool> m_trigDecTool {this, "TrigDecisionTool",""};
341  ToolHandleArray<IDQFilterTool> m_DQFilterTools {this,"FilterTools",{}};
342 
344  {this,"LuminosityCondDataKey","LuminosityCondData","SG Key of LuminosityCondData object"};
346  {this,"LBDurationCondDataKey","LBDurationCondData","SG Key of LBDurationCondData object"};
348  {this,"TrigLiveFractionCondDataKey","TrigLiveFractionCondData", "SG Key of TrigLiveFractionCondData object"};
349 
352  Gaudi::Property<std::string> m_environmentStr {this,"Environment","user"};
353  Gaudi::Property<std::string> m_dataTypeStr {this,"DataType","userDefined"};
354 
355  Gaudi::Property<std::string> m_triggerChainString {this,"TriggerChain",""};
356  std::vector<std::string> m_vTrigChainNames;
357 
358  Gaudi::Property<std::string> m_fileKey {this,"FileKey",""};
359  Gaudi::Property<bool> m_useLumi {this,"EnableLumi",false};
360  Gaudi::Property<float> m_defaultLBDuration {this,"DefaultLBDuration",60.};
361  Gaudi::Property<int> m_detailLevel {this,"DetailLevel",0};
362  SG::ReadHandleKey<xAOD::EventInfo> m_EventInfoKey {this,"EventInfoKey","EventInfo"};
363 
364 private:
365  typedef std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> MonVarVec_t;
366  std::string m_name;
367  std::unordered_map<std::string, size_t> m_toolLookupMap;
368 
369  const ToolHandle<GenericMonitoringTool> m_dummy;
370 
371 
372  Gaudi::Property<bool> m_enforceExpressTriggers{this,
373  "EnforceExpressTriggers", false,
374  "Requires that matched triggers made the event enter the express stream"};
375 };
376 
377 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
IMonitorToolBase.h
AthMonitorAlgorithm::environment
Environment_t environment() const
Accessor functions for the environment.
Definition: AthMonitorAlgorithm.h:205
AthMonitorAlgorithm::livefractionPerBCID
virtual float livefractionPerBCID(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the live fraction per bunch crossing ID.
Definition: AthMonitorAlgorithm.cxx:291
AthMonitorAlgorithm::Environment_t::tier0Raw
@ tier0Raw
AthMonitorAlgorithm::m_dataTypeStr
Gaudi::Property< std::string > m_dataTypeStr
DataType string pulled from the job option and converted to enum.
Definition: AthMonitorAlgorithm.h:353
AthMonitorAlgorithm::dataType
DataType_t dataType() const
Accessor functions for the data type.
Definition: AthMonitorAlgorithm.h:221
AthMonitorAlgorithm::lbInteractionsPerCrossing
virtual float lbInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate instantaneous number of interactions, i.e.
Definition: AthMonitorAlgorithm.cxx:234
AthMonitorAlgorithm::lbLumiWeight
virtual double lbLumiWeight(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average integrated luminosity multiplied by the live fraction.
Definition: AthMonitorAlgorithm.cxx:308
checkFileSG.line
line
Definition: checkFileSG.py:75
AthMonitorAlgorithm::m_environmentStr
Gaudi::Property< std::string > m_environmentStr
Environment string pulled from the job option and converted to enum.
Definition: AthMonitorAlgorithm.h:352
AthMonitorAlgorithm::lbAverageLuminosity
virtual float lbAverageLuminosity(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate average luminosity (in ub-1 s-1 => 10^30 cm-2 s-1).
Definition: AthMonitorAlgorithm.cxx:250
get_generator_info.result
result
Definition: get_generator_info.py:21
checkCoolLatestUpdate.variables
variables
Definition: checkCoolLatestUpdate.py:13
AthMonitorAlgorithm::m_trigDecTool
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecTool
Tool to tell whether a specific trigger is passed.
Definition: AthMonitorAlgorithm.h:340
AthMonitorAlgorithm::Environment_t::tier0
@ tier0
AthMonitorAlgorithm::Environment_t::AOD
@ AOD
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthMonitorAlgorithm::m_triggerChainString
Gaudi::Property< std::string > m_triggerChainString
Trigger chain string pulled from the job option and parsed into a vector.
Definition: AthMonitorAlgorithm.h:355
RunTileMonitoring.groupName
groupName
Definition: RunTileMonitoring.py:158
AthMonitorAlgorithm::m_vTrigChainNames
std::vector< std::string > m_vTrigChainNames
Vector of trigger chain names parsed from trigger chain string.
Definition: AthMonitorAlgorithm.h:356
AthMonitorAlgorithm::m_EventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
Key for retrieving EventInfo from StoreGate.
Definition: AthMonitorAlgorithm.h:362
AthMonitorAlgorithm::getTrigDecisionTool
const ToolHandle< Trig::TrigDecisionTool > & getTrigDecisionTool() const
Get the trigger decision tool member.
Definition: AthMonitorAlgorithm.cxx:189
AthMonitorAlgorithm::m_toolLookupMap
std::unordered_map< std::string, size_t > m_toolLookupMap
Definition: AthMonitorAlgorithm.h:367
AthMonitorAlgorithm::m_environment
AthMonitorAlgorithm::Environment_t m_environment
Instance of the Environment_t enum.
Definition: AthMonitorAlgorithm.h:350
TrigDecisionTool.h
AthMonitorAlgorithm::m_detailLevel
Gaudi::Property< int > m_detailLevel
Sets the level of detail used in the monitoring.
Definition: AthMonitorAlgorithm.h:361
SG::ReadHandleKey< xAOD::EventInfo >
AthMonitorAlgorithm::fill
void fill(const std::string &groupName, const std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &variables) const
Fills a vector of variables to a group by name.
Definition: AthMonitorAlgorithm.h:146
AthMonitorAlgorithm::trigChainsArePassed
bool trigChainsArePassed(const std::vector< std::string > &vTrigNames) const
Check whether triggers are passed.
Definition: AthMonitorAlgorithm.cxx:194
ReadCondHandle.h
AthMonitorAlgorithm::Environment_t::user
@ user
AthMonitorAlgorithm::m_dummy
const ToolHandle< GenericMonitoringTool > m_dummy
Definition: AthMonitorAlgorithm.h:369
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AthMonitorAlgorithm::lbLuminosityPerBCID
virtual float lbLuminosityPerBCID(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the instantaneous luminosity per bunch crossing.
Definition: AthMonitorAlgorithm.cxx:262
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, const std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &variables) const
Fills a vector of variables to a group by reference.
Definition: AthMonitorAlgorithm.h:113
GenericMonitoringTool.h
TrigLiveFractionCondData.h
Hold live fraction data produced by TrigLiveFractionCondAlg.
AthMonitorAlgorithm::m_DQFilterTools
ToolHandleArray< IDQFilterTool > m_DQFilterTools
Array of Data Quality filter tools.
Definition: AthMonitorAlgorithm.h:341
AthMonitorAlgorithm::dataTypeStringToEnum
DataType_t dataTypeStringToEnum(const std::string &str) const
Convert the data type string from the python configuration to an enum object.
Definition: AthMonitorAlgorithm.cxx:140
AthMonitorAlgorithm::~AthMonitorAlgorithm
virtual ~AthMonitorAlgorithm()
Destructor.
Definition: AthMonitorAlgorithm.cxx:15
AthMonitorAlgorithm::DataType_t::heavyIonCollisions
@ heavyIonCollisions
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthMonitorAlgorithm::m_defaultLBDuration
Gaudi::Property< float > m_defaultLBDuration
Default duration of one lumi block.
Definition: AthMonitorAlgorithm.h:360
AthMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const =0
adds event to the monitoring histograms
AthMonitorAlgorithm::fill
void fill(const std::string &groupName, T &&... variables) const
Fills a variadic list of variables to a group by name.
Definition: AthMonitorAlgorithm.h:158
AthMonitorAlgorithm::DataType_t
DataType_t
Specifies what type of input data is being monitored.
Definition: AthMonitorAlgorithm.h:191
AthMonitorAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override
Applies filters and trigger requirements.
Definition: AthMonitorAlgorithm.cxx:73
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
AthMonitorAlgorithm::Environment_t
Environment_t
Specifies the processing environment.
Definition: AthMonitorAlgorithm.h:172
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
LuminosityCondData.h
Hold luminosity data produced by LuminosityCondAlg.
AthMonitorAlgorithm::m_dataType
AthMonitorAlgorithm::DataType_t m_dataType
Instance of the DataType_t enum.
Definition: AthMonitorAlgorithm.h:351
ReadCondHandleKey.h
AthMonitorAlgorithm::DataType_t::cosmics
@ cosmics
AthReentrantAlgorithm.h
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
AthMonitorAlgorithm::Environment_t::online
@ online
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthMonitorAlgorithm::lbAverageLivefraction
virtual float lbAverageLivefraction(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average luminosity livefraction.
Definition: AthMonitorAlgorithm.cxx:274
AthMonitorAlgorithm::Environment_t::tier0ESD
@ tier0ESD
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, T &&... variables) const
Fills a variadic list of variables to a group by reference.
Definition: AthMonitorAlgorithm.h:125
AthMonitorAlgorithm::Environment_t::altprod
@ altprod
LBDurationCondData.h
Hold luminosity block duration data produced from /TRIGGER/LUMI/LBLB.
AthMonitorAlgorithm::m_enforceExpressTriggers
Gaudi::Property< bool > m_enforceExpressTriggers
Definition: AthMonitorAlgorithm.h:372
AthMonitorAlgorithm::lbAverageInteractionsPerCrossing
virtual float lbAverageInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average mu, i.e.
Definition: AthMonitorAlgorithm.cxx:222
EventInfo.h
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
SG::ReadCondHandleKey< LuminosityCondData >
AthMonitorAlgorithm::m_lumiDataKey
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
Definition: AthMonitorAlgorithm.h:344
AthMonitorAlgorithm::DataType_t::collisions
@ collisions
AthMonitorAlgorithm::parseList
virtual StatusCode parseList(const std::string &line, std::vector< std::string > &result) const
Parse a string into a vector.
Definition: AthMonitorAlgorithm.cxx:336
AthMonitorAlgorithm::m_name
std::string m_name
Definition: AthMonitorAlgorithm.h:366
AthMonitorAlgorithm::fill
void fill(const std::string &groupName, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by name.
AthMonitorAlgorithm::envStringToEnum
Environment_t envStringToEnum(const std::string &str) const
Convert the environment string from the python configuration to an enum object.
Definition: AthMonitorAlgorithm.cxx:112
AthMonitorAlgorithm::AthMonitorAlgorithm
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: AthMonitorAlgorithm.cxx:7
AthMonitorAlgorithm::MonVarVec_t
std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > MonVarVec_t
Definition: AthMonitorAlgorithm.h:365
str
Definition: BTagTrackIpAccessor.cxx:11
AthMonitorAlgorithm::m_fileKey
Gaudi::Property< std::string > m_fileKey
Internal Athena name for file.
Definition: AthMonitorAlgorithm.h:358
IDQFilterTool.h
AthMonitorAlgorithm::m_trigLiveFractionDataKey
SG::ReadCondHandleKey< TrigLiveFractionCondData > m_trigLiveFractionDataKey
Definition: AthMonitorAlgorithm.h:348
AthMonitorAlgorithm::lbDuration
virtual double lbDuration(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the duration of the luminosity block (in seconds)
Definition: AthMonitorAlgorithm.cxx:319
AthMonitorAlgorithm::m_useLumi
Gaudi::Property< bool > m_useLumi
Allows use of various luminosity functions.
Definition: AthMonitorAlgorithm.h:359
AthMonitorAlgorithm::DataType_t::userDefined
@ userDefined
AthMonitorAlgorithm::m_lbDurationDataKey
SG::ReadCondHandleKey< LBDurationCondData > m_lbDurationDataKey
Definition: AthMonitorAlgorithm.h:346
AthMonitorAlgorithm::getGroup
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
Definition: AthMonitorAlgorithm.cxx:164
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
AthMonitorAlgorithm::DataType_t::monteCarlo
@ monteCarlo