CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GlobalTriggerEvmReadoutRecord.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <iomanip>
22 #include <bitset>
23 #include <stdint.h>
24 
25 // user include files
26 
27 
30 
31 // constructors
33 {
34 
36  m_tcsWord = L1TcsWord();
37 
38  // reserve just one L1GtFdlWord
39  m_gtFdlWord.reserve(1);
40 
41 }
42 
44 {
45 
47  m_tcsWord = L1TcsWord();
48 
49  m_gtFdlWord.reserve(NumberBxInEvent);
50  m_gtFdlWord.assign(NumberBxInEvent, L1GtFdlWord());
51 
52  // min value of bxInEvent
53  int minBxInEvent = (NumberBxInEvent + 1)/2 - NumberBxInEvent;
54  //int maxBxInEvent = (NumberBxInEvent + 1)/2 - 1; // not needed
55 
56  // matrix index [0, NumberBxInEvent) -> bxInEvent [minBxInEvent, maxBxInEvent]
57  // warning: matrix index != bxInEvent
58  for (int iFdl = 0; iFdl < NumberBxInEvent; ++iFdl) {
59  int iBxInEvent = minBxInEvent + iFdl;
60  m_gtFdlWord[iFdl].setBxInEvent(iBxInEvent);
61  }
62 
63 }
64 
66  const int numberBxInEvent,
67  const int numberFdlBoards)
68 {
69 
70  // GTFE board
72 
73  // TCS board
74  m_tcsWord = L1TcsWord();
75 
76  // FDL board
77  if (numberFdlBoards > 0) {
78  m_gtFdlWord.reserve(numberBxInEvent);
79  }
80 
81 }
82 
83 
84 // copy constructor
87 {
88 
89  m_gtfeWord = result.m_gtfeWord;
90  m_tcsWord = result.m_tcsWord;
91  m_gtFdlWord = result.m_gtFdlWord;
92 
93 }
94 
95 // destructor
97 {
98 
99  // empty now
100 
101 }
102 
103 // assignment operator
106 {
107 
108  if ( this != &result ) {
109 
110  m_gtfeWord = result.m_gtfeWord;
111  m_tcsWord = result.m_tcsWord;
112  m_gtFdlWord = result.m_gtFdlWord;
113 
114  }
115 
116  return *this;
117 
118 }
119 
120 // equal operator
123 {
124 
125  if (m_gtfeWord != result.m_gtfeWord) {
126  return false;
127  }
128 
129  if (m_tcsWord != result.m_tcsWord) {
130  return false;
131  }
132 
133  if (m_gtFdlWord != result.m_gtFdlWord) {
134  return false;
135  }
136 
137  // all members identical
138  return true;
139 
140 }
141 
142 // unequal operator
145 {
146 
147  return !( result == *this);
148 
149 }
150 // methods
151 
152 
153 // get Global Trigger decision and the decision word
154 // general bxInEvent
155 const bool L1GlobalTriggerEvmReadoutRecord::decision(int bxInEventValue) const
156 {
157 
158  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
159  itBx != m_gtFdlWord.end(); ++itBx) {
160 
161  if ( (*itBx).bxInEvent() == bxInEventValue ) {
162  return (*itBx).finalOR();
163  }
164  }
165 
166  // if bunch cross not found, throw exception (action: SkipEvent)
167 
168  throw cms::Exception("NotFound")
169  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
170  << "Can not return global decision for this bx!\n"
171  << std::endl;
172 
173  return false;
174 }
175 
177  int bxInEventValue) const
178 {
179 
180  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
181  itBx != m_gtFdlWord.end(); ++itBx) {
182 
183  if ( (*itBx).bxInEvent() == bxInEventValue ) {
184  return (*itBx).gtDecisionWord();
185  }
186  }
187 
188  // if bunch cross not found, throw exception (action: SkipEvent)
189 
190  throw cms::Exception("NotFound")
191  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
192  << "Can not return decision word for this bx!\n"
193  << std::endl;
194 
195  DecisionWord dW; // empty; it does not arrive here
196  return dW;
197 }
198 
199 // bxInEvent = 0
201 {
202 
203  int bxInEventL1Accept = 0;
204  return decision(bxInEventL1Accept);
205 }
206 
207 const DecisionWord
209 {
210 
211  int bxInEventL1Accept = 0;
212  return decisionWord(bxInEventL1Accept);
213 }
214 
215 
216 // set global decision and the decision word
217 // general
218 void L1GlobalTriggerEvmReadoutRecord::setDecision(bool t, int bxInEventValue)
219 {
220 
221  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
222  itBx != m_gtFdlWord.end(); ++itBx) {
223 
224  if ( (*itBx).bxInEvent() == bxInEventValue ) {
225  (*itBx).setFinalOR(static_cast<uint16_t> (t)); // TODO FIXME when manipulating partitions
226  }
227  }
228 
229  // if bunch cross not found, throw exception (action: SkipEvent)
230 
231  throw cms::Exception("NotFound")
232  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
233  << "Can not set global decision for this bx!\n"
234  << std::endl;
235 
236 }
237 
239  const DecisionWord& decisionWordValue,
240  int bxInEventValue)
241 {
242 
243  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
244  itBx != m_gtFdlWord.end(); ++itBx) {
245 
246  if ( (*itBx).bxInEvent() == bxInEventValue ) {
247  (*itBx).setGtDecisionWord (decisionWordValue);
248  }
249  }
250 
251  // if bunch cross not found, throw exception (action: SkipEvent)
252 
253  throw cms::Exception("NotFound")
254  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
255  << "Can not set decision word for this bx!\n"
256  << std::endl;
257 
258 }
259 
260 // bxInEvent = 0
262 {
263 
264  int bxInEventL1Accept = 0;
265  setDecision(t, bxInEventL1Accept);
266 }
267 
269  const DecisionWord& decisionWordValue)
270 {
271 
272  int bxInEventL1Accept = 0;
273  setDecisionWord(decisionWordValue, bxInEventL1Accept);
274 
275 }
276 
277 // print global decision and algorithm decision word
279  std::ostream& myCout, int bxInEventValue) const
280 {
281 
282  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
283  itBx != m_gtFdlWord.end(); ++itBx) {
284 
285  if ( (*itBx).bxInEvent() == bxInEventValue ) {
286 
287  myCout << "\nL1 Global Trigger Record: " << std::endl;
288 
289  myCout
290  << "\t Bunch cross " << bxInEventValue
291  << std::endl
292  << "\t Global Decision = " << std::setw(5) << (*itBx).globalDecision()
293  << std::endl
294  << "\t Decision word (bitset style) = ";
295 
296  (*itBx).printGtDecisionWord(myCout);
297  }
298  }
299 
300  myCout << std::endl;
301 
302 }
303 
304 void L1GlobalTriggerEvmReadoutRecord::printGtDecision(std::ostream& myCout) const
305 {
306 
307  int bxInEventL1Accept = 0;
308  printGtDecision(myCout, bxInEventL1Accept);
309 
310 }
311 
312 // print technical trigger word (reverse order for vector<bool>)
314  std::ostream& myCout, int bxInEventValue
315 ) const
316 {
317 
318  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
319  itBx != m_gtFdlWord.end(); ++itBx) {
320 
321  if ( (*itBx).bxInEvent() == bxInEventValue ) {
322 
323  myCout << "\nL1 Global Trigger Record: " << std::endl;
324 
325  myCout
326  << "\t Bunch cross " << bxInEventValue
327  << std::endl
328  << "\t Technical Trigger word (bitset style) = ";
329 
330  (*itBx).printGtTechnicalTriggerWord(myCout);
331  }
332  }
333 
334  myCout << std::endl;
335 
336 }
337 
339 {
340 
341  int bxInEventL1Accept = 0;
342  printTechnicalTrigger(myCout, bxInEventL1Accept);
343 
344 }
345 
346 // get/set hardware-related words
347 
348 // get / set GTFE word (record) in the GT readout record
350 {
351 
352  return m_gtfeWord;
353 
354 }
355 
357 {
358 
359  m_gtfeWord = gtfeWordValue;
360 
361 }
362 
363 // get / set TCS word (record) in the GT readout record
365 {
366 
367  return m_tcsWord;
368 
369 }
370 
372 {
373 
374  m_tcsWord = tcsWordValue;
375 
376 }
377 
378 // get / set FDL word (record) in the GT readout record
380 {
381 
382  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
383  itBx != m_gtFdlWord.end(); ++itBx) {
384 
385  if ( (*itBx).bxInEvent() == bxInEventValue ) {
386  return (*itBx);
387  }
388  }
389 
390  // if bunch cross not found, throw exception (action: SkipEvent)
391 
392  throw cms::Exception("NotFound")
393  << "\nError: requested L1GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
394  << std::endl;
395 
396  // return empty record - actually does not arrive here
397  return L1GtFdlWord();
398 
399 }
400 
402 {
403 
404  int bxInEventL1Accept = 0;
405  return gtFdlWord(bxInEventL1Accept);
406 }
407 
409  const L1GtFdlWord& gtFdlWordValue, int bxInEventValue)
410 {
411 
412  // if a L1GtFdlWord exists for bxInEventValue, replace it
413  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
414  itBx != m_gtFdlWord.end(); ++itBx) {
415 
416  if ( (*itBx).bxInEvent() == bxInEventValue ) {
417  *itBx = gtFdlWordValue;
418  LogDebug("L1GlobalTriggerEvmReadoutRecord")
419  << "Replacing L1GtFdlWord for bunch bx = " << bxInEventValue << "\n"
420  << std::endl;
421  return;
422  }
423  }
424 
425  // if bunch cross not found, throw exception (action: SkipEvent)
426  // all L1GtFdlWord are created in the record constructor for allowed bunch crosses
427 
428  throw cms::Exception("NotFound")
429  << "\nError: Cannot set L1GtFdlWord for bx = " << bxInEventValue
430  << std::endl;
431 
432 }
433 
435 {
436 
437  // just push back the new FDL block
438  m_gtFdlWord.push_back(gtFdlWordValue);
439 
440 }
441 
442 
443 // other methods
444 
445 // clear the record
447 {
448 
449  // TODO FIXME clear GTFE, TCS, FDL?
450 
451 }
452 
454 void L1GlobalTriggerEvmReadoutRecord::print(std::ostream& myCout) const
455 {
456 
457  myCout << "\n L1GlobalTriggerEvmReadoutRecord::print \n" << std::endl;
458 
459  m_gtfeWord.print(myCout);
460 
461  m_tcsWord.print(myCout);
462 
463  for (std::vector<L1GtFdlWord>::const_iterator itFdl = m_gtFdlWord.begin();
464  itFdl != m_gtFdlWord.end(); ++itFdl) {
465 
466  itFdl->print(myCout);
467 
468  }
469 
470 }
471 
472 
473 // output stream operator
474 std::ostream& operator<<(std::ostream& s, const L1GlobalTriggerEvmReadoutRecord& result)
475 {
476  // TODO FIXME put together all prints
477  s << "Not available yet - sorry";
478 
479  return s;
480 
481 }
#define LogDebug(id)
void printTechnicalTrigger(std::ostream &myCout, int bxInEventValue) const
print technical triggers
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
const L1TcsWord tcsWord() const
get / set TCS word (record) in the GT readout record
bool operator==(const L1GlobalTriggerEvmReadoutRecord &) const
equal operator
void print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerEvmReadoutRecord
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void setDecisionWord(const DecisionWord &decisionWordValue, int bxInEvent)
bool operator!=(const L1GlobalTriggerEvmReadoutRecord &) const
unequal operator
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
Definition: L1TcsWord.cc:405
L1GlobalTriggerEvmReadoutRecord & operator=(const L1GlobalTriggerEvmReadoutRecord &)
assignment operator
std::vector< bool > DecisionWord
typedefs
void setDecision(bool t, int bxInEvent)
set global decision and the decision word
tuple result
Definition: query.py:137
void setGtFdlWord(const L1GtFdlWord &, int bxInEvent)
void printGtDecision(std::ostream &myCout, int bxInEventValue) const
print global decision and algorithm decision word
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeExtWord