CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalUMNioDigi.cc
Go to the documentation of this file.
2 #include <iostream>
3 
5 HcalUMNioDigi::HcalUMNioDigi(const uint16_t* ptr, int words) {
6  payload_.reserve(words);
7  for (int i = 0; i < words; i++) {
8  payload_.push_back(ptr[i]);
9  }
10 }
11 HcalUMNioDigi::HcalUMNioDigi(const std::vector<uint16_t>& words) : payload_(words) {}
12 
13 uint32_t HcalUMNioDigi::runNumber() const {
14  if (invalid())
15  return 0;
16  return payload_[9] + (uint32_t(payload_[10]) << 16);
17 }
18 
19 uint32_t HcalUMNioDigi::orbitNumber() const {
20  if (invalid())
21  return 0;
22  return payload_[5] + (uint32_t(payload_[8]) << 16);
23 }
24 uint16_t HcalUMNioDigi::bunchNumber() const {
25  if (invalid())
26  return 0;
27  return (payload_[1] >> 4) & 0xFFF;
28 }
29 uint32_t HcalUMNioDigi::eventNumber() const {
30  if (invalid())
31  return 0;
32  return payload_[2] + (uint32_t(payload_[3] & 0xFF) << 16);
33 }
34 
35 uint8_t HcalUMNioDigi::eventType() const {
36  if (invalid())
37  return 0;
38  return (payload_[6] >> 8) & 0xF;
39 }
40 uint16_t HcalUMNioDigi::spillCounter() const {
41  if (invalid())
42  return 0;
43  return (payload_[11]) & 0x7FFF;
44 }
45 bool HcalUMNioDigi::isSpill() const {
46  if (invalid())
47  return false;
48  return (payload_[11] & 0x8000);
49 }
50 
52  if (invalid())
53  return 0;
54  return (payload_[12] & 0xFF);
55 }
56 
57 uint16_t HcalUMNioDigi::idUserWord(int iword) const {
58  if (iword >= numberUserWords() || payload_.size() < (size_t)(16 + iword * 3))
59  return 0;
60  return payload_[13 + 3 * iword];
61 }
62 uint32_t HcalUMNioDigi::valueUserWord(int iword) const {
63  if (iword >= numberUserWords() || payload_.size() < (size_t)(16 + iword * 3))
64  return 0;
65  return payload_[14 + 3 * iword] + (uint32_t(payload_[15 + 3 * iword]) << 16);
66 }
67 bool HcalUMNioDigi::hasUserWord(int id) const {
68  uint32_t dummy;
69  return getUserWord(id, dummy);
70 }
71 uint32_t HcalUMNioDigi::getUserWord(int id) const {
72  uint32_t dummy(0);
73  getUserWord(id, dummy);
74  return dummy;
75 }
76 bool HcalUMNioDigi::getUserWord(int id, uint32_t& value) const {
77  int nwords = numberUserWords();
78  if (size_t(16 + nwords * 3) > payload_.size())
79  return false; // invalid format...
80 
81  for (int i = 0; i < nwords; i++) {
82  if (payload_[14 + 3 * i] == id) {
83  value = payload_[15 + 3 * i] + (uint32_t(payload_[16 + 3 * i]) << 16);
84  return true;
85  }
86  }
87  return false;
88 }
89 
90 std::ostream& operator<<(std::ostream& s, const HcalUMNioDigi& digi) {
91  s << "HcalUMNioDigi orbit/bunch " << digi.orbitNumber() << "/" << digi.bunchNumber() << std::endl;
92  s << " run/l1a " << digi.runNumber() << "/" << digi.eventNumber() << std::endl;
93  s << " eventType " << digi.eventType() << std::endl;
94  for (int i = 0; i < digi.numberUserWords(); i++)
95  s << " id=" << digi.idUserWord(i) << " value=" << digi.valueUserWord(i) << std::endl;
96  return s;
97 }
bool isSpill() const
uint32_t getUserWord(int id) const
bool invalid() const
Definition: HcalUMNioDigi.h:30
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
uint32_t eventNumber() const
std::vector< uint16_t > payload_
Definition: HcalUMNioDigi.h:40
uint32_t valueUserWord(int iword) const
uint8_t eventType() const
uint16_t bunchNumber() const
uint16_t idUserWord(int iword) const
bool hasUserWord(int id) const
uint32_t orbitNumber() const
int numberUserWords() const
uint16_t spillCounter() const
uint32_t runNumber() const