CMS 3D CMS Logo

DigiCollection.h
Go to the documentation of this file.
1 #ifndef CUDADataFormats_HcalDigi_interface_DigiCollection_h
2 #define CUDADataFormats_HcalDigi_interface_DigiCollection_h
3 
5 
6 namespace hcal {
7 
8  // FLAVOR_HE_QIE11 = 1; Phase1 upgrade
9  struct Flavor1 {
10  static constexpr int WORDS_PER_SAMPLE = 1;
11  static constexpr int SAMPLES_PER_WORD = 1;
12  static constexpr int HEADER_WORDS = 1;
13 
14  static constexpr uint8_t adc(uint16_t const* const sample_start) { return (*sample_start & 0xff); }
15  static constexpr uint8_t tdc(uint16_t const* const sample_start) { return (*sample_start >> 8) & 0x3f; }
16  static constexpr uint8_t soibit(uint16_t const* const sample_start) { return (*sample_start >> 14) & 0x1; }
17  };
18 
19  // FLAVOR_HB_QIE11 = 3; Phase1 upgrade
20  struct Flavor3 {
21  static constexpr int WORDS_PER_SAMPLE = 1;
22  static constexpr int SAMPLES_PER_WORD = 1;
23  static constexpr int HEADER_WORDS = 1;
24 
25  static constexpr uint8_t adc(uint16_t const* const sample_start) { return (*sample_start & 0xff); }
26  static constexpr uint8_t tdc(uint16_t const* const sample_start) { return ((*sample_start >> 8) & 0x3); }
27  static constexpr uint8_t soibit(uint16_t const* const sample_start) { return ((*sample_start >> 14) & 0x1); }
28  static constexpr uint8_t capid(uint16_t const* const sample_start) { return ((*sample_start >> 10) & 0x3); }
29  };
30 
31  // FLAVOR_HB_QIE10 = 5; Phase0
32  struct Flavor5 {
33  static constexpr float WORDS_PER_SAMPLE = 0.5;
34  static constexpr int SAMPLES_PER_WORD = 2;
35  static constexpr int HEADER_WORDS = 1;
36 
37  static constexpr uint8_t adc(uint16_t const* const sample_start, uint8_t const shifter) {
38  return ((*sample_start >> shifter * 8) & 0x7f);
39  }
40  };
41 
42  template <typename Flavor>
43  constexpr uint8_t capid_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
44  auto const capid_first = (*dfstart >> 8) & 0x3;
45  return (capid_first + sample) & 0x3; // same as % 4
46  }
47 
48  template <>
49  constexpr uint8_t capid_for_sample<Flavor3>(uint16_t const* const dfstart, uint32_t const sample) {
51  }
52 
53  template <typename Flavor>
54  constexpr uint8_t soibit_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
55  return Flavor::soibit(dfstart + Flavor::HEADER_WORDS + sample * Flavor::WORDS_PER_SAMPLE);
56  }
57 
58  template <typename Flavor>
59  constexpr uint8_t adc_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
60  return Flavor::adc(dfstart + Flavor::HEADER_WORDS + sample * Flavor::WORDS_PER_SAMPLE);
61  }
62 
63  template <typename Flavor>
64  constexpr uint8_t tdc_for_sample(uint16_t const* const dfstart, uint32_t const sample) {
65  return Flavor::tdc(dfstart + Flavor::HEADER_WORDS + sample * Flavor::WORDS_PER_SAMPLE);
66  }
67 
68  template <>
69  constexpr uint8_t adc_for_sample<Flavor5>(uint16_t const* const dfstart, uint32_t const sample) {
70  // avoid using WORDS_PER_SAMPLE and simply shift
71  return Flavor5::adc(dfstart + Flavor5::HEADER_WORDS + (sample >> 1), sample % 2);
72  }
73 
74  template <typename Flavor>
75  constexpr uint32_t compute_stride(uint32_t const nsamples) {
76  return static_cast<uint32_t>(nsamples * Flavor::WORDS_PER_SAMPLE) + Flavor::HEADER_WORDS;
77  }
78 
79  template <typename Flavor>
80  constexpr uint32_t compute_nsamples(uint32_t const nwords) {
81  if constexpr (Flavor::SAMPLES_PER_WORD >= 1)
82  return (nwords - Flavor::HEADER_WORDS) * Flavor::SAMPLES_PER_WORD;
83  else
84  return (nwords - Flavor::HEADER_WORDS) / Flavor::WORDS_PER_SAMPLE;
85  }
86 
87  //
88  template <typename StoragePolicy>
89  struct DigiCollectionBase : public ::calo::common::AddSize<typename StoragePolicy::TagType> {
90  DigiCollectionBase() = default;
91  DigiCollectionBase(DigiCollectionBase const&) = default;
93 
96 
97  template <typename T = typename StoragePolicy::TagType>
99  ids.resize(size);
100  data.resize(size * stride);
101  }
102 
103  template <typename T = typename StoragePolicy::TagType>
105  ids.reserve(size);
106  data.reserve(size * stride);
107  }
108 
109  template <typename T = typename StoragePolicy::TagType>
111  ids.clear();
112  data.clear();
113  }
114 
117  uint32_t stride{0};
118  };
119 
120  template <typename Flavor, typename StoragePolicy>
121  struct DigiCollection : public DigiCollectionBase<StoragePolicy> {
123  };
124 
125  // NOTE: base ctors will not be available
126  template <typename StoragePolicy>
127  struct DigiCollection<Flavor5, StoragePolicy> : public DigiCollectionBase<StoragePolicy> {
128  DigiCollection() = default;
129 
130  DigiCollection(DigiCollection const&) = default;
131  DigiCollection& operator=(DigiCollection const&) = default;
132 
133  DigiCollection(DigiCollection&&) = default;
135 
136  template <typename T = typename StoragePolicy::TagType>
139  npresamples.resize(size);
140  }
141 
142  template <typename T = typename StoragePolicy::TagType>
145  npresamples.reserve(size);
146  }
147 
148  template <typename T = typename StoragePolicy::TagType>
151  npresamples.clear();
152  }
153 
154  // add npresamples member
156  };
157 
158 } // namespace hcal
159 
160 #endif // CUDADataFormats_HcalDigi_interface_DigiCollection_h
hcal::capid_for_sample< Flavor3 >
constexpr uint8_t capid_for_sample< Flavor3 >(uint16_t const *const dfstart, uint32_t const sample)
Definition: DigiCollection.h:49
hcal::DigiCollection< Flavor5, StoragePolicy >::reserve
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type reserve(std::size_t size)
Definition: DigiCollection.h:143
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
hcal
Definition: ConfigurationDatabase.cc:13
hcal::capid_for_sample
constexpr uint8_t capid_for_sample(uint16_t const *const dfstart, uint32_t const sample)
Definition: DigiCollection.h:43
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
hcal::Flavor3::SAMPLES_PER_WORD
static constexpr int SAMPLES_PER_WORD
Definition: DigiCollection.h:22
hcal::Flavor5
Definition: DigiCollection.h:32
hcal::DigiCollectionBase::resize
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type resize(std::size_t size)
Definition: DigiCollection.h:98
Common.h
hcal::adc_for_sample< Flavor5 >
constexpr uint8_t adc_for_sample< Flavor5 >(uint16_t const *const dfstart, uint32_t const sample)
Definition: DigiCollection.h:69
hcal::Flavor1::tdc
static constexpr uint8_t tdc(uint16_t const *const sample_start)
Definition: DigiCollection.h:15
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
hcal::Flavor3::soibit
static constexpr uint8_t soibit(uint16_t const *const sample_start)
Definition: DigiCollection.h:27
hcal::Flavor5::WORDS_PER_SAMPLE
static constexpr float WORDS_PER_SAMPLE
Definition: DigiCollection.h:33
hcal::Flavor1::WORDS_PER_SAMPLE
static constexpr int WORDS_PER_SAMPLE
Definition: DigiCollection.h:10
hcal::compute_nsamples
constexpr uint32_t compute_nsamples(uint32_t const nwords)
Definition: DigiCollection.h:80
hcal::Flavor1::SAMPLES_PER_WORD
static constexpr int SAMPLES_PER_WORD
Definition: DigiCollection.h:11
calo::common::AddSize
Definition: Common.h:22
hcal::Flavor1::adc
static constexpr uint8_t adc(uint16_t const *const sample_start)
Definition: DigiCollection.h:14
hcal::Flavor5::HEADER_WORDS
static constexpr int HEADER_WORDS
Definition: DigiCollection.h:35
hcal::tdc_for_sample
constexpr uint8_t tdc_for_sample(uint16_t const *const dfstart, uint32_t const sample)
Definition: DigiCollection.h:64
hcal::DigiCollection< Flavor5, StoragePolicy >::resize
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type resize(std::size_t size)
Definition: DigiCollection.h:137
hcal::DigiCollection
Definition: DigiCollection.h:121
hcal::Flavor3::adc
static constexpr uint8_t adc(uint16_t const *const sample_start)
Definition: DigiCollection.h:25
hcal::Flavor1::soibit
static constexpr uint8_t soibit(uint16_t const *const sample_start)
Definition: DigiCollection.h:16
hcal::Flavor3::HEADER_WORDS
static constexpr int HEADER_WORDS
Definition: DigiCollection.h:23
hcal::Flavor1::HEADER_WORDS
static constexpr int HEADER_WORDS
Definition: DigiCollection.h:12
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
hcal::Flavor3::tdc
static constexpr uint8_t tdc(uint16_t const *const sample_start)
Definition: DigiCollection.h:26
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
hcal::Flavor3
Definition: DigiCollection.h:20
hcal::DigiCollection< Flavor5, StoragePolicy >::npresamples
StoragePolicy::template StorageSelector< uint8_t >::type npresamples
Definition: DigiCollection.h:155
hcal::compute_stride
constexpr uint32_t compute_stride(uint32_t const nsamples)
Definition: DigiCollection.h:75
hcal::adc_for_sample
constexpr uint8_t adc_for_sample(uint16_t const *const dfstart, uint32_t const sample)
Definition: DigiCollection.h:59
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
hcal::DigiCollectionBase::reserve
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type reserve(std::size_t size)
Definition: DigiCollection.h:104
hcal::DigiCollectionBase::stride
uint32_t stride
Definition: DigiCollection.h:117
hcal::Flavor3::capid
static constexpr uint8_t capid(uint16_t const *const sample_start)
Definition: DigiCollection.h:28
hcal::DigiCollectionBase::DigiCollectionBase
DigiCollectionBase()=default
hcal::soibit_for_sample
constexpr uint8_t soibit_for_sample(uint16_t const *const dfstart, uint32_t const sample)
Definition: DigiCollection.h:54
siStripShotFilter_cfi.DigiCollection
DigiCollection
Definition: siStripShotFilter_cfi.py:6
hcal::DigiCollectionBase::data
StoragePolicy::template StorageSelector< uint16_t >::type data
Definition: DigiCollection.h:116
hcal::Flavor1
Definition: DigiCollection.h:9
hcal::DigiCollectionBase
Definition: DigiCollection.h:89
relativeConstraints.value
value
Definition: relativeConstraints.py:53
hcal::DigiCollectionBase::operator=
DigiCollectionBase & operator=(DigiCollectionBase const &)=default
hcal::DigiCollection< Flavor5, StoragePolicy >::clear
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type clear()
Definition: DigiCollection.h:149
hcal::Flavor3::WORDS_PER_SAMPLE
static constexpr int WORDS_PER_SAMPLE
Definition: DigiCollection.h:21
hcal::Flavor5::SAMPLES_PER_WORD
static constexpr int SAMPLES_PER_WORD
Definition: DigiCollection.h:34
hcal::DigiCollectionBase::ids
StoragePolicy::template StorageSelector< uint32_t >::type ids
Definition: DigiCollection.h:115
hcal::Flavor5::adc
static constexpr uint8_t adc(uint16_t const *const sample_start, uint8_t const shifter)
Definition: DigiCollection.h:37
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
hcal::DigiCollectionBase::clear
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type clear()
Definition: DigiCollection.h:110