ATLAS Offline Software
ROBDataMonitor.h
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 
8 #ifndef ROBDATAMONITOR_H
9 #define ROBDATAMONITOR_H
10 
11 #include "eformat/SourceIdentifier.h"
12 #include <time.h>
13 #include <chrono>
14 #include <map>
15 #include <iostream>
16 #include <iomanip>
17 
19 #include "AthenaKernel/CLASS_DEF.h"
20 
21 namespace robmonitor {
22 
26  enum ROBHistory {
27  UNCLASSIFIED = 0, // ROB was requested but never arrived at processor. History unknown.
28  RETRIEVED = 1, // ROB was retrieved from ROS by DataCollector
29  HLT_CACHED = 2, // ROB was found already in the internal cache of the ROBDataProviderSvc
30  DCM_CACHED = 4, // ROB was found already in the internal cache of the DCM
31  IGNORED = 8, // ROB was on the "ignore" list and therefore not retrieved
32  UNDEFINED = 16, // ROB was not on the "enabled" list, should not happen
33  NUM_ROBHIST_CODES = 6 // number of different history codes
34  };
35 
39  class ROBDataStruct {
40  public:
41 
43  ROBDataStruct();
44 
48  ROBDataStruct(const uint32_t);
49 
50  // data variables
51  uint32_t rob_id; // rob source id
52  uint32_t rob_size; // size of rob in words
53  robmonitor::ROBHistory rob_history; // History of ROB retrieval
54  uint32_t rob_status_word; // last status word in the ROB header
55 
56 
57  // Accessor functions
59  bool isUnclassified() const;
61  bool isHLTCached() const;
63  bool isDCMCached() const;
65  bool isRetrieved() const;
67  bool isIgnored() const;
69  bool isUndefined() const;
71  bool isStatusOk() const;
72 
73  // Extraction operators
74  friend std::ostream& operator<<(std::ostream& os, const robmonitor::ROBDataStruct& rhs);
75  };
76 
82  public:
83 
86 
91  ROBDataMonitorStruct(const uint32_t, const std::string&);
92 
98  ROBDataMonitorStruct(const uint32_t, const std::vector<uint32_t>&, const std::string&);
99 
101 
103 
105 
107 
108  // data variables
109  uint32_t lvl1ID; //current L1 ID from L1 ROBs
110  std::string requestor_name; //name of requesting algorithm
111  std::map<const uint32_t,robmonitor::ROBDataStruct> requested_ROBs; //map of ROBs requested
112 
113  // Legacy timestamps
114  struct timeval start_time_of_ROB_request; //start time of ROB request
115  struct timeval end_time_of_ROB_request; //stop time of ROB request
116 
117  // Run3 TrigTimeStamp
118  uint64_t start_time; //start time of ROB request
119  uint64_t end_time; //stop time of ROB request
120 
121  // Accessor functions to ROB history summaries
123  unsigned allROBs() const;
125  unsigned unclassifiedROBs() const;
127  unsigned HLTcachedROBs() const;
129  unsigned DCMcachedROBs() const;
131  unsigned retrievedROBs() const;
133  unsigned ignoredROBs() const;
135  unsigned undefinedROBs() const;
137  unsigned statusOkROBs() const;
138 
140  float elapsedTime() const;
141 
142  // Extraction operators
143  friend std::ostream& operator<<(std::ostream& os, const robmonitor::ROBDataMonitorStruct& rhs);
144  };
145 
146  // Extraction operator for ROBDataStruct
147  inline std::ostream& operator<<(std::ostream& os, const robmonitor::ROBDataStruct& rhs) {
148  os << "[SourceID,Size(words),History,(Status words)]=["
149  << std::hex << std::setfill( '0' ) << "0x" << std::setw(6) << rhs.rob_id
150  << std::dec << std::setfill(' ')
151  << "," << std::setw(8) << rhs.rob_size;
152  os << "," << std::setw(12);
153  if (rhs.rob_history == robmonitor::UNCLASSIFIED) {
154  os << "UNCLASSIFIED";
155  } else if (rhs.rob_history == robmonitor::RETRIEVED) {
156  os << "RETRIEVED";
157  } else if (rhs.rob_history == robmonitor::HLT_CACHED) {
158  os << "HLT_CACHED";
159  } else if (rhs.rob_history == robmonitor::DCM_CACHED) {
160  os << "DCM_CACHED";
161  }else if (rhs.rob_history == robmonitor::IGNORED) {
162  os << "IGNORED";
163  } else if (rhs.rob_history == robmonitor::UNDEFINED) {
164  os << "UNDEFINED";
165  } else {
166  os << "invalid code";
167  }
168  os << ",(";
169  os << std::hex << std::setfill( '0' ) << "0x" << std::setw(8) << rhs.rob_status_word;
170  os << ")]";
171  return os;
172  }
173 
174  // Extraction operator for ROBDataMonitorStruct
175  inline std::ostream& operator<<(std::ostream& os, const robmonitor::ROBDataMonitorStruct& rhs) {
176  std::string prefix(" ");
177  std::string prefix2("-> ");
178  os << "ROB Request for L1 ID = " << std::dec << rhs.lvl1ID << " (decimal), L1 ID = 0x"
179  << std::hex << rhs.lvl1ID << " (hex)" << std::dec;
180  os << "\n" << prefix << "Requestor name = " << rhs.requestor_name;
181 
182  const std::time_t s_time(rhs.start_time_of_ROB_request.tv_sec);
183  struct tm buf;
184  localtime_r(&s_time, &buf);
185  os << "\n" << prefix << "Start time of ROB request = "
186  << std::put_time(&buf, "%c")
187  << " + " << static_cast<float>(rhs.start_time_of_ROB_request.tv_usec)/1000 << " [ms]";
188 
189  const std::time_t e_time(rhs.end_time_of_ROB_request.tv_sec);
190  localtime_r(&e_time, &buf);
191  os << "\n" << prefix << "Stop time of ROB request = "
192  << std::put_time(&buf, "%c")
193  << " + " << static_cast<float>(rhs.end_time_of_ROB_request.tv_usec)/1000 << " [ms]";
194  os << "\n" << prefix << "Elapsed time for ROB request [ms] = " << rhs.elapsedTime();
195  os << "\n" << prefix << "Requested ROBs:";
196  os << "\n" << prefix << prefix2 << "All " << rhs.allROBs() ;
197  os << "\n" << prefix << prefix2 << "Unclassified " << rhs.unclassifiedROBs() ;
198  os << "\n" << prefix << prefix2 << "HLT Cached " << rhs.HLTcachedROBs() ;
199  os << "\n" << prefix << prefix2 << "DCM Cached " << rhs.DCMcachedROBs() ;
200  os << "\n" << prefix << prefix2 << "Retrieved " << rhs.retrievedROBs() ;
201  os << "\n" << prefix << prefix2 << "Ignored " << rhs.ignoredROBs() ;
202  os << "\n" << prefix << prefix2 << "Undefined " << rhs.undefinedROBs() ;
203  os << "\n" << prefix << prefix2 << "Status OK " << rhs.statusOkROBs() ;
204  for (std::map<const uint32_t,robmonitor::ROBDataStruct>::const_iterator it=rhs.requested_ROBs.begin();
205  it != rhs.requested_ROBs.end(); ++it) {
206  os << "\n" << prefix << prefix2 << (*it).second;
207  }
208  return os;
209  }
210 } // end namespace robmonitor
211 
213 
214 CLASS_DEF( ROBDataMonitorCollection , 1303465505 , 1 )
215 
216 
217 #endif /* ROBDATAMONITOR_H */
robmonitor::ROBDataMonitorStruct::retrievedROBs
unsigned retrievedROBs() const
number of retrieved ROBs in structure
Definition: ROBDataMonitor.cxx:117
robmonitor::UNDEFINED
@ UNDEFINED
Definition: ROBDataMonitor.h:32
robmonitor::ROBDataMonitorStruct::ROBDataMonitorStruct
ROBDataMonitorStruct()
default constructor
Definition: ROBDataMonitor.cxx:60
robmonitor::ROBDataMonitorStruct::start_time_of_ROB_request
struct timeval start_time_of_ROB_request
Definition: ROBDataMonitor.h:114
robmonitor::ROBDataMonitorStruct
The structure which is used to monitor the ROB data request in L2 It is created for every addROBData ...
Definition: ROBDataMonitor.h:81
robmonitor::ROBDataMonitorStruct::ignoredROBs
unsigned ignoredROBs() const
number of ignored ROBs in structure
Definition: ROBDataMonitor.cxx:125
robmonitor::ROBDataStruct
A structure with data about ROB properties.
Definition: ROBDataMonitor.h:39
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
robmonitor::ROBHistory
ROBHistory
A structure with data about ROB properties.
Definition: ROBDataMonitor.h:26
robmonitor::ROBDataMonitorStruct::ROBDataMonitorStruct
ROBDataMonitorStruct(const ROBDataMonitorStruct &)=default
robmonitor::DCM_CACHED
@ DCM_CACHED
Definition: ROBDataMonitor.h:30
skel.it
it
Definition: skel.GENtoEVGEN.py:396
robmonitor::ROBDataMonitorStruct::HLTcachedROBs
unsigned HLTcachedROBs() const
number of ROBDataProviderSvc cached ROBs in structure
Definition: ROBDataMonitor.cxx:101
robmonitor::ROBDataStruct::isIgnored
bool isIgnored() const
ROB was ignored.
Definition: ROBDataMonitor.cxx:44
robmonitor::ROBDataMonitorStruct::ROBDataMonitorStruct
ROBDataMonitorStruct(ROBDataMonitorStruct &&) noexcept=default
robmonitor::NUM_ROBHIST_CODES
@ NUM_ROBHIST_CODES
Definition: ROBDataMonitor.h:33
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
robmonitor::ROBDataStruct::rob_size
uint32_t rob_size
Definition: ROBDataMonitor.h:52
robmonitor::ROBDataStruct::isStatusOk
bool isStatusOk() const
ROB has no status words set.
Definition: ROBDataMonitor.cxx:52
ROBDataMonitorCollection
DataVector< robmonitor::ROBDataMonitorStruct > ROBDataMonitorCollection
Definition: ROBDataMonitor.h:212
robmonitor::ROBDataMonitorStruct::DCMcachedROBs
unsigned DCMcachedROBs() const
number of DCM cached ROBs in structure
Definition: ROBDataMonitor.cxx:109
robmonitor::ROBDataMonitorStruct::elapsedTime
float elapsedTime() const
elapsed time for ROB request in [ms]
Definition: ROBDataMonitor.cxx:149
robmonitor::ROBDataStruct::isDCMCached
bool isDCMCached() const
ROB was found in DCM cache.
Definition: ROBDataMonitor.cxx:36
robmonitor::ROBDataMonitorStruct::end_time
uint64_t end_time
Definition: ROBDataMonitor.h:119
robmonitor::IGNORED
@ IGNORED
Definition: ROBDataMonitor.h:31
robmonitor::ROBDataStruct::isUndefined
bool isUndefined() const
ROB was not enabled.
Definition: ROBDataMonitor.cxx:48
robmonitor::ROBDataStruct::rob_id
uint32_t rob_id
Definition: ROBDataMonitor.h:51
robmonitor::ROBDataMonitorStruct::undefinedROBs
unsigned undefinedROBs() const
number of undefined ROBs in structure
Definition: ROBDataMonitor.cxx:133
robmonitor::ROBDataStruct::ROBDataStruct
ROBDataStruct()
default constructor
Definition: ROBDataMonitor.cxx:14
robmonitor::ROBDataStruct::rob_status_word
uint32_t rob_status_word
Definition: ROBDataMonitor.h:54
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
robmonitor::ROBDataMonitorStruct::lvl1ID
uint32_t lvl1ID
Definition: ROBDataMonitor.h:109
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
robmonitor::ROBDataStruct::rob_history
robmonitor::ROBHistory rob_history
Definition: ROBDataMonitor.h:53
robmonitor::ROBDataStruct::isHLTCached
bool isHLTCached() const
ROB was found in ROBDataProviderSvc cache.
Definition: ROBDataMonitor.cxx:32
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
robmonitor::ROBDataMonitorStruct::statusOkROBs
unsigned statusOkROBs() const
number of ROBs with no status words set in structure
Definition: ROBDataMonitor.cxx:141
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
robmonitor::ROBDataStruct::operator<<
friend std::ostream & operator<<(std::ostream &os, const robmonitor::ROBDataStruct &rhs)
Definition: ROBDataMonitor.h:147
robmonitor::ROBDataMonitorStruct::start_time
uint64_t start_time
Definition: ROBDataMonitor.h:118
robmonitor
Definition: ROBDataMonitor.h:21
robmonitor::ROBDataStruct::isUnclassified
bool isUnclassified() const
ROB is unclassified.
Definition: ROBDataMonitor.cxx:28
robmonitor::ROBDataMonitorStruct::requestor_name
std::string requestor_name
Definition: ROBDataMonitor.h:110
robmonitor::RETRIEVED
@ RETRIEVED
Definition: ROBDataMonitor.h:28
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
robmonitor::HLT_CACHED
@ HLT_CACHED
Definition: ROBDataMonitor.h:29
robmonitor::ROBDataMonitorStruct::requested_ROBs
std::map< const uint32_t, robmonitor::ROBDataStruct > requested_ROBs
Definition: ROBDataMonitor.h:111
robmonitor::ROBDataMonitorStruct::operator<<
friend std::ostream & operator<<(std::ostream &os, const robmonitor::ROBDataMonitorStruct &rhs)
Definition: ROBDataMonitor.h:175
robmonitor::ROBDataMonitorStruct::unclassifiedROBs
unsigned unclassifiedROBs() const
number of unclassified ROBs in structure
Definition: ROBDataMonitor.cxx:93
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
robmonitor::ROBDataMonitorStruct::end_time_of_ROB_request
struct timeval end_time_of_ROB_request
Definition: ROBDataMonitor.h:115
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
CLASS_DEF.h
macros to associate a CLID to a type
robmonitor::UNCLASSIFIED
@ UNCLASSIFIED
Definition: ROBDataMonitor.h:27
robmonitor::ROBDataStruct::isRetrieved
bool isRetrieved() const
ROB was retrieved over network.
Definition: ROBDataMonitor.cxx:40
robmonitor::ROBDataMonitorStruct::allROBs
unsigned allROBs() const
number of ROBs in structure
Definition: ROBDataMonitor.cxx:89