CMS 3D CMS Logo

QIE10DataFrame.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H
2 #define DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H
3 
6 #include <ostream>
7 
12 public:
13  static const int WORDS_PER_SAMPLE = 2;
14  static const int HEADER_WORDS = 1;
15  static const int FLAG_WORDS = 1;
16 
17  constexpr QIE10DataFrame() {}
18  constexpr QIE10DataFrame(edm::DataFrame const& df) : m_data(df) {}
19 
20  class Sample {
21  public:
22  typedef uint32_t wide_type;
23 
25  : word1_(frame[i]), word2_(frame[i + 1]) {}
26  constexpr Sample(const edm::DataFrame::data_type& word1, const edm::DataFrame::data_type& word2)
27  : word1_(word1), word2_(word2) {}
28  explicit Sample(const wide_type wide) : word1_{0}, word2_{0} {
29  static_assert(sizeof(wide) == 2 * sizeof(word1_), "The wide input type must be able to contain two words");
30  const edm::DataFrame::data_type* ptr = reinterpret_cast<const edm::DataFrame::data_type*>(&wide);
31  word1_ = ptr[0];
32  word2_ = ptr[1];
33  }
34 
35  static const int MASK_ADC = 0xFF;
36  static const int MASK_LE_TDC = 0x3F;
37  static const int MASK_TE_TDC = 0x1F;
38  static const int OFFSET_TE_TDC = 6;
39  static const int MASK_SOI = 0x2000;
40  static const int MASK_OK = 0x1000;
41  static const int MASK_CAPID = 0x3;
42  static const int OFFSET_CAPID = 12;
43 
44  constexpr inline int adc() const { return word1_ & MASK_ADC; }
45  constexpr inline int le_tdc() const { return word2_ & MASK_LE_TDC; }
46  constexpr inline int te_tdc() const { return (word2_ >> OFFSET_TE_TDC) & MASK_TE_TDC; }
47  constexpr inline bool ok() const { return word1_ & MASK_OK; }
48  constexpr inline bool soi() const { return word1_ & MASK_SOI; }
49  constexpr inline int capid() const { return (word2_ >> OFFSET_CAPID) & MASK_CAPID; }
51  return (i > WORDS_PER_SAMPLE) ? 0 : ((i == 1) ? word2_ : word1_);
52  }
54  static_assert(sizeof(QIE10DataFrame::Sample::wide_type) == 2 * sizeof(word1_),
55  "The wide result type must be able to contain two words");
56  wide_type result = 0;
57  edm::DataFrame::data_type* ptr = reinterpret_cast<edm::DataFrame::data_type*>(&result);
58  ptr[0] = word1_;
59  ptr[1] = word2_;
60  return result;
61  }
62 
63  private:
66  };
67 
68  constexpr void copyContent(const QIE10DataFrame& digi) {
69  for (edm::DataFrame::size_type i = 0; i < size() && i < digi.size(); i++) {
70  Sample sam = digi[i];
71  setSample(i, sam.adc(), sam.le_tdc(), sam.te_tdc(), sam.capid(), sam.soi(), sam.ok());
72  }
73  }
74 
76  constexpr DetId detid() const { return DetId(m_data.id()); }
77  constexpr edm::DataFrame::id_type id() const { return m_data.id(); }
79  constexpr edm::DataFrame::size_type size() const { return m_data.size(); }
81  constexpr edm::DataFrame::iterator begin() { return m_data.begin(); }
82  constexpr edm::DataFrame::iterator end() { return m_data.end(); }
83  constexpr edm::DataFrame::const_iterator begin() const { return m_data.begin(); }
84  constexpr edm::DataFrame::const_iterator end() const { return m_data.end(); }
86  constexpr int samples() const { return (size() - HEADER_WORDS - FLAG_WORDS) / WORDS_PER_SAMPLE; }
88  constexpr int presamples() const {
89  for (int i = 0; i < samples(); i++) {
90  if ((*this)[i].soi())
91  return i;
92  }
93  return -1;
94  }
96  static const int OFFSET_FLAVOR = 12;
97  static const int MASK_FLAVOR = 0x7;
98  constexpr int flavor() const { return ((m_data[0] >> OFFSET_FLAVOR) & MASK_FLAVOR); }
100  static const int MASK_LINKERROR = 0x800;
101  constexpr bool linkError() const { return m_data[0] & MASK_LINKERROR; }
103  static const int MASK_MARKPASS = 0x100;
104  constexpr bool zsMarkAndPass() const { return m_data[0] & MASK_MARKPASS; }
106  constexpr void setZSInfo(bool markAndPass) {
107  if (markAndPass)
108  m_data[0] |= MASK_MARKPASS;
109  }
111  constexpr inline Sample operator[](edm::DataFrame::size_type i) const {
113  }
115  constexpr void setSample(
116  edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi = false, bool ok = true) {
117  if (isample >= size())
118  return;
119  m_data[isample * WORDS_PER_SAMPLE + HEADER_WORDS] =
120  (adc & Sample::MASK_ADC) | (soi ? (Sample::MASK_SOI) : (0)) | (ok ? (Sample::MASK_OK) : (0));
121  m_data[isample * WORDS_PER_SAMPLE + HEADER_WORDS + 1] =
122  (le_tdc & Sample::MASK_LE_TDC) | ((te_tdc & Sample::MASK_TE_TDC) << Sample::OFFSET_TE_TDC) |
123  ((capid & Sample::MASK_CAPID) << Sample::OFFSET_CAPID) | 0x4000; // 0x4000 marks this as second word of a pair
124  }
126  constexpr uint16_t flags() const { return m_data[size() - 1]; }
128  constexpr void setFlags(uint16_t v) { m_data[size() - 1] = v; }
129 
130 private:
132 };
133 
134 std::ostream& operator<<(std::ostream&, const QIE10DataFrame&);
135 
136 #endif // DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H
mps_fire.i
i
Definition: mps_fire.py:428
QIE10DataFrame::Sample::OFFSET_CAPID
static const int OFFSET_CAPID
Definition: QIE10DataFrame.h:42
QIE10DataFrame::samples
constexpr int samples() const
total number of samples in the digi
Definition: QIE10DataFrame.h:86
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
QIE10DataFrame::linkError
constexpr bool linkError() const
Definition: QIE10DataFrame.h:101
QIE10DataFrame::Sample::le_tdc
constexpr int le_tdc() const
Definition: QIE10DataFrame.h:45
QIE10DataFrame::presamples
constexpr int presamples() const
for backward compatibility
Definition: QIE10DataFrame.h:88
QIE10DataFrame::Sample::adc
constexpr int adc() const
Definition: QIE10DataFrame.h:44
QIE10DataFrame::Sample::wideRaw
QIE10DataFrame::Sample::wide_type wideRaw() const
Definition: QIE10DataFrame.h:53
QIE10DataFrame::flags
constexpr uint16_t flags() const
get the flag word
Definition: QIE10DataFrame.h:126
QIE10DataFrame::QIE10DataFrame
constexpr QIE10DataFrame(edm::DataFrame const &df)
Definition: QIE10DataFrame.h:18
QIE10DataFrame::QIE10DataFrame
constexpr QIE10DataFrame()
Definition: QIE10DataFrame.h:17
QIE10DataFrame::size
constexpr edm::DataFrame::size_type size() const
more accessors
Definition: QIE10DataFrame.h:79
QIE10DataFrame::m_data
edm::DataFrame m_data
Definition: QIE10DataFrame.h:131
QIE10DataFrame::Sample::raw
constexpr edm::DataFrame::data_type raw(edm::DataFrame::size_type i) const
Definition: QIE10DataFrame.h:50
findQualityFiles.v
v
Definition: findQualityFiles.py:179
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
QIE10DataFrame::Sample::MASK_CAPID
static const int MASK_CAPID
Definition: QIE10DataFrame.h:41
QIE10DataFrame::Sample::MASK_OK
static const int MASK_OK
Definition: QIE10DataFrame.h:40
QIE10DataFrame::setZSInfo
constexpr void setZSInfo(bool markAndPass)
set ZS params
Definition: QIE10DataFrame.h:106
DetId
Definition: DetId.h:17
QIE10DataFrame::Sample::OFFSET_TE_TDC
static const int OFFSET_TE_TDC
Definition: QIE10DataFrame.h:38
QIE10DataFrame::WORDS_PER_SAMPLE
static const int WORDS_PER_SAMPLE
Definition: QIE10DataFrame.h:13
QIE10DataFrame::MASK_MARKPASS
static const int MASK_MARKPASS
was this a mark-and-pass ZS event?
Definition: QIE10DataFrame.h:103
QIE10DataFrame::end
constexpr edm::DataFrame::iterator end()
Definition: QIE10DataFrame.h:82
QIE10DataFrame::detid
constexpr DetId detid() const
Get the detector id.
Definition: QIE10DataFrame.h:76
QIE10DataFrame::Sample::wide_type
uint32_t wide_type
Definition: QIE10DataFrame.h:22
QIE10DataFrame::Sample::Sample
Sample(const wide_type wide)
Definition: QIE10DataFrame.h:28
QIE10DataFrame::Sample::te_tdc
constexpr int te_tdc() const
Definition: QIE10DataFrame.h:46
DigiNZS_cff.markAndPass
markAndPass
Definition: DigiNZS_cff.py:6
QIE10DataFrame::Sample::capid
constexpr int capid() const
Definition: QIE10DataFrame.h:49
edm::DataFrame::iterator
data_type * iterator
Definition: DataFrame.h:20
QIE10DataFrame::Sample::ok
constexpr bool ok() const
Definition: QIE10DataFrame.h:47
operator<<
std::ostream & operator<<(std::ostream &, const QIE10DataFrame &)
Definition: QIE10DataFrame.cc:4
QIE10DataFrame::Sample::MASK_ADC
static const int MASK_ADC
Definition: QIE10DataFrame.h:35
edm::DataFrame::size_type
unsigned int size_type
Definition: DataFrame.h:17
QIE10DataFrame::MASK_LINKERROR
static const int MASK_LINKERROR
was there a link error?
Definition: QIE10DataFrame.h:100
DataFrame.h
QIE10DataFrame::begin
constexpr edm::DataFrame::const_iterator begin() const
Definition: QIE10DataFrame.h:83
QIE10DataFrame::Sample::Sample
constexpr Sample(const edm::DataFrame::data_type &word1, const edm::DataFrame::data_type &word2)
Definition: QIE10DataFrame.h:26
QIE10DataFrame::MASK_FLAVOR
static const int MASK_FLAVOR
Definition: QIE10DataFrame.h:97
HcalDetId.h
QIE10DataFrame::copyContent
constexpr void copyContent(const QIE10DataFrame &digi)
Definition: QIE10DataFrame.h:68
edm::DataFrame::const_iterator
const data_type * const_iterator
Definition: DataFrame.h:21
QIE10DataFrame::zsMarkAndPass
constexpr bool zsMarkAndPass() const
Definition: QIE10DataFrame.h:104
QIE10DataFrame::flavor
constexpr int flavor() const
Definition: QIE10DataFrame.h:98
QIE10DataFrame::Sample::MASK_TE_TDC
static const int MASK_TE_TDC
Definition: QIE10DataFrame.h:37
QIE10DataFrame::end
constexpr edm::DataFrame::const_iterator end() const
Definition: QIE10DataFrame.h:84
edm::DataFrame
Definition: DataFrame.h:15
QIE10DataFrame::setFlags
constexpr void setFlags(uint16_t v)
set the flag word
Definition: QIE10DataFrame.h:128
QIE10DataFrame::setSample
constexpr void setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi=false, bool ok=true)
set the sample contents
Definition: QIE10DataFrame.h:115
edm::DataFrame::id_type
unsigned int id_type
Definition: DataFrame.h:18
edm::DataFrame::end
constexpr iterator end()
Definition: DataFrame.h:35
QIE10DataFrame::Sample::word2_
edm::DataFrame::data_type word2_
Definition: QIE10DataFrame.h:65
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
QIE10DataFrame::Sample::word1_
edm::DataFrame::data_type word1_
Definition: QIE10DataFrame.h:64
QIE10DataFrame
Definition: QIE10DataFrame.h:11
QIE10DataFrame::operator[]
constexpr Sample operator[](edm::DataFrame::size_type i) const
get the sample
Definition: QIE10DataFrame.h:111
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
QIE10DataFrame::Sample
Definition: QIE10DataFrame.h:20
QIE10DataFrame::Sample::Sample
constexpr Sample(const edm::DataFrame &frame, edm::DataFrame::size_type i)
Definition: QIE10DataFrame.h:24
QIE10DataFrame::begin
constexpr edm::DataFrame::iterator begin()
iterators
Definition: QIE10DataFrame.h:81
QIE10DataFrame::Sample::MASK_SOI
static const int MASK_SOI
Definition: QIE10DataFrame.h:39
mps_fire.result
result
Definition: mps_fire.py:311
QIE10DataFrame::FLAG_WORDS
static const int FLAG_WORDS
Definition: QIE10DataFrame.h:15
QIE10DataFrame::Sample::MASK_LE_TDC
static const int MASK_LE_TDC
Definition: QIE10DataFrame.h:36
edm::DataFrame::size
constexpr size_type size() const
Definition: DataFrame.h:43
QIE10DataFrame::id
constexpr edm::DataFrame::id_type id() const
Definition: QIE10DataFrame.h:77
QIE10DataFrame::HEADER_WORDS
static const int HEADER_WORDS
Definition: QIE10DataFrame.h:14
edm::DataFrame::data_type
unsigned short data_type
Definition: DataFrame.h:19
QIE10DataFrame::Sample::soi
constexpr bool soi() const
Definition: QIE10DataFrame.h:48
edm::DataFrame::id
constexpr id_type id() const
Definition: DataFrame.h:41
edm::DataFrame::begin
constexpr iterator begin()
Definition: DataFrame.h:33
QIE10DataFrame::OFFSET_FLAVOR
static const int OFFSET_FLAVOR
get the flavor of the frame
Definition: QIE10DataFrame.h:96