ATLAS Offline Software
TrigMonEvent.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 <algorithm>
7 #include <cmath>
8 
9 // Local
11 
12 namespace EventBits
13 {
14  const uint32_t maskLumi = 0x0000ffff;
15  const uint32_t maskBxid = 0xffff0000;
16  const uint32_t shftBxid = 16;
17 
18  static const unsigned TrigMonEventVersion = 2;
19 }
20 
21 using namespace std;
22 
23 //--------------------------------------------------------------------------------------
24 // Helper function for decoding/encoding event content
25 //
27  return EventBits::TrigMonEventVersion;
28 }
29 
30 //--------------------------------------------------------------------------------------
32  :m_event(0),
33  m_lumi(0),
34  m_bxid(0),
35  m_run(0),
36  m_sec(0),
37  m_nsec(0)
38 {
39 }
40 
41 //--------------------------------------------------------------------------------------
43 {
44  //
45  // Erase all event data
46  //
47  m_event = 0;
48  m_lumi = 0;
49  m_bxid = 0;
50  m_run = 0;
51  m_sec = 0;
52  m_nsec = 0;
53 
54  m_word.clear();
55  m_rob.clear();
56  m_roi.clear();
57  m_seq.clear();
58  m_te.clear();
59  m_l1.clear();
60  m_hlt.clear();
61  m_var_key.clear();
62  m_var_val.clear();
63 }
64 
65 //--------------------------------------------------------------------------------------
67  uint32_t lumi,
68  uint32_t bxid,
69  uint32_t run,
70  uint32_t sec,
71  uint32_t nsec)
72 {
73  //
74  // Fill EventID data
75  //
76  m_event = event;
77  m_run = run;
78  m_sec = sec;
79  m_nsec = nsec;
80 
81  //
82  // Pack luminosity block and bunch crossing id into m_lumi variable
83  //
84  m_lumi = 0;
86  m_lumi |= bxid << EventBits::shftBxid;
87 
88  /*
89  cout << "TrigMonEvent::setEventID -"
90  << " lumi=" << lumi << "=" << getLumi()
91  << " bxid=" << bxid << "=" << getBunchId() << endl;
92  */
93 }
94 
95 //--------------------------------------------------------------------------------------
97 {
98  //
99  // Convert timer to int with 0.1ms precision and 4.0e5s maximum: stored in m_bxid variable
100  //
101  timer *= 10.0;
102 
103  if(timer > 4.0e9) timer = 4.0e9;
104 
105  const float timerI = std::floor(timer);
106 
107  if(timer - timerI > 0.499) {
108  timer = timerI + 1;
109  }
110  else {
111  timer = timerI;
112  }
113 
114  m_bxid = static_cast<uint32_t>(timer);
115 }
116 
117 //--------------------------------------------------------------------------------------
119 {
120  //
121  // Read timer stored as m_bxid variable
122  //
123  return static_cast<float>(m_bxid)/10.0;
124 }
125 
126 //--------------------------------------------------------------------------------------
128 {
129  return (m_lumi & EventBits::maskLumi);
130 }
131 
132 //--------------------------------------------------------------------------------------
134 {
136 }
137 
138 //--------------------------------------------------------------------------------------
140 {
141  //
142  // Add new variable
143  //
144  m_var_key.push_back(key);
145  m_var_val.push_back(var);
146 }
147 
148 //--------------------------------------------------------------------------------------
150 {
151  //
152  // Get float variable
153  //
154  if(m_var_val.size() != m_var_key.size()) return false;
155 
156  for(unsigned int i = 0; i < m_var_key.size(); ++i) {
157  if(key == m_var_key[i]) {
158  var = m_var_val[i];
159  return true;
160  }
161  }
162 
163  return false;
164 }
165 
166 //--------------------------------------------------------------------------------------
168 {
169  //
170  // Get int variable
171  //
172  if(m_var_val.size() != m_var_key.size()) return false;
173 
174  for(unsigned int i = 0; i < m_var_val.size(); ++i) {
175  if(var == m_var_val[i]) {
176  key = m_var_key[i];
177  return true;
178  }
179  }
180 
181  return false;
182 }
183 
184 //--------------------------------------------------------------------------------------
185 const std::vector<TrigMonL1Item> TrigMonEvent::getL1Items() const
186 {
187  //
188  // Build variables on a fly and return vector by value
189  //
190  std::vector<TrigMonL1Item> l1vec;
191 
192  //
193  // Iterate over encoded items
194  //
195  l1vec.reserve(m_l1.size());
196 
197  for(unsigned int i = 0; i < m_l1.size(); ++i) {
198  l1vec.push_back(TrigMonL1Item(m_l1[i]));
199  }
200 
201  return l1vec;
202 }
203 
204 //--------------------------------------------------------------------------------------
205 const std::vector<TrigMonChain> TrigMonEvent::getChains() const
206 {
207  //
208  // Build variables on a fly and return vector by value
209  //
210  std::vector<TrigMonChain> chvec;
211 
212  //
213  // Iterate over chains
214  //
215  chvec.reserve(m_hlt.size());
216 
217  for(unsigned int i = 0; i < m_hlt.size(); ++i) {
218  chvec.push_back(TrigMonChain(m_hlt[i]));
219  }
220 
221  return chvec;
222 }
223 
224 //--------------------------------------------------------------------------------------
225 const std::vector<TrigMonVar> TrigMonEvent::getVar() const
226 {
227  //
228  // Build variables on a fly and return vector by value
229  //
230  std::vector<TrigMonVar> var;
231 
232  if(m_var_key.size() == m_var_val.size()) {
233  //
234  // Iterate over keys abd values
235  //
236  var.reserve(m_var_key.size());
237 
238  for(unsigned int i = 0; i < m_var_key.size(); ++i) {
239  var.push_back(TrigMonVar(m_var_key[i], m_var_val[i]));
240  }
241  }
242 
243  return var;
244 }
TrigMonEvent::m_nsec
uint32_t m_nsec
Definition: TrigMonEvent.h:109
TrigMonEvent::m_lumi
uint32_t m_lumi
Definition: TrigMonEvent.h:105
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
TrigMonEvent::m_event
uint32_t m_event
Definition: TrigMonEvent.h:104
TrigMonEvent::TrigMonEvent
TrigMonEvent()
Definition: TrigMonEvent.cxx:31
TrigMonEvent::m_hlt
std::vector< uint32_t > m_hlt
Definition: TrigMonEvent.h:120
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TrigMonEvent::m_bxid
uint32_t m_bxid
Definition: TrigMonEvent.h:106
EventBits
Definition: TrigMonEvent.cxx:13
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
TrigMonEvent::m_word
std::vector< uint32_t > m_word
Definition: TrigMonEvent.h:110
TrigMonEvent::clear
void clear()
Definition: TrigMonEvent.cxx:42
TrigMonEvent::m_var_key
std::vector< uint32_t > m_var_key
Definition: TrigMonEvent.h:123
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
TrigMonEvent::m_rob
std::vector< TrigMonROB > m_rob
Definition: TrigMonEvent.h:113
TrigMonEvent::getTimer
float getTimer() const
Definition: TrigMonEvent.cxx:118
TrigMonEvent::getBunchId
uint32_t getBunchId() const
Definition: TrigMonEvent.cxx:133
TrigMonEvent::getKey
bool getKey(uint32_t &key, float var) const
Definition: TrigMonEvent.cxx:167
TrigMonEvent::getChains
const std::vector< TrigMonChain > getChains() const
Definition: TrigMonEvent.cxx:205
TrigMonEvent.h
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigMonVar
Definition: TrigMonVar.h:59
EventBits::shftBxid
const uint32_t shftBxid
Definition: TrigMonEvent.cxx:16
run
Definition: run.py:1
TrigMonEvent::setEventID
void setEventID(uint32_t event, uint32_t lumi, uint32_t bxid, uint32_t run, uint32_t sec, uint32_t nsec)
Definition: TrigMonEvent.cxx:66
TrigMonEvent::addVar
void addVar(uint32_t key, float var)
Definition: TrigMonEvent.cxx:139
TrigMonEvent::m_run
uint32_t m_run
Definition: TrigMonEvent.h:107
TrigMonEvent::m_roi
std::vector< TrigMonRoi > m_roi
Definition: TrigMonEvent.h:114
TrigMonEvent::getL1Items
const std::vector< TrigMonL1Item > getL1Items() const
Definition: TrigMonEvent.cxx:185
TrigMonEvent::m_l1
std::vector< uint16_t > m_l1
Definition: TrigMonEvent.h:119
EventBits::maskLumi
const uint32_t maskLumi
Definition: TrigMonEvent.cxx:14
TrigMonEvent::m_te
std::vector< TrigMonTE > m_te
Definition: TrigMonEvent.h:116
EventBits::maskBxid
const uint32_t maskBxid
Definition: TrigMonEvent.cxx:15
getTrigMonEventVersion
unsigned getTrigMonEventVersion()
Definition: TrigMonEvent.cxx:26
TrigMonEvent::m_sec
uint32_t m_sec
Definition: TrigMonEvent.h:108
TrigMonEvent::getLumi
uint32_t getLumi() const
Definition: TrigMonEvent.cxx:127
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
TrigMonChain
Summary of chain decisions.
Definition: TrigMonChain.h:26
TrigMonEvent::getVar
const std::vector< TrigMonVar > getVar() const
Definition: TrigMonEvent.cxx:225
TrigMonL1Item
Encoded L1 decision for one item.
Definition: TrigMonL1Item.h:25
TrigMonEvent::m_seq
std::vector< TrigMonSeq > m_seq
Definition: TrigMonEvent.h:115
TrigMonEvent::m_var_val
std::vector< float > m_var_val
Definition: TrigMonEvent.h:124
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
TrigMonEvent::setTimer
void setTimer(float timer)
Definition: TrigMonEvent.cxx:96