Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:58

0001 /** @class sipm::SiPMDigitalSignal SimSiPM/SimSiPM/SiPMDigitalSignal.h
0002  * SiPMDigitalSignal.h
0003  *
0004  *  @brief Class containing the digitized waveform of the generated signal.
0005  *
0006  *  This class stores the generated signal as a std::vector<int32_t>
0007  *  representing the sampled analog waveform passed through an ADC.
0008  *  It also has some methods that can be used to extract some simple features
0009  *  from the signal.
0010  *
0011  *  @author Edoardo Proserpio
0012  *  @date 2020
0013  */
0014 #include <algorithm>
0015 #include <iomanip>
0016 #include <iostream>
0017 #include <stdint.h>
0018 #include <vector>
0019 
0020 #ifndef SIPM_SIPMDIGITALSIGNAL_H
0021 #define SIPM_SIPMDIGITALSIGNAL_H
0022 
0023 namespace sipm {
0024 
0025 class SiPMDigitalSignal {
0026 public:
0027   /// @brief SiPMDigitalSignal default constructor
0028   SiPMDigitalSignal(const double sampling) noexcept : m_Sampling(sampling){};
0029 
0030   /// @brief SiPMDigitalSignal constructor from a std::vector
0031   SiPMDigitalSignal(const std::vector<int32_t>& wav, const double sampling) noexcept
0032     : m_Waveform(wav), m_Sampling(sampling){};
0033 
0034   /// @brief Move assignement operator from a std::vector
0035   SiPMDigitalSignal& operator=(const std::vector<int32_t>&& aVect) noexcept {
0036     m_Waveform = std::move(aVect);
0037     return *this;
0038   };
0039 
0040   /// @brief Copy assignement operator from a std::vector
0041   inline int32_t& operator[](const uint32_t i) noexcept { return m_Waveform[i]; }
0042   inline int32_t operator[](const uint32_t i) const noexcept { return m_Waveform[i]; }
0043 
0044   /// @brief Returns the size of the vector containing the signal
0045   uint32_t size() const { return m_Waveform.size(); }
0046   /// @brief Clears all elements of the vector containing the signal
0047   void clear() { return m_Waveform.clear(); }
0048   /// @brief Returns the sampling time of the signal in ns
0049   double sampling() const { return m_Sampling; }
0050   /// @brief Used to access signal elements as if it is a std::vector
0051   const std::vector<int32_t> waveform() const { return m_Waveform; }
0052 
0053   /// @brief Returns integral of the signal
0054   int32_t integral(const double, const double, const int32_t) const;
0055   /// @brief Returns peak of the signal
0056   int32_t peak(const double, const double, const int32_t) const;
0057   /// @brief Returns time over threshold of the signal
0058   double tot(const double, const double, const int32_t) const;
0059   /// @brief Returns time of arrival of the signal
0060   double toa(const double, const double, const int32_t) const;
0061   /// @brief Returns time of peak
0062   double top(const double, const double, const int32_t) const;
0063 
0064   friend std::ostream& operator<< (std::ostream&, const SiPMDigitalSignal&);
0065 
0066 private:
0067   std::vector<int32_t> m_Waveform;
0068   const double m_Sampling;
0069 };
0070 
0071 } // namespace sipm
0072 #endif /* SIPM_SIPMSIGNAL_H */