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, const xAOD::TrigCompositeContainer *rosCollection, 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 xAOD::TrigCompositeContainerrosCollection () const
 Getter of the cached ros 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.
const xAOD::TrigCompositeContainerm_rosCollection = nullptr
 Cached non-owning pointer to ros 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 CostROSDatam_costROSData = nullptr
 Helper class to store ROS to ROB mapping.
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:191
bool m_liveTimeIsPerEvent
If the livetime represents a single event or all of the current LB.
Definition CostData.h:193
uint64_t m_algTotalTime
Integrated CPU time of all algorithms in the event.
Definition CostData.h:189
const std::unordered_map< uint32_t, std::string > * m_typeMapPtr
Cached non-owning pointer mapping algorithm instance names to types.
Definition CostData.h:194
uint32_t m_slot
Current online slot number.
Definition CostData.h:192
const xAOD::TrigCompositeContainer * m_costCollection
Cached non-owning pointer to main algorithm cost collection.
Definition CostData.h:187
float m_liveTime
Effective walltime of either the event or the LB, in seconds (.
Definition CostData.h:190

◆ ~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 117 of file CostData.cxx.

117 {
118 const static std::string unknown = "UNKNOWN_CLASS";
119 if (m_typeMapPtr == nullptr) {
120 return unknown;
121 }
122 const auto it = m_typeMapPtr->find(algNameHash);
123 if (it == m_typeMapPtr->end()) {
124 return unknown;
125 }
126 return it->second;
127}

◆ 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 91 of file CostData.cxx.

91 {
92 return m_algToRos;
93}
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:195

◆ algTotalTimeMilliSec()

float CostData::algTotalTimeMilliSec ( ) const

Getter of the total algorithm CPU time in the event.

Returns
Total CPU time in milliseconds.

Definition at line 95 of file CostData.cxx.

95 {
96 return m_algTotalTime * 1e-3; // microseconds to milliseconds
97}

◆ cache()

StatusCode CostData::cache ( )
private

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

Computes algTotalTimeMilliSec()

Definition at line 39 of file CostData.cxx.

39 {
40 for (const xAOD::TrigComposite* tc : costCollection()) {
41 if (tc->getDetail<uint32_t>("slot") != onlineSlot()) {
42 continue; // When monitoring the master slot, ignores algs running in different slots
43 }
44 m_algTotalTime += (tc->getDetail<uint64_t>("stop") - tc->getDetail<uint64_t>("start"));
45 }
46 return StatusCode::SUCCESS;
47}
static Double_t tc
const xAOD::TrigCompositeContainer & costCollection() const
Getter of the cached algorithm cost collection pointer.
Definition CostData.cxx:72
uint32_t onlineSlot() const
Definition CostData.cxx:103
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 147 of file CostData.cxx.

147 {
148 return *m_chainToAlgIdx;
149}
const std::map< std::string, std::set< size_t > > * m_chainToAlgIdx
Mapping of chain to algorithms idx.
Definition CostData.h:197

◆ 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 151 of file CostData.cxx.

151 {
152 return *m_chainToUniqAlgIdx;
153}
const std::map< std::string, std::set< size_t > > * m_chainToUniqAlgIdx
Mapping of chain name to its unique algorithms.
Definition CostData.h:198

◆ costCollection()

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

Getter of the cached algorithm cost collection pointer.

Definition at line 72 of file CostData.cxx.

72 {
73 if (!m_costCollection) {
74 throw std::runtime_error("nullptr in CostData::costCollection(). Make sure CostData::set() is called.");
75 }
76 return *m_costCollection;
77}

◆ costROSData()

const CostROSData & CostData::costROSData ( ) const

Getter of the ROS to ROB map.

Definition at line 87 of file CostData.cxx.

87 {
88 return *m_costROSData;
89}
const CostROSData * m_costROSData
Helper class to store ROS to ROB mapping.
Definition CostData.h:196

◆ 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 107 of file CostData.cxx.

107 {
108 return (onlineSlot() == 0);
109}

◆ lb()

uint32_t CostData::lb ( ) const

Current luminosity block number.

Returns
Luminosity block number.

Definition at line 99 of file CostData.cxx.

99 {
100 return m_lb;
101}

◆ 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 112 of file CostData.cxx.

112 {
113 return m_liveTime;
114}

◆ 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 67 of file CostData.cxx.

67 {
69}

◆ onlineSlot()

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

Definition at line 103 of file CostData.cxx.

103 {
104 return m_slot;
105}

◆ operator=()

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

Forbid assignment.

◆ rosCollection()

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

Getter of the cached ros cost collection pointer.

Definition at line 80 of file CostData.cxx.

80 {
81 if (!m_rosCollection) {
82 throw std::runtime_error("nullptr in CostData::rosCollection(). Make sure CostData::set() is called.");
83 }
84 return *m_rosCollection;
85}
const xAOD::TrigCompositeContainer * m_rosCollection
Cached non-owning pointer to ros cost collection.
Definition CostData.h:188

◆ seededChains()

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

Getter of the seeded chains set.

Definition at line 159 of file CostData.cxx.

159 {
160 return *m_seededChains;
161}
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > * m_seededChains
Set of seeded chains to monitor.
Definition CostData.h:200

◆ 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 155 of file CostData.cxx.

155 {
156 return *m_sequencers;
157}
const std::map< std::string, std::map< int16_t, std::set< size_t > > > * m_sequencers
Mapping of sequence to algorithms.
Definition CostData.h:199

◆ set()

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

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

Definition at line 20 of file CostData.cxx.

20 {
23
26
27 // Create mapping from algorithm to associated ROS requests
28 m_algToRos.clear();
29 size_t rosIdx = 0;
30 for (const xAOD::TrigComposite* tc : *rosCollection) {
31 m_algToRos[tc->getDetail<size_t>("alg_idx")].push_back(rosIdx);
32 ++rosIdx;
33 }
34
35 return StatusCode::SUCCESS;
36}
#define ATH_CHECK
Evaluate an expression and check for errors.
const xAOD::TrigCompositeContainer & rosCollection() const
Getter of the cached ros cost collection pointer.
Definition CostData.cxx:80
StatusCode cache()
Compute and cache derived quantities, called automatically after set().
Definition CostData.cxx:39
void setOnlineSlot(uint32_t slot)
Setter of the online Slot number of the current event.
Definition CostData.cxx:57

◆ setChainToAlgMap()

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

Set the alg name to chains map.

Definition at line 134 of file CostData.cxx.

134 {
135 m_chainToAlgIdx = &chainToAlgIdx;
136}

◆ 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 138 of file CostData.cxx.

138 {
139 m_chainToUniqAlgIdx = &chainToAlgIdx;
140}

◆ setCostROSData()

void CostData::setCostROSData ( const CostROSData & costROSData)

Set ROS to ROB map.

Definition at line 49 of file CostData.cxx.

49 {
51}
const CostROSData & costROSData() const
Getter of the ROS to ROB map.
Definition CostData.cxx:87

◆ setLb()

void CostData::setLb ( uint32_t lb)

Setter of effective P1 walltime represented by the current event.

Definition at line 53 of file CostData.cxx.

53 {
54 m_lb = lb;
55}
uint32_t lb() const
Current luminosity block number.
Definition CostData.cxx:99

◆ 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 61 of file CostData.cxx.

61 {
64}
bool liveTimeIsPerEvent() const
If a call to liveTime() is providing data on a single event or a whole LB.
Definition CostData.cxx:67
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 57 of file CostData.cxx.

57 {
58 m_slot = slot;
59}

◆ setSeededChains()

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

Set the seeded chains set.

Definition at line 163 of file CostData.cxx.

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

◆ 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 142 of file CostData.cxx.

142 {
143 m_sequencers = &seqToAlg;
144}

◆ 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 130 of file CostData.cxx.

130 {
131 m_typeMapPtr = &typeMap;
132}

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 195 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 189 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 197 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 198 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 187 of file CostData.h.

◆ m_costROSData

const CostROSData* CostData::m_costROSData = nullptr
private

Helper class to store ROS to ROB mapping.

Definition at line 196 of file CostData.h.

◆ m_lb

uint32_t CostData::m_lb
private

Current luminosity block number.

Definition at line 191 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 190 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 193 of file CostData.h.

◆ m_rosCollection

const xAOD::TrigCompositeContainer* CostData::m_rosCollection = nullptr
private

Cached non-owning pointer to ros cost collection.

Definition at line 188 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 200 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 199 of file CostData.h.

◆ m_slot

uint32_t CostData::m_slot
private

Current online slot number.

Definition at line 192 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 194 of file CostData.h.


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