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