CMS 3D CMS Logo

HcalDigiSoA.h
Go to the documentation of this file.
1 #ifndef DataFormats_HcalDigi_HcalDigiSoA_h
2 #define DataFormats_HcalDigi_HcalDigiSoA_h
3 
4 //TODO: Use Eigen column for data(?)
5 //#include <Eigen/Core>
6 //#include <Eigen/Dense>
7 
11 
12 namespace hcal {
13 
14  // FLAVOR_HE_QIE11 = 1; Phase1 upgrade
15  struct Flavor1 {
16  static constexpr int WORDS_PER_SAMPLE = 1;
17  static constexpr int SAMPLES_PER_WORD = 1;
18  static constexpr int HEADER_WORDS = 1;
19 
20  static constexpr uint8_t adc(uint16_t const* const sample_start) { return (*sample_start & 0xff); }
21  static constexpr uint8_t tdc(uint16_t const* const sample_start) { return (*sample_start >> 8) & 0x3f; }
22  static constexpr uint8_t soibit(uint16_t const* const sample_start) { return (*sample_start >> 14) & 0x1; }
23  };
24 
25  // FLAVOR_HB_QIE11 = 3; Phase1 upgrade
26  struct Flavor3 {
27  static constexpr int WORDS_PER_SAMPLE = 1;
28  static constexpr int SAMPLES_PER_WORD = 1;
29  static constexpr int HEADER_WORDS = 1;
30 
31  static constexpr uint8_t adc(uint16_t const* const sample_start) { return (*sample_start & 0xff); }
32  static constexpr uint8_t tdc(uint16_t const* const sample_start) { return ((*sample_start >> 8) & 0x3); }
33  static constexpr uint8_t soibit(uint16_t const* const sample_start) { return ((*sample_start >> 14) & 0x1); }
34  static constexpr uint8_t capid(uint16_t const* const sample_start) { return ((*sample_start >> 10) & 0x3); }
35  };
36 
37  // FLAVOR_HB_QIE10 = 5; Phase0
38  struct Flavor5 {
39  static constexpr float WORDS_PER_SAMPLE = 0.5;
40  static constexpr int SAMPLES_PER_WORD = 2;
41  static constexpr int HEADER_WORDS = 1;
42 
43  static constexpr uint8_t adc(uint16_t const* const sample_start, uint8_t const shifter) {
44  return ((*sample_start >> shifter * 8) & 0x7f);
45  }
46  };
47 
48  template <typename Flavor>
49  constexpr uint8_t capid_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
50  auto const capid_first = (*dfstart >> 8) & 0x3;
51  return (capid_first + sample) & 0x3; // same as % 4
52  }
53 
54  template <>
55  constexpr uint8_t capid_for_sample<Flavor3>(uint16_t const* const dfstart, uint32_t const sample) {
57  }
58 
59  template <typename Flavor>
60  constexpr uint8_t soibit_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
61  return Flavor::soibit(dfstart + Flavor::HEADER_WORDS + sample * Flavor::WORDS_PER_SAMPLE);
62  }
63 
64  template <typename Flavor>
65  constexpr uint8_t adc_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
66  return Flavor::adc(dfstart + Flavor::HEADER_WORDS + sample * Flavor::WORDS_PER_SAMPLE);
67  }
68 
69  template <typename Flavor>
70  constexpr uint8_t tdc_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
71  return Flavor::tdc(dfstart + Flavor::HEADER_WORDS + sample * Flavor::WORDS_PER_SAMPLE);
72  }
73 
74  template <>
75  constexpr uint8_t adc_for_sample<Flavor5>(uint16_t const* const dfstart, uint32_t const sample) {
76  // avoid using WORDS_PER_SAMPLE and simply shift
77  return Flavor5::adc(dfstart + Flavor5::HEADER_WORDS + (sample >> 1), sample % 2);
78  }
79 
80  template <typename Flavor>
81  constexpr uint32_t compute_stride(uint32_t const nsamples) {
82  return static_cast<uint32_t>(nsamples * Flavor::WORDS_PER_SAMPLE) + Flavor::HEADER_WORDS;
83  }
84 
85  template <typename Flavor>
86  constexpr uint32_t compute_nsamples(uint32_t const nwords) {
87  if constexpr (Flavor::SAMPLES_PER_WORD >= 1)
88  return (nwords - Flavor::HEADER_WORDS) * Flavor::SAMPLES_PER_WORD;
89  else
90  return (nwords - Flavor::HEADER_WORDS) / Flavor::WORDS_PER_SAMPLE;
91  }
92 
93  using QIE11dataArray = edm::StdArray<uint16_t, QIE11DigiCollection::MAXSAMPLES + Flavor1::HEADER_WORDS>;
94  using QIE10dataArray = edm::StdArray<uint16_t, HBHEDataFrame::MAXSAMPLES + Flavor5::HEADER_WORDS>;
95 
96  //using QIE11dataVector = Eigen::Matrix<uint16_t, QIE11DigiCollection::MAXSAMPLES, 1>;
97  //using QIE10dataVector = Eigen::Matrix<uint16_t, HBHEDataFrame::MAXSAMPLES, 1>;
98 
100  SOA_COLUMN(uint32_t, ids),
101  //SOA_EIGEN_COLUMN(QIE11dataVector, data),
103  SOA_SCALAR(uint32_t, stride),
104  SOA_SCALAR(uint32_t, size))
106  SOA_COLUMN(uint32_t, ids),
107  SOA_COLUMN(uint32_t, npresamples),
108  //SOA_EIGEN_COLUMN(QIE10dataVector, data),
110  SOA_SCALAR(uint32_t, stride),
111  SOA_SCALAR(uint32_t, size))
112 
115 
116 } // namespace hcal
117 
118 #endif
constexpr uint32_t compute_nsamples(uint32_t const nwords)
static constexpr int HEADER_WORDS
static constexpr int WORDS_PER_SAMPLE
return((rh ^ lh) &mask)
static constexpr int SAMPLES_PER_WORD
constexpr uint8_t tdc_for_sample(uint16_t const *const dfstart, uint32_t const sample)
constexpr uint8_t soibit_for_sample(uint16_t const *const dfstart, uint32_t const sample)
constexpr uint32_t stride
Definition: HelixFit.h:22
static constexpr uint8_t soibit(uint16_t const *const sample_start)
Definition: HcalDigiSoA.h:22
#define GENERATE_SOA_LAYOUT(CLASS,...)
Definition: SoALayout.h:431
#define SOA_SCALAR(TYPE, NAME)
Definition: SoACommon.h:563
static constexpr uint8_t adc(uint16_t const *const sample_start)
Definition: HcalDigiSoA.h:31
constexpr uint8_t capid_for_sample(uint16_t const *const dfstart, uint32_t const sample)
constexpr uint8_t adc_for_sample< Flavor5 >(uint16_t const *const dfstart, uint32_t const sample)
constexpr uint32_t compute_stride(uint32_t const nsamples)
static constexpr int SAMPLES_PER_WORD
static constexpr int MAXSAMPLES
static constexpr uint8_t soibit(uint16_t const *const sample_start)
Definition: HcalDigiSoA.h:33
static constexpr uint8_t adc(uint16_t const *const sample_start, uint8_t const shifter)
Definition: HcalDigiSoA.h:43
static constexpr uint8_t tdc(uint16_t const *const sample_start)
Definition: HcalDigiSoA.h:32
static constexpr int SAMPLES_PER_WORD
static constexpr int HEADER_WORDS
constexpr uint8_t adc_for_sample(uint16_t const *const dfstart, uint32_t const sample)
constexpr uint8_t capid_for_sample< Flavor3 >(uint16_t const *const dfstart, uint32_t const sample)
static constexpr uint8_t adc(uint16_t const *const sample_start)
Definition: HcalDigiSoA.h:20
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
static constexpr float WORDS_PER_SAMPLE
static constexpr int HEADER_WORDS
#define SOA_COLUMN(TYPE, NAME)
Definition: SoACommon.h:564
static constexpr int WORDS_PER_SAMPLE
static constexpr uint8_t tdc(uint16_t const *const sample_start)
Definition: HcalDigiSoA.h:21
uint16_t *__restrict__ uint16_t const *__restrict__ adc
static constexpr uint8_t capid(uint16_t const *const sample_start)
Definition: HcalDigiSoA.h:34