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 DIGIECAL_ECALMGPASAMPLE_H
2 #define DIGIECAL_ECALMGPASAMPLE_H
3 
4 #include <iosfwd>
5 #include <cstdint>
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) { return (adc & 0xFFF) | ((gainId & 0x3) << 12); }
15 } // namespace ecalMGPA
16 
23 public:
25  EcalMGPASample(uint16_t data) { theSample = data; }
26  EcalMGPASample(int adc, int gainId);
27 
29  uint16_t raw() const { return theSample; }
31  int adc() const { return theSample & 0xFFF; }
33  int gainId() const { return (theSample >> 12) & 0x3; }
35  uint16_t operator()() const { return theSample; }
36  operator uint16_t() const { return theSample; }
37 
38 private:
39  uint16_t theSample;
40 };
41 
42 std::ostream& operator<<(std::ostream&, const EcalMGPASample&);
43 
44 #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)
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:79
int adc() const
get the ADC sample (12 bits)