CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalLiteDTUSample.h
Go to the documentation of this file.
1 #ifndef DataFormats_EcalDigi_EcalLiteDTUSample_h
2 #define DataFormats_EcalDigi_EcalLiteDTUSample_h
3 
4 #include <iosfwd>
5 #include <cstdint>
7 
8 namespace ecalLiteDTU {
9  typedef uint16_t sample_type;
10 
12  constexpr int adc(sample_type sample) { return sample & ecalPh2::kAdcMask; }
14  constexpr int gainId(sample_type sample) { return (sample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; }
15  constexpr sample_type pack(int adc, int gainId) {
16  return (adc & ecalPh2::kAdcMask) | ((gainId & ecalPh2::kGainIdMask) << ecalPh2::NBITS);
17  }
18 } // namespace ecalLiteDTU
19 
26 public:
29  EcalLiteDTUSample(int adc, int gainId);
30 
32  uint16_t raw() const { return theSample; }
34  int adc() const { return theSample & ecalPh2::kAdcMask; }
36  int gainId() const { return (theSample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; }
38  uint16_t operator()() const { return theSample; }
39  operator uint16_t() const { return theSample; }
40 
41 private:
42  uint16_t theSample;
43 };
44 
45 std::ostream& operator<<(std::ostream&, const EcalLiteDTUSample&);
46 
47 #endif
EcalLiteDTUSample(uint16_t data)
constexpr sample_type pack(int adc, int gainId)
static constexpr unsigned int kGainIdMask
Definition: EcalConstants.h:19
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
static constexpr unsigned int kAdcMask
Definition: EcalConstants.h:18
uint16_t operator()() const
for streaming
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
static constexpr unsigned int NBITS
Definition: EcalConstants.h:13
int adc() const
get the ADC sample (12 bits)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
uint16_t sample_type
uint16_t raw() const
get the raw word
int gainId() const
get the gainId (2 bits)
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)