CMS 3D CMS Logo

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