File indexing completed on 2025-08-05 08:16:09
0001 #ifndef FUN4ALLRAW_TPCRAWTHITV2_H
0002 #define FUN4ALLRAW_TPCRAWTHITV2_H
0003
0004 #include "TpcRawHit.h"
0005
0006 #include <phool/PHObject.h>
0007
0008 #include <cassert>
0009 #include <limits>
0010 #include <map>
0011
0012 class TpcRawHitv2 : public TpcRawHit
0013 {
0014 public:
0015 TpcRawHitv2() = default;
0016 TpcRawHitv2(TpcRawHit *tpchit);
0017 ~TpcRawHitv2() override = default;
0018
0019
0020
0021
0022 void identify(std::ostream &os = std::cout) const override;
0023
0024 void Clear(Option_t *) override;
0025
0026 uint64_t get_bco() const override { return bco; }
0027
0028 void set_bco(const uint64_t val) override { bco = val; }
0029
0030 uint64_t get_gtm_bco() const override { return gtm_bco; }
0031
0032 void set_gtm_bco(const uint64_t val) override { gtm_bco = val; }
0033
0034 int32_t get_packetid() const override { return packetid; }
0035
0036 void set_packetid(const int32_t val) override { packetid = val; }
0037
0038 uint16_t get_fee() const override { return fee; }
0039
0040 void set_fee(const uint16_t val) override { fee = val; }
0041
0042 uint16_t get_channel() const override { return channel; }
0043
0044 void set_channel(const uint16_t val) override { channel = val; }
0045
0046 uint16_t get_sampaaddress() const override { return sampaaddress; }
0047
0048 void set_sampaaddress(const uint16_t val) override { sampaaddress = val; }
0049
0050 uint16_t get_sampachannel() const override { return sampachannel; }
0051
0052 void set_sampachannel(const uint16_t val) override { sampachannel = val; }
0053
0054 uint16_t get_samples() const override { return samples; }
0055
0056 void set_samples(const uint16_t val) override
0057 {
0058
0059 samples = val;
0060 }
0061
0062 uint16_t get_adc(const uint16_t sample) const override;
0063
0064
0065 void set_adc(const uint16_t sample, const uint16_t val) override
0066 {
0067 adcmap[sample] = val;
0068 }
0069
0070 uint16_t get_type() const override { return type; }
0071 void set_type(const uint16_t i) override { type = i; }
0072
0073 uint16_t get_userword() const override { return userword; }
0074 void set_userword(const uint16_t i) override { userword = i; }
0075
0076 uint16_t get_checksum() const override { return checksum; }
0077 void set_checksum(const uint16_t i) override { checksum = i; }
0078
0079 uint16_t get_parity() const override { return data_parity; }
0080 void set_parity(const uint16_t i) override { data_parity = i; }
0081
0082 bool get_checksumerror() const override { return checksumerror; }
0083 void set_checksumerror(const bool b) override { checksumerror = b; }
0084
0085 bool get_parityerror() const override { return parityerror; }
0086 void set_parityerror(const bool b) override { parityerror = b; }
0087
0088 class AdcIteratorv2 : public AdcIterator
0089 {
0090 private:
0091 const std::map<uint16_t, uint16_t> &m_adc;
0092 std::map<uint16_t, uint16_t>::const_iterator m_iterator;
0093
0094 public:
0095
0096 explicit AdcIteratorv2(const std::map<uint16_t, uint16_t> &adc)
0097 : m_adc(adc)
0098 , m_iterator(adc.begin())
0099 {
0100 }
0101
0102 void First() override { m_iterator = m_adc.begin(); }
0103
0104 void Next() override { ++m_iterator; }
0105
0106 bool IsDone() const override { return m_iterator == m_adc.end(); }
0107
0108 uint16_t CurrentTimeBin() const override
0109 {
0110 if (!IsDone())
0111 {
0112 return m_iterator->first;
0113 }
0114 return std::numeric_limits<uint16_t>::max();
0115 }
0116 uint16_t CurrentAdc() const override
0117 {
0118 if (!IsDone())
0119 {
0120 return m_iterator->second;
0121 }
0122 return std::numeric_limits<uint16_t>::max();
0123 }
0124 };
0125
0126 AdcIterator *CreateAdcIterator() const override { return new AdcIteratorv2(adcmap); }
0127
0128 private:
0129 uint64_t bco{std::numeric_limits<uint64_t>::max()};
0130 uint64_t gtm_bco{std::numeric_limits<uint64_t>::max()};
0131 int32_t packetid{std::numeric_limits<int32_t>::max()};
0132 uint16_t fee{std::numeric_limits<uint16_t>::max()};
0133 uint16_t channel{std::numeric_limits<uint16_t>::max()};
0134 uint16_t sampaaddress{std::numeric_limits<uint16_t>::max()};
0135 uint16_t sampachannel{std::numeric_limits<uint16_t>::max()};
0136 uint16_t samples{std::numeric_limits<uint16_t>::max()};
0137 uint16_t type{std::numeric_limits<uint16_t>::max()};
0138 uint16_t userword{std::numeric_limits<uint16_t>::max()};
0139 uint16_t checksum{std::numeric_limits<uint16_t>::max()};
0140 uint16_t data_parity{std::numeric_limits<uint16_t>::max()};
0141
0142 bool checksumerror{true};
0143 bool parityerror{true};
0144
0145
0146 std::map<uint16_t, uint16_t> adcmap;
0147
0148 ClassDefOverride(TpcRawHitv2, 1)
0149 };
0150
0151 #endif