File indexing completed on 2024-04-06 12:04:04
0001 #ifndef DataFormats_EcalDigi_EcalLiteDTUSample_h
0002 #define DataFormats_EcalDigi_EcalLiteDTUSample_h
0003
0004 #include <iosfwd>
0005 #include <cstdint>
0006 #include "DataFormats/EcalDigi/interface/EcalConstants.h"
0007
0008 namespace ecalLiteDTU {
0009 typedef uint16_t sample_type;
0010
0011
0012 constexpr int adc(sample_type sample) { return sample & ecalPh2::kAdcMask; }
0013
0014 constexpr int gainId(sample_type sample) { return (sample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; }
0015 constexpr sample_type pack(int adc, int gainId) {
0016 return (adc & ecalPh2::kAdcMask) | ((gainId & ecalPh2::kGainIdMask) << ecalPh2::NBITS);
0017 }
0018 }
0019
0020
0021
0022
0023
0024
0025 class EcalLiteDTUSample {
0026 public:
0027 EcalLiteDTUSample() { theSample = 0; }
0028 EcalLiteDTUSample(uint16_t data) { theSample = data; }
0029 EcalLiteDTUSample(int adc, int gainId);
0030
0031
0032 uint16_t raw() const { return theSample; }
0033
0034 int adc() const { return theSample & ecalPh2::kAdcMask; }
0035
0036 int gainId() const { return (theSample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; }
0037
0038 uint16_t operator()() const { return theSample; }
0039 operator uint16_t() const { return theSample; }
0040
0041 private:
0042 uint16_t theSample;
0043 };
0044
0045 std::ostream& operator<<(std::ostream&, const EcalLiteDTUSample&);
0046
0047 #endif