CMS 3D CMS Logo

EcalMGPASample.h
Go to the documentation of this file.
1 #ifndef DIGIECAL_ECALMGPASAMPLE_H
2 #define DIGIECAL_ECALMGPASAMPLE_H
3 
4 #include <iosfwd>
5 #include <boost/cstdint.hpp>
6 
7 namespace ecalMGPA {
8  typedef uint16_t sample_type;
9 
11  constexpr int adc(sample_type sample) { return sample&0xFFF; }
13  constexpr int gainId(sample_type sample) { return (sample>>12)&0x3; }
14  constexpr sample_type pack(int adc, int gainId) {
15  return (adc&0xFFF) | ((gainId&0x3)<<12);
16  }
17 }
18 
19 
26  public:
27  EcalMGPASample() { theSample=0; }
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&0xFFF; }
36  int gainId() const { return (theSample>>12)&0x3; }
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 
48 
49 #endif
constexpr sample_type pack(int adc, int gainId)
uint16_t theSample
uint16_t raw() const
get the raw word
int gainId() const
get the gainId (2 bits)
std::ostream & operator<<(std::ostream &, const EcalMGPASample &)
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:8
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
#define constexpr
int adc() const
get the ADC sample (12 bits)