CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCSample.h
Go to the documentation of this file.
1 #ifndef DIGIHGCAL_HGCSAMPLE_H
2 #define DIGIHGCAL_HGCSAMPLE_H
3 
4 #include <ostream>
5 #include <boost/cstdint.hpp>
6 
12 class HGCSample {
13 
14 public:
15 
16  enum HGCSampleMasks {ADC_MASK=0x7fff, GAIN_MASK=0x1 };
17  enum HGCSamplePos {ADC_POS=0 , GAIN_POS=15 };
18 
22  HGCSample() : value_(0) { }
23  HGCSample(uint16_t value) : value_(value) { }
24 
28  void setGain(uint16_t gain) { setWord(gain,GAIN_MASK,GAIN_POS); }
29  void setADC(uint16_t adc) { setWord(adc,ADC_MASK,ADC_POS); }
30  void set(uint16_t gain, uint16_t adc) { setGain(gain); setADC(adc); }
31 
35  uint16_t raw() const { return value_; }
36  uint16_t gain() const { return ((value_ >> GAIN_POS) & GAIN_MASK); }
37  uint16_t adc() const { return ((value_ >> ADC_POS) & ADC_MASK); }
38  uint16_t operator()() { return value_; }
39 
40 private:
41 
45  void setWord(uint16_t word, uint16_t mask, uint16_t pos)
46  {
47  //clear required bits
48  value_ &= ~((word & mask) << pos);
49  //now set the new value
50  value_ |= ((word & mask) << pos);
51  }
52 
53  // the word
54  uint16_t value_;
55 
56 };
57 
58 
59 #endif
uint16_t raw() const
getters
Definition: HGCSample.h:35
void set(uint16_t gain, uint16_t adc)
Definition: HGCSample.h:30
void setADC(uint16_t adc)
Definition: HGCSample.h:29
wrapper for a data word
Definition: HGCSample.h:12
HGCSample()
CTOR.
Definition: HGCSample.h:22
uint16_t adc() const
Definition: HGCSample.h:37
HGCSampleMasks
Definition: HGCSample.h:16
void setGain(uint16_t gain)
setters
Definition: HGCSample.h:28
uint16_t value_
Definition: HGCSample.h:54
HGCSample(uint16_t value)
Definition: HGCSample.h:23
uint16_t operator()()
Definition: HGCSample.h:38
void setWord(uint16_t word, uint16_t mask, uint16_t pos)
wrapper to reset words at a given position
Definition: HGCSample.h:45
uint16_t gain() const
Definition: HGCSample.h:36