CMS 3D CMS Logo

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