CMS 3D CMS Logo

HcalQIESample.h
Go to the documentation of this file.
1 #ifndef DIGIHCAL_HCALQIESAMPLE_H
2 #define DIGIHCAL_HCALQIESAMPLE_H
3 
4 #include <ostream>
5 #include <cstdint>
6 
7 static
8 #ifdef __CUDA_ARCH__
9  __constant__
10 #else
11  constexpr
12 #endif
13  float nominal_adc2fc[128] = {
14  -0.5f, 0.5f, 1.5f, 2.5f, 3.5f, 4.5f, 5.5f, 6.5f, 7.5f, 8.5f, 9.5f, 10.5f,
15  11.5f, 12.5f, 13.5f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 27.0f, 29.5f, 32.5f,
16  35.5f, 38.5f, 42.0f, 46.0f, 50.0f, 54.5f, 59.5f, 64.5f, 59.5f, 64.5f, 69.5f, 74.5f,
17  79.5f, 84.5f, 89.5f, 94.5f, 99.5f, 104.5f, 109.5f, 114.5f, 119.5f, 124.5f, 129.5f, 137.0f,
18  147.0f, 157.0f, 167.0f, 177.0f, 187.0f, 197.0f, 209.5f, 224.5f, 239.5f, 254.5f, 272.0f, 292.0f,
19  312.0f, 334.5f, 359.5f, 384.5f, 359.5f, 384.5f, 409.5f, 434.5f, 459.5f, 484.5f, 509.5f, 534.5f,
20  559.5f, 584.5f, 609.5f, 634.5f, 659.5f, 684.5f, 709.5f, 747.0f, 797.0f, 847.0f, 897.0f, 947.0f,
21  997.0f, 1047.0f, 1109.5f, 1184.5f, 1259.5f, 1334.5f, 1422.0f, 1522.0f, 1622.0f, 1734.5f, 1859.5f, 1984.5f,
22  1859.5f, 1984.5f, 2109.5f, 2234.5f, 2359.5f, 2484.5f, 2609.5f, 2734.5f, 2859.5f, 2984.5f, 3109.5f, 3234.5f,
23  3359.5f, 3484.5f, 3609.5f, 3797.0f, 4047.0f, 4297.0f, 4547.0f, 4797.0f, 5047.0f, 5297.0f, 5609.5f, 5984.5f,
24  6359.5f, 6734.5f, 7172.0f, 7672.0f, 8172.0f, 8734.5f, 9359.5f, 9984.5f};
25 
33 public:
35  constexpr HcalQIESample(uint16_t data) : theSample{data} {}
36  constexpr HcalQIESample(int adc, int capid, int fiber, int fiberchan, bool dv = true, bool er = false)
37  : theSample((uint16_t)((adc & 0x7f) | ((capid & 0x3) << 7) | (((fiber - 1) & 0x7) << 13) |
38  ((fiberchan & 0x3) << 11) | ((dv) ? (0x0200) : (0)) | ((er) ? (0x0400) : (0)))) {}
39 
41  constexpr uint16_t raw() const { return theSample; }
43  constexpr int adc() const { return theSample & 0x7F; }
45  constexpr double nominal_fC() const { return nominal_adc2fc[adc()]; }
47  constexpr int capid() const { return (theSample >> 7) & 0x3; }
49  constexpr bool dv() const { return (theSample & 0x0200) != 0; }
51  constexpr bool er() const { return (theSample & 0x0400) != 0; }
53  constexpr int fiber() const { return ((theSample >> 13) & 0x7) + 1; }
55  constexpr int fiberChan() const { return (theSample >> 11) & 0x3; }
57  constexpr int fiberAndChan() const { return (theSample >> 11) & 0x1F; }
58 
60  constexpr uint16_t operator()() { return theSample; }
61 
62 private:
63  uint16_t theSample;
64 };
65 
66 std::ostream& operator<<(std::ostream&, const HcalQIESample&);
67 
68 #endif
constexpr HcalQIESample()
Definition: HcalQIESample.h:34
constexpr bool er() const
is the error bit set?
Definition: HcalQIESample.h:51
constexpr uint16_t operator()()
for streaming
Definition: HcalQIESample.h:60
constexpr int fiberChan() const
get the fiber channel number
Definition: HcalQIESample.h:55
static constexpr float nominal_adc2fc[128]
Definition: HcalQIESample.h:13
uint16_t theSample
Definition: HcalQIESample.h:63
constexpr double nominal_fC() const
get the nominal FC (no calibrations applied)
Definition: HcalQIESample.h:45
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43
std::ostream & operator<<(std::ostream &, const HcalQIESample &)
Definition: HcalQIESample.cc:3
constexpr bool dv() const
is the Data Valid bit set?
Definition: HcalQIESample.h:49
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
constexpr uint16_t raw() const
get the raw word
Definition: HcalQIESample.h:41
constexpr HcalQIESample(int adc, int capid, int fiber, int fiberchan, bool dv=true, bool er=false)
Definition: HcalQIESample.h:36
#define constexpr
constexpr int fiber() const
get the fiber number
Definition: HcalQIESample.h:53
constexpr int fiberAndChan() const
get the id channel
Definition: HcalQIESample.h:57
constexpr HcalQIESample(uint16_t data)
Definition: HcalQIESample.h:35