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 {
9  if (isHeader()) determineMode();
10 }
11 
13  if (m_ptr==m_limit) return *this;
14  if (m_stepclass==0) m_ptr++;
15  else if (m_stepclass==1) {
16  if (m_microstep==0) { m_ptr++; m_microstep++; }
17  else { m_microstep--; }
18  }
19  else if (m_stepclass==2) {
20  if (isHeader()) { m_ptr++; }
21  else { m_ptr+=2; }
22  }
23 
24  if (isHeader()) {
25  determineMode();
28  }
29  return *this;
30 }
31 
33  if (!isHeader()) return;
34  m_flavor=flavor();
35  m_stepclass=0;
36  if (m_flavor==5) { m_stepclass=1; m_microstep=0; }
37  else if (m_flavor == 2) { m_stepclass=2; }
39 }
40 
42  if ((m_flavor==7 && m_technicalDataType==15) && !isHeader()) return ((*m_ptr)>>11)&0x1;
43  else return ((*m_ptr)>>10)&0x3;
44 }
45 
47  if ((m_flavor==7 && m_technicalDataType==15) && !isHeader()) return ((*m_ptr)>>10)&0x1;
48  else return !(errFlags()&0x2);
49 }
50 
52  if (m_flavor==7) return ((*m_ptr)>>8)&0xF;
53  else return 0;
54 }
55 
57  if (m_flavor==5 && m_microstep==0) return ((*m_ptr)>>8)&0x7F;
58  else if (m_flavor==7 && m_technicalDataType==15) return (*m_ptr)&0x7F;
59  else return (*m_ptr)&0xFF;
60 }
61 
63  if (m_flavor==5 || (m_flavor==7 && m_technicalDataType==15)) return 0x80;
64  else if (m_flavor == 2) return (m_ptr[1]&0x3F);
65  else return (((*m_ptr)&0x3F00)>>8);
66 }
67 
69  if (m_flavor==5 || (m_flavor==7 && m_technicalDataType==15)) return false;
70  else if (m_flavor == 2) return (m_ptr[0]&0x2000);
71  else return (((*m_ptr)&0x4000));
72 }
73 
75  if (m_flavor==2) return(m_ptr[1]>>6)&0x1F;
76  else return 0x80;
77 }
78 
80  if (m_flavor==2) return(m_ptr[1]>>12)&0x3;
81  else if (m_flavor==7 && m_technicalDataType==15) {
82  return ((*m_ptr)>>8)&0x3;
83  }
84  else if (m_flavor == 1 || m_flavor == 0) {
85  // For flavor 0,1 we only get the first capid in the header, and so we need
86  // to count the number of data rows and figure out which cap we want,
87  // knowing that they go 0->1->2->3->0
88  return 0;
89  }
90  else { return 0; }
91 }
92 
94  if (m_flavor == 2) { return (m_ptr[0]>>12)&0x1; }
95  else if (m_flavor == 4) { return (m_ptr[0]>>13)&0x1; }
96  else { return false; }
97 }
98 
101 }
102 
104  return HcalUHTRData::const_iterator(m_raw16+(m_rawLength64-1)*sizeof(uint64_t)/sizeof(uint16_t),m_raw16+(m_rawLength64-1)*sizeof(uint64_t)/sizeof(uint16_t));
105 }
106 
108 
109 HcalUHTRData::HcalUHTRData(const uint64_t* data, int length) : m_rawLength64(length),m_raw64(data),m_raw16((const uint16_t*)(data)),m_ownData(nullptr) {
110  m_formatVersion=(m_raw16[6]>>12)&0xF;
111 }
112 
114 
115 HcalUHTRData::HcalUHTRData(int version_to_create) : m_formatVersion(version_to_create) {
116 
117  // the needed space is for the biggest possible event...
118  // fibers*maxsamples/fiber
119  const int needed=(0x20+FIBERS_PER_UHTR*CHANNELS_PER_FIBER_MAX*(10+1))*sizeof(uint16_t)/sizeof(uint64_t);
120 
121  m_ownData=new uint64_t[needed];
122  memset(m_ownData,0,sizeof(uint64_t)*needed);
123  m_rawLength64=0;
125  m_raw16=(const uint16_t*)m_raw64;
126 }
127 
129  if (m_ownData==nullptr) {
132  m_raw64=hd.m_raw64;
133  m_raw16=hd.m_raw16;
134  }
135  return (*this);
136 }
const uint16_t * m_limit
Definition: HcalUHTRData.h:72
static const int CHANNELS_PER_FIBER_MAX
Definition: HcalUHTRData.h:21
const uint16_t * m_0th_data_ptr
Definition: HcalUHTRData.h:73
#define nullptr
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
Definition: HcalUHTRData.cc:99
const uint16_t * m_raw16
Definition: HcalUHTRData.h:115
static const int FIBERS_PER_UHTR
Definition: HcalUHTRData.h:18
HcalUHTRData & operator=(const HcalUHTRData &)
unsigned long long uint64_t
Definition: Time.h:15
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const uint16_t * m_header_ptr
Definition: HcalUHTRData.h:73
const uint64_t * m_raw64
Definition: HcalUHTRData.h:114
const_iterator end() const
uint64_t * m_ownData
Definition: HcalUHTRData.h:116