CMS 3D CMS Logo

QIE11DataFrame.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
2 #define DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
3 
6 #include <ostream>
7 
12 public:
13  static const int WORDS_PER_SAMPLE = 1;
14  static const int HEADER_WORDS = 1;
15  static const int FLAG_WORDS = 1;
16 
17  static const int OFFSET_FLAVOR = 12;
18  static const int MASK_FLAVOR = 0x7;
19  static const int FLAVOR_HB = 3;
20  static const int MASK_LINKERROR = 0x800;
21 
22  constexpr QIE11DataFrame() {}
23  constexpr QIE11DataFrame(edm::DataFrame const& df) : m_data(df) {}
24 
25  class Sample {
26  public:
28  static const int MASK_ADC = 0xFF;
29  static const int MASK_TDC_HE = 0x3F;
30  static const int MASK_TDC_HB = 0x3;
31  static const int OFFSET_TDC = 8; // 8 bits
32  static const int MASK_SOI = 0x4000;
33  static const int MASK_LE_HB = 0x2000;
34  static const int MASK_CAPID = 0x3;
35  static const int MASK_CAPID_INV_HB = 0xF3FF;
36  static const int MASK_CAPID_KEEP_HB = 0x0C00;
37  static const int OFFSET_CAPID_HE = 8;
38  static const int OFFSET_CAPID_HB = 10;
39  constexpr int flavor() const { return ((frame_[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); }
40  constexpr int adc() const { return frame_[i_] & MASK_ADC; }
41  constexpr int tdc() const {
42  return (frame_[i_] >> OFFSET_TDC) & ((flavor() == FLAVOR_HB) ? (MASK_TDC_HB) : (MASK_TDC_HE));
43  }
44  constexpr bool soi() const { return frame_[i_] & MASK_SOI; }
45  constexpr int capid() const {
46  return (flavor() == FLAVOR_HB)
49  }
50  constexpr bool linkError() const {
51  return (flavor() == FLAVOR_HB) ? (frame_[i_] & MASK_LE_HB) : (frame_[0] & MASK_LINKERROR);
52  }
53 
54  private:
57  };
58 
59  constexpr void copyContent(const QIE11DataFrame& digi) {
60  for (edm::DataFrame::size_type i = 0; i < size() && i < digi.size(); i++) {
61  Sample sam = digi[i];
62  setSample(i, sam.adc(), sam.tdc(), sam.soi());
63  }
64  }
65 
67  constexpr DetId detid() const { return DetId(m_data.id()); }
68  constexpr edm::DataFrame::id_type id() const { return m_data.id(); }
70  constexpr edm::DataFrame::size_type size() const { return m_data.size(); }
72  constexpr edm::DataFrame::iterator begin() { return m_data.begin(); }
73  constexpr edm::DataFrame::iterator end() { return m_data.end(); }
74  constexpr edm::DataFrame::const_iterator begin() const { return m_data.begin(); }
75  constexpr edm::DataFrame::const_iterator end() const { return m_data.end(); }
77  constexpr int samples() const { return (size() - HEADER_WORDS - FLAG_WORDS) / WORDS_PER_SAMPLE; }
79  constexpr int presamples() const {
80  for (int i = 0; i < samples(); i++) {
81  if ((*this)[i].soi())
82  return i;
83  }
84  return -1;
85  }
87  constexpr int flavor() const { return ((m_data[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); }
89  constexpr bool linkError() const { return m_data[0] & MASK_LINKERROR; }
91  static const int MASK_CAPIDERROR = 0x400;
92  constexpr bool capidError() const { return m_data[0] & MASK_CAPIDERROR; }
94  constexpr bool zsMarkAndPass() const { return (flavor() == 1); }
96  constexpr void setZSInfo(bool markAndPass) {
97  if (markAndPass)
99  }
101  constexpr inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data, i + HEADER_WORDS); }
102 
103  // set flavor
104  constexpr void setFlavor(int flavor) {
105  m_data[0] &= 0x9FFF; // inversion of flavor mask
106  m_data[0] |= ((flavor & MASK_FLAVOR) << OFFSET_FLAVOR);
107  }
108 
109  constexpr void setCapid0(int cap0) {
110  if (flavor() == FLAVOR_HB) {
111  for (int i = 0; i < samples(); i++) {
113  m_data[i + 1] |= ((cap0 + i) & Sample::MASK_CAPID) << Sample::OFFSET_CAPID_HB;
114  }
115  } else {
116  m_data[0] &= 0xFCFF; // inversion of the capid0 mask
118  }
119  }
121  constexpr void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi = false) {
122  if (isample >= size())
123  return;
124  if (flavor() == FLAVOR_HB)
125  m_data[isample + 1] = (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) |
127  (m_data[isample + 1] & Sample::MASK_CAPID_KEEP_HB);
128  else
129  m_data[isample + 1] = (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) |
131  }
133  constexpr uint16_t flags() const { return m_data[size() - 1]; }
135  constexpr void setFlags(uint16_t v) { m_data[size() - 1] = v; }
136 
137 private:
139 };
140 
141 std::ostream& operator<<(std::ostream&, const QIE11DataFrame&);
142 
143 #endif // DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
QIE11DataFrame::begin
constexpr edm::DataFrame::iterator begin()
iterators
Definition: QIE11DataFrame.h:72
QIE11DataFrame::Sample::MASK_CAPID
static const int MASK_CAPID
Definition: QIE11DataFrame.h:34
QIE11DataFrame::Sample::soi
constexpr bool soi() const
Definition: QIE11DataFrame.h:44
mps_fire.i
i
Definition: mps_fire.py:428
QIE11DataFrame::OFFSET_FLAVOR
static const int OFFSET_FLAVOR
Definition: QIE11DataFrame.h:17
QIE11DataFrame::Sample::flavor
constexpr int flavor() const
Definition: QIE11DataFrame.h:39
QIE11DataFrame::setFlags
constexpr void setFlags(uint16_t v)
set the flag word
Definition: QIE11DataFrame.h:135
QIE11DataFrame::presamples
constexpr int presamples() const
for backward compatibility
Definition: QIE11DataFrame.h:79
QIE11DataFrame::operator[]
constexpr Sample operator[](edm::DataFrame::size_type i) const
get the sample
Definition: QIE11DataFrame.h:101
QIE11DataFrame::flags
constexpr uint16_t flags() const
get the flag word
Definition: QIE11DataFrame.h:133
operator<<
std::ostream & operator<<(std::ostream &, const QIE11DataFrame &)
Definition: QIE11DataFrame.cc:4
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
QIE11DataFrame::zsMarkAndPass
constexpr bool zsMarkAndPass() const
was this a mark-and-pass ZS event?
Definition: QIE11DataFrame.h:94
QIE11DataFrame::end
constexpr edm::DataFrame::iterator end()
Definition: QIE11DataFrame.h:73
QIE11DataFrame::setCapid0
constexpr void setCapid0(int cap0)
Definition: QIE11DataFrame.h:109
QIE11DataFrame::Sample::linkError
constexpr bool linkError() const
Definition: QIE11DataFrame.h:50
QIE11DataFrame::QIE11DataFrame
constexpr QIE11DataFrame(edm::DataFrame const &df)
Definition: QIE11DataFrame.h:23
QIE11DataFrame::Sample::Sample
constexpr Sample(const edm::DataFrame &frame, edm::DataFrame::size_type i)
Definition: QIE11DataFrame.h:27
findQualityFiles.v
v
Definition: findQualityFiles.py:179
DetId
Definition: DetId.h:17
QIE11DataFrame::Sample
Definition: QIE11DataFrame.h:25
QIE11DataFrame::Sample::i_
edm::DataFrame::size_type i_
Definition: QIE11DataFrame.h:56
QIE11DataFrame::copyContent
constexpr void copyContent(const QIE11DataFrame &digi)
Definition: QIE11DataFrame.h:59
QIE11DataFrame::FLAVOR_HB
static const int FLAVOR_HB
Definition: QIE11DataFrame.h:19
DigiNZS_cff.markAndPass
markAndPass
Definition: DigiNZS_cff.py:6
QIE11DataFrame::Sample::tdc
constexpr int tdc() const
Definition: QIE11DataFrame.h:41
QIE11DataFrame::Sample::capid
constexpr int capid() const
Definition: QIE11DataFrame.h:45
edm::DataFrame::iterator
data_type * iterator
Definition: DataFrame.h:20
QIE11DataFrame::samples
constexpr int samples() const
total number of samples in the digi
Definition: QIE11DataFrame.h:77
QIE11DataFrame::WORDS_PER_SAMPLE
static const int WORDS_PER_SAMPLE
Definition: QIE11DataFrame.h:13
QIE11DataFrame::Sample::adc
constexpr int adc() const
Definition: QIE11DataFrame.h:40
QIE11DataFrame::setFlavor
constexpr void setFlavor(int flavor)
Definition: QIE11DataFrame.h:104
edm::DataFrame::size_type
unsigned int size_type
Definition: DataFrame.h:17
QIE11DataFrame::Sample::MASK_TDC_HB
static const int MASK_TDC_HB
Definition: QIE11DataFrame.h:30
QIE11DataFrame::size
constexpr edm::DataFrame::size_type size() const
more accessors
Definition: QIE11DataFrame.h:70
QIE11DataFrame::Sample::OFFSET_TDC
static const int OFFSET_TDC
Definition: QIE11DataFrame.h:31
DataFrame.h
QIE11DataFrame::setSample
constexpr void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false)
set the sample contents
Definition: QIE11DataFrame.h:121
QIE11DataFrame::HEADER_WORDS
static const int HEADER_WORDS
Definition: QIE11DataFrame.h:14
QIE11DataFrame::MASK_FLAVOR
static const int MASK_FLAVOR
Definition: QIE11DataFrame.h:18
QIE11DataFrame::Sample::MASK_CAPID_KEEP_HB
static const int MASK_CAPID_KEEP_HB
Definition: QIE11DataFrame.h:36
HcalDetId.h
QIE11DataFrame::Sample::OFFSET_CAPID_HE
static const int OFFSET_CAPID_HE
Definition: QIE11DataFrame.h:37
QIE11DataFrame::MASK_CAPIDERROR
static const int MASK_CAPIDERROR
was there a capid rotation error?
Definition: QIE11DataFrame.h:91
QIE11DataFrame::id
constexpr edm::DataFrame::id_type id() const
Definition: QIE11DataFrame.h:68
QIE11DataFrame::end
constexpr edm::DataFrame::const_iterator end() const
Definition: QIE11DataFrame.h:75
QIE11DataFrame::Sample::OFFSET_CAPID_HB
static const int OFFSET_CAPID_HB
Definition: QIE11DataFrame.h:38
QIE11DataFrame::MASK_LINKERROR
static const int MASK_LINKERROR
Definition: QIE11DataFrame.h:20
QIE11DataFrame::capidError
constexpr bool capidError() const
Definition: QIE11DataFrame.h:92
edm::DataFrame::const_iterator
const data_type * const_iterator
Definition: DataFrame.h:21
QIE11DataFrame::detid
constexpr DetId detid() const
Get the detector id.
Definition: QIE11DataFrame.h:67
edm::DataFrame
Definition: DataFrame.h:15
QIE11DataFrame::Sample::frame_
const edm::DataFrame & frame_
Definition: QIE11DataFrame.h:55
QIE11DataFrame::setZSInfo
constexpr void setZSInfo(bool markAndPass)
set ZS params
Definition: QIE11DataFrame.h:96
edm::DataFrame::id_type
unsigned int id_type
Definition: DataFrame.h:18
edm::DataFrame::end
constexpr iterator end()
Definition: DataFrame.h:35
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
QIE11DataFrame
Definition: QIE11DataFrame.h:11
QIE11DataFrame::Sample::MASK_TDC_HE
static const int MASK_TDC_HE
Definition: QIE11DataFrame.h:29
QIE11DataFrame::flavor
constexpr int flavor() const
get the flavor of the frame
Definition: QIE11DataFrame.h:87
QIE11DataFrame::Sample::MASK_LE_HB
static const int MASK_LE_HB
Definition: QIE11DataFrame.h:33
QIE11DataFrame::linkError
constexpr bool linkError() const
was there a link error?
Definition: QIE11DataFrame.h:89
QIE11DataFrame::begin
constexpr edm::DataFrame::const_iterator begin() const
Definition: QIE11DataFrame.h:74
edm::DataFrame::size
constexpr size_type size() const
Definition: DataFrame.h:43
QIE11DataFrame::FLAG_WORDS
static const int FLAG_WORDS
Definition: QIE11DataFrame.h:15
edm::DataFrame::id
constexpr id_type id() const
Definition: DataFrame.h:41
edm::DataFrame::begin
constexpr iterator begin()
Definition: DataFrame.h:33
QIE11DataFrame::Sample::MASK_SOI
static const int MASK_SOI
Definition: QIE11DataFrame.h:32
QIE11DataFrame::m_data
edm::DataFrame m_data
Definition: QIE11DataFrame.h:138
QIE11DataFrame::QIE11DataFrame
constexpr QIE11DataFrame()
Definition: QIE11DataFrame.h:22
QIE11DataFrame::Sample::MASK_CAPID_INV_HB
static const int MASK_CAPID_INV_HB
Definition: QIE11DataFrame.h:35
QIE11DataFrame::Sample::MASK_ADC
static const int MASK_ADC
Definition: QIE11DataFrame.h:28