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

Caches and propagates event data to be used by monitoring algorithms. More...

#include <CostData.h>

Collaboration diagram for CostData:

Public Member Functions

 CostData ()
 Construct an empty CostData.
 ~CostData ()=default
 Default destructor.
CostDataoperator= (const CostData &)=delete
 Forbid assignment.
 CostData (const CostData &)=delete
 Forbid copy.
StatusCode set (const xAOD::TrigCompositeContainer *costCollection, uint32_t onlineSlot)
 Cache the cost and ros collections, after formally requesting it from storegate.
const xAOD::TrigCompositeContainercostCollection () const
 Getter of the cached algorithm cost collection pointer.
const CostROSDatacostROSData () const
 Getter of the ROS to ROB map.
void setCostROSData (const CostROSData &costROSData)
 Set ROS to ROB map.
const std::map< std::string, std::set< size_t > > & chainToAlgMap () const
 Getter of the alg name to chains map.
void setChainToAlgMap (const std::map< std::string, std::set< size_t > > &algToChains)
 Set the alg name to chains map.
const std::map< std::string, std::set< size_t > > & chainToUniqAlgMap () const
 Getter of the chain to its unique alg names map.
void setChainToUniqAlgMap (const std::map< std::string, std::set< size_t > > &algToChains)
 Set the chain to its unique alg names map.
const std::map< std::string, std::map< int16_t, std::set< size_t > > > & sequencersMap () const
 Getter of the sequence to alg idx map.
void setSequencersMap (const std::map< std::string, std::map< int16_t, std::set< size_t > > > &seqToAlg)
 Set the sequence to alg idx map.
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > & seededChains () const
 Getter of the seeded chains set.
void setSeededChains (const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > &seededChains)
 Set the seeded chains set.
const std::map< size_t, std::vector< size_t > > & algToRequestMap () const
 Getter of map between algorithm (index in costCollection) and ROS requests (indicies in rosCollection).
void setLb (uint32_t lb)
 Setter of effective P1 walltime represented by the current event.
void setOnlineSlot (uint32_t slot)
 Setter of the online Slot number of the current event.
void setLivetime (float time, bool liveTimeIsPerEvent)
 Setter of effective P1 walltime represented by the current event, or the current lumi block.
float liveTime () const
 Getter of effective P1 walltime represented by either the current event, or the current lumi block.
bool liveTimeIsPerEvent () const
 If a call to liveTime() is providing data on a single event or a whole LB.
uint32_t lb () const
 Current luminosity block number.
uint32_t onlineSlot () const
bool isMasterSlot () const
float algTotalTimeMilliSec () const
 Getter of the total algorithm CPU time in the event.
const std::string & algNameToClassType (size_t algNameHash) const
 Get the class typename given an algorithm instance name.
void setTypeMap (const std::unordered_map< uint32_t, std::string > &typeMap)
 Set internal type map pointer.

Private Member Functions

StatusCode cache ()
 Compute and cache derived quantities, called automatically after set().

Private Attributes

const xAOD::TrigCompositeContainerm_costCollection
 Cached non-owning pointer to main algorithm cost collection.
uint64_t m_algTotalTime
 Integrated CPU time of all algorithms in the event.
