Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:14

0001 #ifndef FUN4ALLRAW_TPCRAWTHITv3_H
0002 #define FUN4ALLRAW_TPCRAWTHITv3_H
0003 
0004 #include "MicromegasRawHit.h"
0005 
0006 #include <phool/PHObject.h>
0007 
0008 #include <cassert>
0009 #include <limits>
0010 #include <utility>
0011 #include <vector>
0012 
0013 // NOLINTNEXTLINE(hicpp-special-member-functions)
0014 class MicromegasRawHitv3 : public MicromegasRawHit
0015 {
0016  public:
0017   MicromegasRawHitv3() = default;
0018   explicit MicromegasRawHitv3(MicromegasRawHit *);
0019   explicit MicromegasRawHitv3(MicromegasRawHitv3 &&other) noexcept;
0020 
0021   /** identify Function from PHObject
0022       @param os Output Stream
0023    */
0024   void identify(std::ostream &os = std::cout) const override;
0025 
0026   void Clear(Option_t * /*unused*/) override;
0027 
0028   uint64_t get_bco() const override { return bco; }
0029   // cppcheck-suppress virtualCallInConstructor
0030   void set_bco(const uint64_t val) override { bco = val; }
0031 
0032   int32_t get_packetid() const override { return packetid; }
0033   // cppcheck-suppress virtualCallInConstructor
0034   void set_packetid(const int32_t val) override { packetid = val; }
0035 
0036   uint16_t get_fee() const override { return fee; }
0037   // cppcheck-suppress virtualCallInConstructor
0038   void set_fee(const uint16_t val) override { fee = val; }
0039 
0040   uint16_t get_channel() const override { return channel; }
0041   // cppcheck-suppress virtualCallInConstructor
0042   void set_channel(const uint16_t val) override { channel = val; }
0043 
0044   uint16_t get_sampaaddress() const override
0045   {
0046     return static_cast<uint16_t>(channel >> 5U) & 0xfU;
0047   }
0048 
0049   uint16_t get_sampachannel() const override { return channel & 0x1fU; }
0050 
0051   // index of the first sample with data
0052   uint16_t get_sample_begin() const override
0053   {
0054     return m_adcData.empty() ? 0 : m_adcData.front().first;
0055   }
0056 
0057   // index of the next to last sample with data
0058   uint16_t get_sample_end() const override
0059   {
0060     return m_adcData.empty() ? 0 : m_adcData.back().first + m_adcData.back().second.size();
0061   }
0062 
0063   // get adc value
0064   uint16_t get_adc(const uint16_t sample) const override;
0065 
0066   //! adc list
0067   using adc_list_t = std::vector<uint16_t>;
0068 
0069   // set adc values
0070   void move_adc_waveform(const uint16_t start_time, adc_list_t &&adc);
0071 
0072  private:
0073   uint64_t bco{std::numeric_limits<uint64_t>::max()};
0074   int32_t packetid{std::numeric_limits<int32_t>::max()};
0075   uint16_t fee{std::numeric_limits<uint16_t>::max()};
0076   uint16_t channel{std::numeric_limits<uint16_t>::max()};
0077   uint16_t type{std::numeric_limits<uint16_t>::max()};
0078   uint16_t checksum{std::numeric_limits<uint16_t>::max()};
0079   uint16_t data_parity{std::numeric_limits<uint16_t>::max()};
0080 
0081   bool checksumerror{true};
0082   bool parityerror{true};
0083 
0084   //! list of waveforms
0085   /** each pair contains the start sample of the waveform and the constituting adc values */
0086   using waveform_pair_t = std::pair<uint16_t, adc_list_t>;
0087   std::vector<waveform_pair_t> m_adcData;
0088 
0089   ClassDefOverride(MicromegasRawHitv3, 1)
0090 };
0091 
0092 #endif