CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DataFormats/EcalDigi/interface/EcalMGPASample.h

Go to the documentation of this file.
00001 #ifndef DIGIECAL_ECALMGPASAMPLE_H
00002 #define DIGIECAL_ECALMGPASAMPLE_H
00003 
00004 #include <iosfwd>
00005 #include <boost/cstdint.hpp>
00006 
00007 namespace ecalMGPA {
00008   typedef uint16_t sample_type;
00009  
00011   inline int adc(sample_type sample) { return sample&0xFFF; }
00013   inline int gainId(sample_type sample) { return (sample>>12)&0x3; }
00014   inline sample_type pack(int adc, int gainId) {
00015     return (adc&0xFFF) | ((gainId&0x3)<<12);
00016   }
00017 }
00018 
00019 
00026 class EcalMGPASample {
00027  public:
00028   EcalMGPASample() { theSample=0; }
00029   EcalMGPASample(uint16_t data) { theSample=data; }
00030   EcalMGPASample(int adc, int gainId);
00031     
00033   uint16_t raw() const { return theSample; }
00035   int adc() const { return theSample&0xFFF; }
00037   int gainId() const { return (theSample>>12)&0x3; }
00039   uint16_t operator()() const { return theSample; }
00040   operator uint16_t () const { return theSample; }
00041 
00042  private:
00043   uint16_t theSample;
00044 };
00045 
00046 std::ostream& operator<<(std::ostream&, const EcalMGPASample&);
00047   
00048 
00049 
00050 #endif