CMS 3D CMS Logo

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 }
mps_fire.i
i
Definition: mps_fire.py:355
HcalUMNioDigi::eventType
uint8_t eventType() const
Definition: HcalUMNioDigi.cc:35
HcalUMNioDigi::invalid
bool invalid() const
Definition: HcalUMNioDigi.h:30
HcalUMNioDigi::idUserWord
uint16_t idUserWord(int iword) const
Definition: HcalUMNioDigi.cc:57
HcalUMNioDigi.h
HcalUMNioDigi::bunchNumber
uint16_t bunchNumber() const
Definition: HcalUMNioDigi.cc:24
HcalUMNioDigi::orbitNumber
uint32_t orbitNumber() const
Definition: HcalUMNioDigi.cc:19
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HcalUMNioDigi::valueUserWord
uint32_t valueUserWord(int iword) const
Definition: HcalUMNioDigi.cc:62
HcalUMNioDigi::numberUserWords
int numberUserWords() const
Definition: HcalUMNioDigi.cc:51
HcalUMNioDigi
Definition: HcalUMNioDigi.h:15
HcalUMNioDigi::payload_
std::vector< uint16_t > payload_
Definition: HcalUMNioDigi.h:40
HcalUMNioDigi::isSpill
bool isSpill() const
Definition: HcalUMNioDigi.cc:45
operator<<
std::ostream & operator<<(std::ostream &s, const HcalUMNioDigi &digi)
Definition: HcalUMNioDigi.cc:90
value
Definition: value.py:1
HcalUMNioDigi::eventNumber
uint32_t eventNumber() const
Definition: HcalUMNioDigi.cc:29
HcalUMNioDigi::hasUserWord
bool hasUserWord(int id) const
Definition: HcalUMNioDigi.cc:67
HcalUMNioDigi::HcalUMNioDigi
HcalUMNioDigi()
Definition: HcalUMNioDigi.cc:4
HcalUMNioDigi::runNumber
uint32_t runNumber() const
Definition: HcalUMNioDigi.cc:13
HcalUMNioDigi::spillCounter
uint16_t spillCounter() const
Definition: HcalUMNioDigi.cc:40
dummy
Definition: DummySelector.h:38
HcalUMNioDigi::getUserWord
uint32_t getUserWord(int id) const
Definition: HcalUMNioDigi.cc:71