Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef FUN4ALLRAW_TPCDIODEV1_H
0002 #define FUN4ALLRAW_TPCDIODEV1_H
0003 
0004 #include "TpcDiode.h"
0005 
0006 #include <phool/PHObject.h>
0007 
0008 #include <cassert>
0009 #include <limits>
0010 
0011 class TpcDiodev1 : public TpcDiode
0012 {
0013  public:
0014   TpcDiodev1() = default;
0015   TpcDiodev1(TpcDiode* tpcdiode);
0016   ~TpcDiodev1() override = default;
0017 
0018   /** identify Function from PHObject
0019       @param os Output Stream
0020    */
0021   void identify(std::ostream& os = std::cout) const override;
0022 
0023   void Clear(Option_t*) override;
0024 
0025   // uint64_t get_bco() const override { return bco; }
0026 
0027   // void set_bco(const uint64_t val) override { bco = val; }
0028 
0029   // uint64_t get_gtm_bco() const override { return gtm_bco; }
0030   // void set_gtm_bco(const uint64_t val) override { gtm_bco = val; }
0031 
0032   int32_t get_packetid() const override { return packetid; }
0033   void set_packetid(const int32_t val) override { packetid = val; }
0034 
0035   // uint16_t get_fee() const override { return fee; }
0036   // void set_fee(const uint16_t val) override { fee = val; }
0037 
0038   uint16_t get_channel() const override { return channel; }
0039   void set_channel(const uint16_t val) override { channel = val; }
0040 
0041   uint16_t get_maxadc() const override { return maxadc; }
0042   void set_maxadc(const uint16_t val) override { maxadc = val; }
0043 
0044   uint16_t get_maxbin() const override { return maxbin; }
0045   void set_maxbin(const uint16_t val) override { maxbin = val; }
0046 
0047   double get_integral() const override { return integral; }
0048   void set_integral(const double val) override { integral = val; }
0049 
0050   double get_pulsewidth() const override { return pulsewidth; }
0051   void set_pulsewidth(const double val) override { pulsewidth = val; }
0052 
0053   uint16_t get_nabovethreshold() const override { return nabovethreshold; }
0054   void set_nabovethreshold(const uint16_t val) override { nabovethreshold = val; }
0055 
0056   // uint16_t get_sampaaddress() const override { return sampaaddress; }
0057   // void set_sampaaddress(const uint16_t val) override { sampaaddress = val; }
0058 
0059   // uint16_t get_sampachannel() const override { return sampachannel; }
0060   // void set_sampachannel(const uint16_t val) override { sampachannel = val; }
0061 
0062   uint16_t get_samples() const override { return samples; }
0063   void set_samples(const uint16_t val) override
0064   {
0065     // assign
0066     samples = val;
0067 
0068     // resize adc vector
0069     adc.resize(val, 0);
0070   }
0071 
0072   uint16_t get_adc(uint16_t sample) const override
0073   {
0074     assert(sample < adc.size());
0075     return adc[sample];
0076   }
0077 
0078   void set_adc(uint16_t sample, uint16_t val) override
0079   {
0080     assert(sample < adc.size());
0081     adc[sample] = val;
0082   }
0083 
0084   // class AdcIteratorv1 : public AdcIterator
0085   //   {
0086   //    private:
0087   //     const std::vector<uint16_t> & m_adc;
0088   //     uint16_t m_index = 0;
0089 
0090   //    public:
0091   //     explicit AdcIteratorv1(const std::vector<uint16_t> & adc)
0092   //       : m_adc(adc)
0093   //     {
0094   //     }
0095 
0096   //     void First() override { m_index = 0; }
0097 
0098   //     void Next() override { ++m_index; }
0099 
0100   //     bool IsDone() const override { return m_index >= m_adc.size(); }
0101 
0102   //     uint16_t CurrentTimeBin() const override
0103   //     {
0104   //       return m_index;
0105   //     }
0106   //     uint16_t CurrentAdc() const override
0107   //     {
0108   //       if (!IsDone())
0109   //       {
0110   //         return m_adc[m_index];
0111   //       }
0112   //       return std::numeric_limits<uint16_t>::max();  // Or throw an exception
0113   //     }
0114   //   };
0115 
0116   // AdcIterator* CreateAdcIterator() const override { return new AdcIteratorv1(adc); }
0117 
0118  private:
0119   // uint64_t bco = std::numeric_limits<uint64_t>::max();
0120   // uint64_t gtm_bco = std::numeric_limits<uint64_t>::max();
0121   int32_t packetid = std::numeric_limits<int32_t>::max();
0122   // uint16_t fee = std::numeric_limits<uint16_t>::max();
0123   uint16_t channel = std::numeric_limits<uint16_t>::max();
0124   // uint16_t sampaaddress = std::numeric_limits<uint16_t>::max();
0125   // uint16_t sampachannel = std::numeric_limits<uint16_t>::max();
0126   uint16_t samples = std::numeric_limits<uint16_t>::max();
0127   uint16_t maxadc = std::numeric_limits<uint16_t>::max();
0128   uint16_t maxbin = std::numeric_limits<uint16_t>::max();
0129   double integral = std::numeric_limits<uint16_t>::max();
0130   double pulsewidth = std::numeric_limits<uint16_t>::max();
0131   uint16_t nabovethreshold = std::numeric_limits<uint16_t>::max();
0132 
0133   //! adc value for each sample
0134   std::vector<uint16_t> adc;
0135 
0136   ClassDefOverride(TpcDiodev1, 1)
0137 };
0138 
0139 #endif