CMS 3D CMS Logo

HcalUHTRData.cc
Go to the documentation of this file.
2 #include <cstring>
3 
4 static const int HEADER_LENGTH_16BIT = 2 * sizeof(uint64_t) / sizeof(uint16_t);
5 
6 HcalUHTRData::const_iterator::const_iterator(const uint16_t* ptr, const uint16_t* limit)
7  : m_ptr(ptr), m_limit(limit), m_stepclass(0), m_technicalDataType(0) {
8  if (isHeader())
10 }
11 
13  if (m_ptr == m_limit)
14  return *this;
15  if (m_stepclass == 0)
16  m_ptr++;
17  else if (m_stepclass == 1) {
18  if (m_microstep == 0) {
19  m_ptr++;
20  m_microstep++;
21  } else {
22  m_microstep--;
23  }
24  } else if (m_stepclass == 2) {
25  if (isHeader()) {
26  m_ptr++;
27  } else {
28  m_ptr += 2;
29  }
30  }
31 
32  if (isHeader()) {
33  determineMode();
36  }
37  return *this;
38 }
39 
41  if (!isHeader())
42  return;
43  m_flavor = flavor();
44  m_stepclass = 0;
45  if (m_flavor == 5) {
46  m_stepclass = 1;
47  m_microstep = 0;
48  } else if (m_flavor == 2) {
49  m_stepclass = 2;
50  }
51  if (m_flavor == 7) {
53  }
54 }
55 
57  if ((m_flavor == 7 && m_technicalDataType == 15) && !isHeader())
58  return ((*m_ptr) >> 11) & 0x1;
59  else
60  return ((*m_ptr) >> 10) & 0x3;
61 }
62 
64  if ((m_flavor == 7 && m_technicalDataType == 15) && !isHeader())
65  return ((*m_ptr) >> 10) & 0x1;
66  else
67  return !(errFlags() & 0x2);
68 }
69 
71  if (m_flavor == 7)
72  return ((*m_ptr) >> 8) & 0xF;
73  else
74  return 0;
75 }
76 
78  if (m_flavor == 5 && m_microstep == 0)
79  return ((*m_ptr) >> 8) & 0x7F;
80  else if (m_flavor == 7 && m_technicalDataType == 15)
81  return (*m_ptr) & 0x7F;
82  else
83  return (*m_ptr) & 0xFF;
84 }
85 
87  if (m_flavor == 5 || (m_flavor == 7 && m_technicalDataType == 15))
88  return 0x80;
89  else if (m_flavor == 2)
90  return (m_ptr[1] & 0x3F);
91  else
92  return (((*m_ptr) & 0x3F00) >> 8);
93 }
94 
96  if (m_flavor == 5 || (m_flavor == 7 && m_technicalDataType == 15))
97  return false;
98  else if (m_flavor == 2)
99  return (m_ptr[0] & 0x2000);
100  else
101  return (((*m_ptr) & 0x4000));
102 }
103 
105  if (m_flavor == 2)
106  return (m_ptr[1] >> 6) & 0x1F;
107  else
108  return 0x80;
109 }
110 
112  if (m_flavor == 2)
113  return (m_ptr[1] >> 12) & 0x3;
114  else if (m_flavor == 7 && m_technicalDataType == 15) {
115  return ((*m_ptr) >> 8) & 0x3;
116  } else if (m_flavor == 1 || m_flavor == 0) {
117  // For flavor 0,1 we only get the first capid in the header, and so we need
118  // to count the number of data rows and figure out which cap we want,
119  // knowing that they go 0->1->2->3->0
120  return 0;
121  } else {
122  return 0;
123  }
124 }
125 
127  if (m_flavor == 2) {
128  return (m_ptr[0] >> 12) & 0x1;
129  } else if (m_flavor == 4) {
130  return (m_ptr[0] >> 13) & 0x1;
131  } else {
132  return false;
133  }
134 }
135 
138  m_raw16 + (m_rawLength64 - 1) * sizeof(uint64_t) / sizeof(uint16_t));
139 }
140 
142  return HcalUHTRData::const_iterator(m_raw16 + (m_rawLength64 - 1) * sizeof(uint64_t) / sizeof(uint16_t),
143  m_raw16 + (m_rawLength64 - 1) * sizeof(uint64_t) / sizeof(uint16_t));
144 }
145 
148 
150  : m_rawLength64(length), m_raw64(data), m_raw16((const uint16_t*)(data)), m_ownData(nullptr) {
151  m_formatVersion = (m_raw16[6] >> 12) & 0xF;
152 }
153 
157  m_raw64(hd.m_raw64),
158  m_raw16(hd.m_raw16),
159  m_ownData(nullptr) {}
160 
161 HcalUHTRData::HcalUHTRData(int version_to_create) : m_formatVersion(version_to_create) {
162  // the needed space is for the biggest possible event...
163  // fibers*maxsamples/fiber
164  const int needed = (0x20 + FIBERS_PER_UHTR * CHANNELS_PER_FIBER_MAX * (10 + 1)) * sizeof(uint16_t) / sizeof(uint64_t);
165 
166  m_ownData = new uint64_t[needed];
167  memset(m_ownData, 0, sizeof(uint64_t) * needed);
168  m_rawLength64 = 0;
169  m_raw64 = m_ownData;
170  m_raw16 = (const uint16_t*)m_raw64;
171 }
172 
174  if (m_ownData == nullptr) {
177  m_raw64 = hd.m_raw64;
178  m_raw16 = hd.m_raw16;
179  }
180  return (*this);
181 }
const uint16_t * m_limit
Definition: HcalUHTRData.h:75
#define nullptr
static const int CHANNELS_PER_FIBER_MAX
Definition: HcalUHTRData.h:21
const uint16_t * m_0th_data_ptr
Definition: HcalUHTRData.h:76
const_iterator & operator++()
Definition: HcalUHTRData.cc:12
static const int HEADER_LENGTH_16BIT
Definition: HcalUHTRData.cc:4
const_iterator(const uint16_t *ptr, const uint16_t *limit=nullptr)
Definition: HcalUHTRData.cc:6
const_iterator begin() const
const uint16_t * m_raw16
Definition: HcalUHTRData.h:117
static const int FIBERS_PER_UHTR
Definition: HcalUHTRData.h:18
HcalUHTRData & operator=(const HcalUHTRData &)
unsigned long long uint64_t
Definition: Time.h:13
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const uint16_t * m_header_ptr
Definition: HcalUHTRData.h:76
const uint64_t * m_raw64
Definition: HcalUHTRData.h:116
const_iterator end() const
uint64_t * m_ownData
Definition: HcalUHTRData.h:118