ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
 ~CostData ()=default
 Default destructor. More...
 
CostDataoperator= (const CostData &)=delete
 Forbid assignment. More...
 
 CostData (const CostData &)=delete
 Forbid copy. More...
 
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. More...
 
const xAOD::TrigCompositeContainercostCollection () const
 Getter of the cached algorithm cost collection pointer. More...
 
const xAOD::TrigCompositeContainerrosCollection () const
 Getter of the cached ros cost collection pointer. More...
 
const CostROSDatacostROSData () const
 Getter of the ROS to ROB map. More...
 
void setCostROSData (const CostROSData &costROSData)
 Set ROS to ROB map. More...
 
const std::map< std::string, std::set< size_t > > & chainToAlgMap () const
 Getter of the alg name to chains map. More...
 
void setChainToAlgMap (const std::map< std::string, std::set< size_t >> &algToChains)
 Set the alg name to chains map. More...
 
const std::map< std::string, std::set< size_t > > & chainToUniqAlgMap () const
 Getter of the chain to its unique alg names map. More...
 
void setChainToUniqAlgMap (const std::map< std::string, std::set< size_t >> &algToChains)
 Set the chain to its unique alg names map. More...
 
const std::map< std::string, std::map< int16_t, std::set< size_t > > > & sequencersMap () const
 Getter of the sequence to alg idx map. More...
 
void setSequencersMap (const std::map< std::string, std::map< int16_t, std::set< size_t >>> &seqToAlg)
 Set the sequence to alg idx map. More...
 
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > & seededChains () const
 Getter of the seeded chains set. More...
 
void setSeededChains (const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > &seededChains)
 Set the seeded chains set. More...
 
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) More...
 
void setLb (uint32_t lb)
 Setter of effective P1 walltime represented by the current event. More...
 
void setOnlineSlot (uint32_t slot)
 Setter of the online Slot number of the current event. More...
 
void setLivetime (float time, bool liveTimeIsPerEvent)
 Setter of effective P1 walltime represented by the current event, or the current lumi block. More...
 
float liveTime () const
 Getter of effective P1 walltime represented by either the current event, or the current lumi block. More...
 
bool liveTimeIsPerEvent () const
 If a call to liveTime() is providing data on a single event or a whole LB. More...
 
uint32_t lb () const
 Current luminosity block number. More...
 
uint32_t onlineSlot () const
 
bool isMasterSlot () const
 
float algTotalTimeMilliSec () const
 Getter of the total algorithm CPU time in the event. More...
 
const std::string & algNameToClassType (size_t algNameHash) const
 Get the class typename given an algorithm instance name. More...
 
void setTypeMap (const std::unordered_map< uint32_t, std::string > &typeMap)
 Set internal type map pointer. More...
 

Private Member Functions

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

Private Attributes

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

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),
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 }

◆ ~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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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  {
68  return m_liveTimeIsPerEvent;
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 }

◆ 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 }

◆ 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 }

◆ 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 
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 }

◆ 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 }

◆ 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 }

◆ 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.

◆ 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 }

◆ 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:
CostData::m_rosCollection
const xAOD::TrigCompositeContainer * m_rosCollection
Cached non-owning pointer to ros cost collection.
Definition: CostData.h:188
CostData::m_seededChains
const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > * m_seededChains
Set of seeded chains to monitor.
Definition: CostData.h:200
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
skel.it
it
Definition: skel.GENtoEVGEN.py:423
CostData::m_slot
uint32_t m_slot
Current online slot number.
Definition: CostData.h:192
CostData::m_costROSData
const CostROSData * m_costROSData
Helper class to store ROS to ROB mapping.
Definition: CostData.h:196
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::m_chainToAlgIdx
const std::map< std::string, std::set< size_t > > * m_chainToAlgIdx
Mapping of chain to algorithms idx.
Definition: CostData.h:197
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::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
integrator_ascii2db.rosIdx
rosIdx
Definition: integrator_ascii2db.py:92
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
CostData::rosCollection
const xAOD::TrigCompositeContainer & rosCollection() const
Getter of the cached ros cost collection pointer.
Definition: CostData.cxx:80
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
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
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::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::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