ATLAS Offline Software
Loading...
Searching...
No Matches
CostData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CostData.h"
7
8
10 m_costCollection(nullptr),
12 m_liveTime(1.),
13 m_lb(0),
14 m_slot(0),
16 m_typeMapPtr(nullptr) {
17}
18
19
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}
37
38
39StatusCode CostData::cache() {
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}
48
52
53void CostData::setLb(uint32_t lb) {
54 m_lb = lb;
55}
56
57void CostData::setOnlineSlot(uint32_t slot) {
58 m_slot = slot;
59}
60
65
66
70
71
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}
78
79
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}
86
88 return *m_costROSData;
89}
90
91const std::map<size_t, std::vector<size_t>>& CostData::algToRequestMap() const {
92 return m_algToRos;
93}
94
96 return m_algTotalTime * 1e-3; // microseconds to milliseconds
97}
98
99uint32_t CostData::lb() const {
100 return m_lb;
101}
102
103uint32_t CostData::onlineSlot() const {
104 return m_slot;
105}
106
108 return (onlineSlot() == 0);
109}
110
111
112float CostData::liveTime() const {
113 return m_liveTime;
114}
115
116
117const std::string& CostData::algNameToClassType(size_t algNameHash) const {
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}
128
129
130void CostData::setTypeMap( const std::unordered_map<uint32_t, std::string>& typeMap ) {
131 m_typeMapPtr = &typeMap;
132}
133
134void CostData::setChainToAlgMap( const std::map<std::string, std::set<size_t>>& chainToAlgIdx ) {
135 m_chainToAlgIdx = &chainToAlgIdx;
136}
137
138void CostData::setChainToUniqAlgMap( const std::map<std::string, std::set<size_t>>& chainToAlgIdx ) {
139 m_chainToUniqAlgIdx = &chainToAlgIdx;
140}
141
142void CostData::setSequencersMap( const std::map<std::string, std::map<int16_t, std::set<size_t>>>& seqToAlg ) {
143 m_sequencers = &seqToAlg;
144}
145
146
147const std::map<std::string, std::set<size_t>>& CostData::chainToAlgMap() const {
148 return *m_chainToAlgIdx;
149}
150
151const std::map<std::string, std::set<size_t>>& CostData::chainToUniqAlgMap() const {
152 return *m_chainToUniqAlgIdx;
153}
154
155const std::map<std::string, std::map<int16_t, std::set<size_t>>>& CostData::sequencersMap() const {
156 return *m_sequencers;
157}
158
159const std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo>& CostData::seededChains() const {
160 return *m_seededChains;
161}
162
163void CostData::setSeededChains(const std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo>& seededChains) {
165}
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t tc
const std::map< std::string, std::set< size_t > > & chainToUniqAlgMap() const
Getter of the chain to its unique alg names map.
Definition CostData.cxx:151
const std::map< std::string, std::set< size_t > > * m_chainToUniqAlgIdx
Mapping of chain name to its unique algorithms.
Definition CostData.h:198
const CostROSData * m_costROSData
Helper class to store ROS to ROB mapping.
Definition CostData.h:196
const xAOD::TrigCompositeContainer & costCollection() const
Getter of the cached algorithm cost collection pointer.
Definition CostData.cxx:72
bool isMasterSlot() const
Definition CostData.cxx:107
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > * m_seededChains
Set of seeded chains to monitor.
Definition CostData.h:200
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
const CostROSData & costROSData() const
Getter of the ROS to ROB map.
Definition CostData.cxx:87
void setLb(uint32_t lb)
Setter of effective P1 walltime represented by the current event.
Definition CostData.cxx:53
void setSequencersMap(const std::map< std::string, std::map< int16_t, std::set< size_t > > > &seqToAlg)
Set the sequence to alg idx map.
Definition CostData.cxx:142
const std::map< std::string, std::set< size_t > > & chainToAlgMap() const
Getter of the alg name to chains map.
Definition CostData.cxx:147
const xAOD::TrigCompositeContainer & rosCollection() const
Getter of the cached ros cost collection pointer.
Definition CostData.cxx:80
const std::string & algNameToClassType(size_t algNameHash) const
Get the class typename given an algorithm instance name.
Definition CostData.cxx:117
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...
Definition CostData.cxx:91
uint32_t lb() const
Current luminosity block number.
Definition CostData.cxx:99
const std::map< std::string, std::map< int16_t, std::set< size_t > > > & sequencersMap() const
Getter of the sequence to alg idx map.
Definition CostData.cxx:155
uint32_t onlineSlot() const
Definition CostData.cxx:103
CostData()
Construct an empty CostData.
Definition CostData.cxx:9
void setCostROSData(const CostROSData &costROSData)
Set ROS to ROB map.
Definition CostData.cxx:49
void setTypeMap(const std::unordered_map< uint32_t, std::string > &typeMap)
Set internal type map pointer.
Definition CostData.cxx:130
void setChainToAlgMap(const std::map< std::string, std::set< size_t > > &algToChains)
Set the alg name to chains map.
Definition CostData.cxx:134
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
bool liveTimeIsPerEvent() const
If a call to liveTime() is providing data on a single event or a whole LB.
Definition CostData.cxx:67
uint32_t m_slot
Current online slot number.
Definition CostData.h:192
const std::map< std::string, std::map< int16_t, std::set< size_t > > > * m_sequencers
Mapping of sequence to algorithms.
Definition CostData.h:199
void setSeededChains(const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > &seededChains)
Set the seeded chains set.
Definition CostData.cxx:163
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
StatusCode cache()
Compute and cache derived quantities, called automatically after set().
Definition CostData.cxx:39
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > & seededChains() const
Getter of the seeded chains set.
Definition CostData.cxx:159
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
float liveTime() const
Getter of effective P1 walltime represented by either the current event, or the current lumi block.
Definition CostData.cxx:112
void setLivetime(float time, bool liveTimeIsPerEvent)
Setter of effective P1 walltime represented by the current event, or the current lumi block.
Definition CostData.cxx:61
void setOnlineSlot(uint32_t slot)
Setter of the online Slot number of the current event.
Definition CostData.cxx:57
void setChainToUniqAlgMap(const std::map< std::string, std::set< size_t > > &algToChains)
Set the chain to its unique alg names map.
Definition CostData.cxx:138
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.
Definition CostData.cxx:20
float algTotalTimeMilliSec() const
Getter of the total algorithm CPU time in the event.
Definition CostData.cxx:95
const std::map< std::string, std::set< size_t > > * m_chainToAlgIdx
Mapping of chain to algorithms idx.
Definition CostData.h:197
const xAOD::TrigCompositeContainer * m_rosCollection
Cached non-owning pointer to ros cost collection.
Definition CostData.h:188
Caches and propagates event data to be used by monitoring algorithms.
Definition CostROSData.h:24
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.