float m_liveTime
 Effective walltime of either the event or the LB, in seconds (.
uint32_t m_lb
 Current luminosity block number.
uint32_t m_slot
 Current online slot number.
bool m_liveTimeIsPerEvent
 If the livetime represents a single event or all of the current LB.
const std::unordered_map< uint32_t, std::string > * m_typeMapPtr
 Cached non-owning pointer mapping algorithm instance names to types.
std::map< size_t, std::vector< size_t > > m_algToRos
 Mapping of indexes from m_costCollection to corresponding ROS requests made by algorithm.
const std::map< std::string, std::set< size_t > > * m_chainToAlgIdx = nullptr
 Mapping of chain to algorithms idx.
const std::map< std::string, std::set< size_t > > * m_chainToUniqAlgIdx = nullptr
 Mapping of chain name to its unique algorithms.
const std::map< std::string, std::map< int16_t, std::set< size_t > > > * m_sequencers = nullptr
 Mapping of sequence to algorithms.
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > * m_seededChains = nullptr
 Set of seeded chains to monitor.

Detailed Description

Caches and propagates event data to be used by monitoring algorithms.

Cost Monitors and their Counters need access to different storegate collections, derived data, and other normalisation factors. The CostData object wraps all of these, providing a single "data" object which is passed down to all clients.

Definition at line 26 of file CostData.h.

Constructor & Destructor Documentation

◆ CostData() [1/2]

CostData::CostData ( )

Construct an empty CostData.

Definition at line 9 of file CostData.cxx.

9 :
10 m_costCollection(nullptr),
12 m_liveTime(1.),
13 m_lb(0),
14 m_slot(0),
16 m_typeMapPtr(nullptr) {
17}
uint32_t m_lb
Current luminosity block number.
Definition CostData.h:185
bool m_liveTimeIsPerEvent
If the livetime represents a single event or all of the current LB.
Definition CostData.h:187
uint64_t m_algTotalTime
Integrated CPU time of all algorithms in the event.
Definition CostData.h:183
const std::unordered_map< uint32_t, std::string > * m_typeMapPtr
Cached non-owning pointer mapping algorithm instance names to types.
Definition CostData.h:188
uint32_t m_slot
Current online slot number.
Definition CostData.h:186
const xAOD::TrigCompositeContainer * m_costCollection
Cached non-owning pointer to main algorithm cost collection.
Definition CostData.h:182
float m_liveTime
Effective walltime of either the event or the LB, in seconds (.
Definition CostData.h:184

◆ ~CostData()

CostData::~CostData ( )
default

Default destructor.

◆ CostData() [2/2]

CostData::CostData ( const CostData & )
delete

Forbid copy.

Member Function Documentation

◆ algNameToClassType()

const std::string & CostData::algNameToClassType ( size_t algNameHash) const

Get the class typename given an algorithm instance name.

Name is supplied in serialised hashed form.

Definition at line 89 of file CostData.cxx.

89 {
90 const static std::string unknown = "UNKNOWN_CLASS";
91 if (m_typeMapPtr == nullptr) {
92 return unknown;
93 }
94 const auto it = m_typeMapPtr->find(algNameHash);
95 if (it == m_typeMapPtr->end()) {
96 return unknown;
97 }
98 return it->second;
99}

◆ algToRequestMap()

const std::map< size_t, std::vector< size_t > > & CostData::algToRequestMap ( ) const

Getter of map between algorithm (index in costCollection) and ROS requests (indicies in rosCollection).

Definition at line 63 of file CostData.cxx.

63 {
64 return m_algToRos;
65}
std::map< size_t, std::vector< size_t > > m_algToRos
Mapping of indexes from m_costCollection to corresponding ROS requests made by algorithm.
Definition CostData.h:189

◆ algTotalTimeMilliSec()

float CostData::algTotalTimeMilliSec ( ) const

Getter of the total algorithm CPU time in the event.

Returns
Total CPU time in milliseconds.

Definition at line 67 of file CostData.cxx.

67 {
68 return m_algTotalTime * 1e-3; // microseconds to milliseconds
69}

◆ cache()

StatusCode CostData::cache ( )
private

Compute and cache derived quantities, called automatically after set().

Computes algTotalTimeMilliSec()

Definition at line 27 of file CostData.cxx.

27 {
28 for (const xAOD::TrigComposite* tc : costCollection()) {
29 if (tc->getDetail<uint32_t>("slot") != onlineSlot()) {
30 continue; // When monitoring the master slot, ignores algs running in different slots
31 }
32 m_algTotalTime += (tc->getDetail<uint64_t>("stop") - tc->getDetail<uint64_t>("start"));
33 }
34 return StatusCode::SUCCESS;
35}
static Double_t tc
const xAOD::TrigCompositeContainer & costCollection() const
Getter of the cached algorithm cost collection pointer.
Definition CostData.cxx:56
uint32_t onlineSlot() const
Definition CostData.cxx:75
TrigComposite_v1 TrigComposite
Declare the latest version of the class.

◆ chainToAlgMap()

const std::map< std::string, std::set< size_t > > & CostData::chainToAlgMap ( ) const

Getter of the alg name to chains map.

Definition at line 119 of file CostData.cxx.

119 {
120 return *m_chainToAlgIdx;
121}
const std::map< std::string, std::set< size_t > > * m_chainToAlgIdx
Mapping of chain to algorithms idx.
Definition CostData.h:190

◆ chainToUniqAlgMap()

const std::map< std::string, std::set< size_t > > & CostData::chainToUniqAlgMap ( ) const

Getter of the chain to its unique alg names map.

Definition at line 123 of file CostData.cxx.

123 {
124 return *m_chainToUniqAlgIdx;
125}
const std::map< std::string, std::set< size_t > > * m_chainToUniqAlgIdx
Mapping of chain name to its unique algorithms.
Definition CostData.h:191

◆ costCollection()

const xAOD::TrigCompositeContainer & CostData::costCollection ( ) const

Getter of the cached algorithm cost collection pointer.

Definition at line 56 of file CostData.cxx.

56 {
57 if (!m_costCollection) {
58 throw std::runtime_error("nullptr in CostData::costCollection(). Make sure CostData::set() is called.");
59 }
60 return *m_costCollection;
61}

◆ costROSData()

const CostROSData & CostData::costROSData ( ) const

Getter of the ROS to ROB map.

◆ isMasterSlot()

bool CostData::isMasterSlot ( ) const
Returns
True if event was processed in the master slot (0), and hence contains cost data spanning all concurrent slots

Definition at line 79 of file CostData.cxx.

79 {
80 return (onlineSlot() == 0);
81}

◆ lb()

uint32_t CostData::lb ( ) const

Current luminosity block number.

Returns
Luminosity block number.

Definition at line 71 of file CostData.cxx.

71 {
72 return m_lb;
73}

◆ liveTime()

float CostData::liveTime ( ) const

Getter of effective P1 walltime represented by either the current event, or the current lumi block.

Returns
Walltime in seconds.

Definition at line 84 of file CostData.cxx.

84 {
85 return m_liveTime;
86}

◆ liveTimeIsPerEvent()

bool CostData::liveTimeIsPerEvent ( ) const

If a call to liveTime() is providing data on a single event or a whole LB.

Returns
Walltime in seconds.

Definition at line 51 of file CostData.cxx.

51 {
53}

◆ onlineSlot()

uint32_t CostData::onlineSlot ( ) const
Returns
Online slot number

Definition at line 75 of file CostData.cxx.

75 {
76 return m_slot;
77}

◆ operator=()

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

Forbid assignment.

◆ seededChains()

const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > & CostData::seededChains ( ) const

Getter of the seeded chains set.

Definition at line 131 of file CostData.cxx.

131 {
132 return *m_seededChains;
133}
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > * m_seededChains
Set of seeded chains to monitor.
Definition CostData.h:193

◆ sequencersMap()

const std::map< std::string, std::map< int16_t, std::set< size_t > > > & CostData::sequencersMap ( ) const

Getter of the sequence to alg idx map.

Definition at line 127 of file CostData.cxx.

127 {
128 return *m_sequencers;
129}
const std::map< std::string, std::map< int16_t, std::set< size_t > > > * m_sequencers
Mapping of sequence to algorithms.
Definition CostData.h:192

◆ set()

StatusCode CostData::set ( const xAOD::TrigCompositeContainer * costCollection,
uint32_t onlineSlot )

Cache the cost and ros collections, after formally requesting it from storegate.

Definition at line 19 of file CostData.cxx.

19 {
21
24 return StatusCode::SUCCESS;
25}
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode cache()
Compute and cache derived quantities, called automatically after set().
Definition CostData.cxx:27
void setOnlineSlot(uint32_t slot)
Setter of the online Slot number of the current event.
Definition CostData.cxx:41

◆ setChainToAlgMap()

void CostData::setChainToAlgMap ( const std::map< std::string, std::set< size_t > > & algToChains)

Set the alg name to chains map.

Definition at line 106 of file CostData.cxx.

106 {
107 m_chainToAlgIdx = &chainToAlgIdx;
108}

◆ setChainToUniqAlgMap()

void CostData::setChainToUniqAlgMap ( const std::map< std::string, std::set< size_t > > & algToChains)

Set the chain to its unique alg names map.

Definition at line 110 of file CostData.cxx.

110 {
111 m_chainToUniqAlgIdx = &chainToAlgIdx;
112}

◆ setCostROSData()

void CostData::setCostROSData ( const CostROSData & costROSData)

Set ROS to ROB map.

◆ setLb()

void CostData::setLb ( uint32_t lb)

Setter of effective P1 walltime represented by the current event.

Definition at line 37 of file CostData.cxx.

37 {
38 m_lb = lb;
39}
uint32_t lb() const
Current luminosity block number.
Definition CostData.cxx:71

◆ setLivetime()

void CostData::setLivetime ( float time,
bool liveTimeIsPerEvent )

Setter of effective P1 walltime represented by the current event, or the current lumi block.

As specified by the second parameter

Definition at line 45 of file CostData.cxx.

45 {
48}
bool liveTimeIsPerEvent() const
If a call to liveTime() is providing data on a single event or a whole LB.
Definition CostData.cxx:51
time(flags, cells_name, *args, **kw)

◆ setOnlineSlot()

void CostData::setOnlineSlot ( uint32_t slot)

Setter of the online Slot number of the current event.

Definition at line 41 of file CostData.cxx.

41 {
42 m_slot = slot;
43}

◆ setSeededChains()

void CostData::setSeededChains ( const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > & seededChains)

Set the seeded chains set.

Definition at line 135 of file CostData.cxx.

135 {
137}
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > & seededChains() const
Getter of the seeded chains set.
Definition CostData.cxx:131

◆ setSequencersMap()

void CostData::setSequencersMap ( const std::map< std::string, std::map< int16_t, std::set< size_t > > > & seqToAlg)

Set the sequence to alg idx map.

Definition at line 114 of file CostData.cxx.

114 {
115 m_sequencers = &seqToAlg;
116}

◆ setTypeMap()

void CostData::setTypeMap ( const std::unordered_map< uint32_t, std::string > & typeMap)

Set internal type map pointer.

Returns
Total CPU time in milliseconds.

Definition at line 102 of file CostData.cxx.

102 {
103 m_typeMapPtr = &typeMap;
104}

Member Data Documentation

◆ m_algToRos

std::map<size_t, std::vector<size_t> > CostData::m_algToRos
private

Mapping of indexes from m_costCollection to corresponding ROS requests made by algorithm.

Definition at line 189 of file CostData.h.

◆ m_algTotalTime

uint64_t CostData::m_algTotalTime
private

Integrated CPU time of all algorithms in the event.

Stored in discrete microseconds.

Definition at line 183 of file CostData.h.

◆ m_chainToAlgIdx

const std::map<std::string, std::set<size_t> >* CostData::m_chainToAlgIdx = nullptr
private

Mapping of chain to algorithms idx.

Definition at line 190 of file CostData.h.

◆ m_chainToUniqAlgIdx

const std::map<std::string, std::set<size_t> >* CostData::m_chainToUniqAlgIdx = nullptr
private

Mapping of chain name to its unique algorithms.

Definition at line 191 of file CostData.h.

◆ m_costCollection

const xAOD::TrigCompositeContainer* CostData::m_costCollection
private

Cached non-owning pointer to main algorithm cost collection.

Definition at line 182 of file CostData.h.

◆ m_lb

uint32_t CostData::m_lb
private

Current luminosity block number.

Definition at line 185 of file CostData.h.

◆ m_liveTime

float CostData::m_liveTime
private

Effective walltime of either the event or the LB, in seconds (.

See also
m_liveTimeIsPerEvent).

Definition at line 184 of file CostData.h.

◆ m_liveTimeIsPerEvent

bool CostData::m_liveTimeIsPerEvent
private

If the livetime represents a single event or all of the current LB.

Definition at line 187 of file CostData.h.

◆ m_seededChains

const std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo>* CostData::m_seededChains = nullptr
private

Set of seeded chains to monitor.

Definition at line 193 of file CostData.h.

◆ m_sequencers

const std::map<std::string, std::map<int16_t, std::set<size_t> > >* CostData::m_sequencers = nullptr
private

Mapping of sequence to algorithms.

Definition at line 192 of file CostData.h.

◆ m_slot

uint32_t CostData::m_slot
private

Current online slot number.

Definition at line 186 of file CostData.h.

◆ m_typeMapPtr

const std::unordered_map<uint32_t, std::string>* CostData::m_typeMapPtr
private

Cached non-owning pointer mapping algorithm instance names to types.

Definition at line 188 of file CostData.h.


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