ATLAS Offline Software
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),
11  m_algTotalTime(0.),
12  m_liveTime(1.),
13  m_lb(0),
14  m_slot(0),
15  m_liveTimeIsPerEvent(false),
16  m_typeMapPtr(nullptr) {
17 }
18 
19 
20 StatusCode CostData::set(const xAOD::TrigCompositeContainer* costCollection, const xAOD::TrigCompositeContainer* rosCollection, uint32_t onlineSlot) {
23 
25  ATH_CHECK(cache());
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 
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 
49 void CostData::setCostROSData(const CostROSData& costROSData) {
51 }
52 
54  m_lb = lb;
55 }
56 
58  m_slot = slot;
59 }
60 
61 void CostData::setLivetime(float time, bool liveTimeIsPerEvent) {
62  m_liveTime = time;
64 }
65 
66 
68  return m_liveTimeIsPerEvent;
69 }
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 
91 const 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 
100  return m_lb;
101 }
102 
104  return m_slot;
105 }
106 
108  return (onlineSlot() == 0);
109 }
110 
111 
112 float CostData::liveTime() const {
113  return m_liveTime;
114 }
115 
116 
117 const 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 
130 void CostData::setTypeMap( const std::unordered_map<uint32_t, std::string>& typeMap ) {
131  m_typeMapPtr = &typeMap;
132 }
133 
134 void CostData::setChainToAlgMap( const std::map<std::string, std::set<size_t>>& chainToAlgIdx ) {
135  m_chainToAlgIdx = &chainToAlgIdx;
136 }
137 
138 void CostData::setChainToUniqAlgMap( const std::map<std::string, std::set<size_t>>& chainToAlgIdx ) {
139  m_chainToUniqAlgIdx = &chainToAlgIdx;
140 }
141 
142 void CostData::setSequencersMap( const std::map<std::string, std::map<int16_t, std::set<size_t>>>& seqToAlg ) {
143  m_sequencers = &seqToAlg;
144 }
145 
146 
147 const std::map<std::string, std::set<size_t>>& CostData::chainToAlgMap() const {
148  return *m_chainToAlgIdx;
149 }
150 
151 const std::map<std::string, std::set<size_t>>& CostData::chainToUniqAlgMap() const {
152  return *m_chainToUniqAlgIdx;
153 }
154 
155 const std::map<std::string, std::map<int16_t, std::set<size_t>>>& CostData::sequencersMap() const {
156  return *m_sequencers;
157 }
158 
159 const std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo>& CostData::seededChains() const {
160  return *m_seededChains;
161 }
162 
163 void CostData::setSeededChains(const std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo>& seededChains) {
165 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CostData::setSequencersMap
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
CostData::m_rosCollection
const xAOD::TrigCompositeContainer * m_rosCollection
Cached non-owning pointer to ros cost collection.
Definition: CostData.h:188
AthCheckMacros.h
CostData::sequencersMap
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
CostData::m_seededChains
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > * m_seededChains
Set of seeded chains to monitor.
Definition: CostData.h:200
CostData::isMasterSlot
bool isMasterSlot() const
Definition: CostData.cxx:107
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CostData::liveTime
float liveTime() const
Getter of effective P1 walltime represented by either the current event, or the current lumi block.
Definition: CostData.cxx:112
CostData::setTypeMap
void setTypeMap(const std::unordered_map< uint32_t, std::string > &typeMap)
Set internal type map pointer.
Definition: CostData.cxx:130
CostData::chainToUniqAlgMap
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
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CostData::m_slot
uint32_t m_slot
Current online slot number.
Definition: CostData.h:192
CostData::algNameToClassType
const std::string & algNameToClassType(size_t algNameHash) const
Get the class typename given an algorithm instance name.
Definition: CostData.cxx:117
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
CostData::set
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
CostData::m_costROSData
const CostROSData * m_costROSData
Helper class to store ROS to ROB mapping.
Definition: CostData.h:196
CostData::setLb
void setLb(uint32_t lb)
Setter of effective P1 walltime represented by the current event.
Definition: CostData.cxx:53
CostData::seededChains
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > & seededChains() const
Getter of the seeded chains set.
Definition: CostData.cxx:159
CostData::m_sequencers
const std::map< std::string, std::map< int16_t, std::set< size_t > > > * m_sequencers
Mapping of sequence to algorithms.
Definition: CostData.h:199
CostData::chainToAlgMap
const std::map< std::string, std::set< size_t > > & chainToAlgMap() const
Getter of the alg name to chains map.
Definition: CostData.cxx:147
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
CostData::m_chainToAlgIdx
const std::map< std::string, std::set< size_t > > * m_chainToAlgIdx
Mapping of chain to algorithms idx.
Definition: CostData.h:197
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CostData::setOnlineSlot
void setOnlineSlot(uint32_t slot)
Setter of the online Slot number of the current event.
Definition: CostData.cxx:57
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CostData::setSeededChains
void setSeededChains(const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > &seededChains)
Set the seeded chains set.
Definition: CostData.cxx:163
CostData::m_costCollection
const xAOD::TrigCompositeContainer * m_costCollection
Cached non-owning pointer to main algorithm cost collection.
Definition: CostData.h:187
CostData::cache
StatusCode cache()
Compute and cache derived quantities, called automatically after set().
Definition: CostData.cxx:39
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
integrator_ascii2db.rosIdx
rosIdx
Definition: integrator_ascii2db.py:92
CostData::algToRequestMap
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
CostData::m_algTotalTime
uint64_t m_algTotalTime
Integrated CPU time of all algorithms in the event.
Definition: CostData.h:189
CostData::lb
uint32_t lb() const
Current luminosity block number.
Definition: CostData.cxx:99
Muon::nsw::unknown
@ unknown
Definition: NSWTriggerElink.h:36
CostROSData
Caches and propagates event data to be used by monitoring algorithms.
Definition: CostROSData.h:24
CostData::rosCollection
const xAOD::TrigCompositeContainer & rosCollection() const
Getter of the cached ros cost collection pointer.
Definition: CostData.cxx:80
CostData.h
CostData::m_liveTime
float m_liveTime
Effective walltime of either the event or the LB, in seconds (.
Definition: CostData.h:190
CostData::liveTimeIsPerEvent
bool liveTimeIsPerEvent() const
If a call to liveTime() is providing data on a single event or a whole LB.
Definition: CostData.cxx:67
CostData::m_algToRos
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
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
CostData::setCostROSData
void setCostROSData(const CostROSData &costROSData)
Set ROS to ROB map.
Definition: CostData.cxx:49
CostData::costCollection
const xAOD::TrigCompositeContainer & costCollection() const
Getter of the cached algorithm cost collection pointer.
Definition: CostData.cxx:72
CostData::m_liveTimeIsPerEvent
bool m_liveTimeIsPerEvent
If the livetime represents a single event or all of the current LB.
Definition: CostData.h:193
CostData::setChainToAlgMap
void setChainToAlgMap(const std::map< std::string, std::set< size_t >> &algToChains)
Set the alg name to chains map.
Definition: CostData.cxx:134
CostData::setLivetime
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
CostData::m_chainToUniqAlgIdx
const std::map< std::string, std::set< size_t > > * m_chainToUniqAlgIdx
Mapping of chain name to its unique algorithms.
Definition: CostData.h:198
CostData::setChainToUniqAlgMap
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
CostData::CostData
CostData()
Construct an empty CostData.
Definition: CostData.cxx:9
CostData::algTotalTimeMilliSec
float algTotalTimeMilliSec() const
Getter of the total algorithm CPU time in the event.
Definition: CostData.cxx:95
CostData::m_lb
uint32_t m_lb
Current luminosity block number.
Definition: CostData.h:191
CostData::m_typeMapPtr
const std::unordered_map< uint32_t, std::string > * m_typeMapPtr
Cached non-owning pointer mapping algorithm instance names to types.
Definition: CostData.h:194
CostData::costROSData
const CostROSData & costROSData() const
Getter of the ROS to ROB map.
Definition: CostData.cxx:87
CostData::onlineSlot
uint32_t onlineSlot() const
Definition: CostData.cxx:103