ATLAS Offline Software
TrigMonSeq.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 // C/C++
6 #include <iostream>
7 #include <iomanip>
8 #include <sstream>
9 
12 
13 namespace SeqBits
14 {
15  const uint32_t maskLow16 = 0x0000ffff; // mask low 16 bits
16  const uint32_t maskIndex = 0xfff00000; // mask index bits
17  const uint32_t shiftIndex = 20;
18 }
19 
20 
21 // This is to work around an edm change
22 const static uint16_t LARGE_INDEX_SEQ_LOCATION = 321;
23 
24 //--------------------------------------------------------------------------------------
26  :m_encoded(0x0)
27 {
28 }
29 
30 //--------------------------------------------------------------------------------------
32  :m_encoded(encoded)
33 {
34 }
35 
36 //--------------------------------------------------------------------------------------
38  :m_encoded(chn.getEncodedId())
39 {
40  //
41  // Encoded index into
42  //
43  const uint32_t index = seq.getIndex();
44  if(index >= 4096) {
45  // EDM limitation workaround with big run-2 menus
46  m_var_key.push_back(LARGE_INDEX_SEQ_LOCATION);
47  m_var_val.push_back((float) index); // This is not going to get so large that we'll loose info in a float
48  }
49  else {
51  }
52 }
53 
54 //--------------------------------------------------------------------------------------
56 {
57  //
58  // Store variable as int and float, reserve 0-9 keys
59  //
60  if(var.getKey() > 9) {
61  m_var_key.push_back(var.getKey());
62  m_var_val.push_back(var.getData());
63  }
64 }
65 
66 //--------------------------------------------------------------------------------------
68 {
69  //
70  // Add sequence timer at key = 0
71  //
72  m_var_key.push_back(0);
73  m_var_val.push_back(timer);
74 }
75 
76 //--------------------------------------------------------------------------------------
78 {
79  //
80  // Make OR with State enum value (already at correct bit position)
81  //
82  m_encoded |= value;
83 }
84 
85 //--------------------------------------------------------------------------------------
87 {
88  //
89  // Check value of SEQ State enum
90  //
91  return (m_encoded & kInitial);
92 }
93 
94 //--------------------------------------------------------------------------------------
96 {
97  //
98  // Check value of SEQ State enum
99  //
100  return (m_encoded & kStart);
101 }
102 
103 //--------------------------------------------------------------------------------------
105 {
106  //
107  // Check value of SEQ State enum
108  //
109  return (m_encoded & kAlreadyExecuted);
110 }
111 
112 //--------------------------------------------------------------------------------------
114 {
115  //
116  // Check value of SEQ State enum
117  //
118  return (m_encoded & kPrevious);
119 }
120 
121 //--------------------------------------------------------------------------------------
123 {
125 }
126 
127 //--------------------------------------------------------------------------------------
129 {
131 }
132 
133 //--------------------------------------------------------------------------------------
135 {
136  //
137  // Mask out low 16 bits and return encoded chain id
138  //
139  return (m_encoded & SeqBits::maskLow16);
140 }
141 
142 //--------------------------------------------------------------------------------------
144 {
145  //
146  // Mask out SEQ State enum bits and return index
147  //
148  // Check it's not stored in the hack way first
149  for (uint32_t i=0; i < m_var_key.size(); ++i) {
150  if (m_var_key.at(i) == LARGE_INDEX_SEQ_LOCATION) return (uint16_t) m_var_val.at(i);
151  }
153 }
154 
155 //--------------------------------------------------------------------------------------
157 {
158  //
159  // Explicit loop over timers to get total time measures by algorithms
160  //
161  if(m_alg.empty()) return 0.0;
162 
163  double timer_sum = 0.0;
164  for(unsigned int i = 0; i < m_alg.size(); ++i) timer_sum += m_alg[i].getTimer();
165 
166  return timer_sum;
167 }
168 
169 //--------------------------------------------------------------------------------------
171 {
172  //
173  // Get sequence timer which is stored at key=0
174  //
175 
176  if(m_var_key.size() == m_var_val.size()) {
177  //
178  // Look for key == 0
179  //
180  for(unsigned int i = 0; i < m_var_key.size(); ++i) {
181  if(m_var_key[i] == 0) return m_var_val[i];
182  }
183  }
184 
185  return 0.0;
186 }
187 
188 //--------------------------------------------------------------------------------------
189 const std::vector<TrigMonVar> TrigMonSeq::getVar() const
190 {
191  //
192  // Build variables on a fly and return vector by value
193  //
194  std::vector<TrigMonVar> var;
195 
196  if(m_var_key.size() == m_var_val.size()) {
197  //
198  // Iterate over keys abd values
199  //
200  var.reserve(m_var_key.size());
201 
202  for(unsigned int i = 0; i < m_var_key.size(); ++i) {
203  if(m_var_key[i] != 0) {
204  var.push_back(TrigMonVar(m_var_key[i], m_var_val[i]));
205  }
206  }
207  }
208 
209  return var;
210 }
211 
212 //--------------------------------------------------------------------------------------
213 void TrigMonSeq::print(const TrigConfSeq &confg, std::ostream &os) const
214 {
215  //
216  // Print payload
217  //
218  if(confg.getIndex() != getSeqIndex()) {
219  os << "TrigMonSeq::Print - error configuration does not match this sequence\n";
220  return;
221  }
222 
223  std::stringstream st;
224 
225  st << "TrigMonSeq: " << confg.getName()
226  << " isExecuted=" << int(isExecuted())
227  << " isAlreadyExecuted=" << int(isAlreadyExecuted())
228  << " isInitial=" << int(isInitial())
229  << " isPrevious=" << int(isPrevious()) << "\n"
230  << " t_seq-t_alg=" << getSeqTimer() << "-" << getAlgTimer() << "="
231  << getSeqTimer() - getAlgTimer()
232  << " SEQ contains " << m_alg.size() << " algorithm(s)"
233  << "\n";
234 
235  unsigned int iwidth = 0;
236  for(unsigned int j = 0; j < m_alg.size(); ++j) {
237  const TrigMonAlg &alg_entry = m_alg[j];
238  const TrigConfAlg &alg_confg = confg.getAlg(alg_entry.getPosition());
239 
240  iwidth = std::max<unsigned int>(iwidth, alg_confg.getName().size());
241  }
242 
243  for(unsigned int j = 0; j < m_alg.size(); ++j) {
244  const TrigMonAlg &alg_entry = m_alg[j];
245  const TrigConfAlg &alg_confg = confg.getAlg(alg_entry.getPosition());
246 
247  st << " " << std::setw(2) << std::setfill(' ') << std::right << j << ": "
248  << std::setw(iwidth) << std::left << alg_confg.getName()
249  << " isCached=" << int(alg_entry.isCached())
250  << " timer=" << alg_entry.elapsed()
251  << " RoiId=";
252 
253  for(unsigned int r = 0; r < alg_entry.getNRoi(); ++r) {
254  st << static_cast<unsigned int>(alg_entry.getRoiId(r)) << " ";
255  }
256 
257  if(alg_entry.isCalled()) {
258  st << " t1-t0="
259  << alg_entry.start().getSec() << "." << alg_entry.start().getMicroSec()
260  << "-"
261  << alg_entry.stop().getSec() << "." << alg_entry.stop().getMicroSec()
262  << "="
263  << alg_entry.elapsed();
264  }
265 
266  st << "\n";
267  }
268 
269  os << st.str();
270 }
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
beamspotman.r
def r
Definition: beamspotman.py:676
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
TrigMonAlg::isCached
bool isCached() const
Definition: TrigMonAlg.cxx:136
TrigMonSeq::print
void print(const TrigConfSeq &confg, std::ostream &os=std::cout) const
Definition: TrigMonSeq.cxx:213
TrigMonSeq::kStart
@ kStart
Definition: TrigMonSeq.h:34
TrigMonSeq::getSeqIndex
uint16_t getSeqIndex() const
Definition: TrigMonSeq.cxx:143
TrigMonAlg::getRoiId
uint8_t getRoiId(unsigned int i=0) const
Definition: TrigMonAlg.cxx:116
TrigMonAlg::getNRoi
uint8_t getNRoi() const
Definition: TrigMonAlg.cxx:107
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigMonSeq::getLevel
uint16_t getLevel() const
Definition: TrigMonSeq.cxx:122
TrigMonSeq::getVar
const std::vector< TrigMonVar > getVar() const
Definition: TrigMonSeq.cxx:189
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
TrigMonSeq::kPrevious
@ kPrevious
Definition: TrigMonSeq.h:36
TrigMonSeq::isInitial
bool isInitial() const
Definition: TrigMonSeq.cxx:86
athena.value
value
Definition: athena.py:122
TrigMonAlg::elapsed
double elapsed() const
Definition: TrigMonAlg.h:57
TrigMonSeq::kAlreadyExecuted
@ kAlreadyExecuted
Definition: TrigMonSeq.h:35
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
TrigMonSeq.h
TrigMonSeq::State
State
Definition: TrigMonSeq.h:31
TrigMonTimer::getSec
uint32_t getSec() const
Definition: TrigMonTimer.cxx:61
TrigMonSeq::m_var_key
std::vector< uint16_t > m_var_key
Definition: TrigMonSeq.h:77
TrigMonSeq::isExecuted
bool isExecuted() const
Definition: TrigMonSeq.cxx:95
TrigMonSeq::kInitial
@ kInitial
Definition: TrigMonSeq.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
TrigConfChain
Definition: TrigConfChain.h:32
TrigMonAlg::stop
const TrigMonTimer stop() const
Definition: TrigMonAlg.cxx:167
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigConfSeq
Definition: TrigConfSeq.h:29
TrigConfAlg
Definition: TrigConfAlg.h:25
TrigMonVar
Definition: TrigMonVar.h:59
Trig::getCounterFromEncodedId
uint16_t getCounterFromEncodedId(uint16_t encoded)
Definition: TrigConfChain.h:158
SeqBits::shiftIndex
const uint32_t shiftIndex
Definition: TrigMonSeq.cxx:17
TrigConfSeq::getIndex
uint16_t getIndex() const
Definition: TrigConfSeq.h:42
TrigMonTimer::getMicroSec
uint32_t getMicroSec() const
Definition: TrigMonTimer.cxx:68
TrigConfAlg::getName
const std::string & getName() const
Definition: TrigConfAlg.h:39
TrigMonSeq::getChnEncodedId
uint16_t getChnEncodedId() const
Definition: TrigMonSeq.cxx:134
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
TrigMonSeq::m_var_val
std::vector< float > m_var_val
Definition: TrigMonSeq.h:78
TrigMonAlg::isCalled
bool isCalled() const
Definition: TrigMonAlg.cxx:145
SeqBits
Definition: TrigMonSeq.cxx:14
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TrigMonSeq::m_encoded
uint32_t m_encoded
Definition: TrigMonSeq.h:75
SeqBits::maskLow16
const uint32_t maskLow16
Definition: TrigMonSeq.cxx:15
TrigMonSeq::getSeqTimer
float getSeqTimer() const
Definition: TrigMonSeq.cxx:170
TrigMonAlg::start
const TrigMonTimer start() const
Definition: TrigMonAlg.cxx:154
TrigMonSeq::addTimer
void addTimer(float timer)
Definition: TrigMonSeq.cxx:67
Trig::getLevelFromEncodedId
uint16_t getLevelFromEncodedId(uint16_t encoded)
Definition: TrigConfChain.h:161
TrigMonSeq::getChnCounter
uint16_t getChnCounter() const
Definition: TrigMonSeq.cxx:128
TrigMonSeq::m_alg
std::vector< TrigMonAlg > m_alg
Definition: TrigMonSeq.h:76
TrigConfSeq::getName
const std::string & getName() const
Definition: TrigConfSeq.h:44
SeqBits::maskIndex
const uint32_t maskIndex
Definition: TrigMonSeq.cxx:16
TrigMonAlg::getPosition
uint8_t getPosition() const
Definition: TrigMonAlg.cxx:98
TrigMonAlg
Summary of single agorithm execution. Algorithm is identified by position within parent sequence....
Definition: TrigMonAlg.h:30
TrigMonSeq::isAlreadyExecuted
bool isAlreadyExecuted() const
Definition: TrigMonSeq.cxx:104
TrigMonSeq::TrigMonSeq
TrigMonSeq()
Definition: TrigMonSeq.cxx:25
TrigConfSeq::getAlg
const TrigConfAlg & getAlg(unsigned int pos) const
Definition: TrigConfSeq.cxx:44
TrigMonSeq::addState
void addState(State value)
Definition: TrigMonSeq.cxx:77
Trig::getEncodedId
uint16_t getEncodedId(int level, int counter)
Definition: TrigConfChain.cxx:15
TrigMonSeq::isPrevious
bool isPrevious() const
Definition: TrigMonSeq.cxx:113
TrigMonSeq::addVar
void addVar(const TrigMonVar &var)
Definition: TrigMonSeq.cxx:55
TrigMonSeq::getAlgTimer
double getAlgTimer() const
Definition: TrigMonSeq.cxx:156