Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-01 09:06:28

0001 /** @class sipm::SiPMAnalogSignal SimSiPM/SimSiPM/SiPMAnalogSignal.h
0002  * SiPMAnalogSignal.h
0003  *
0004  *  @brief Class containing the waveform of the generated signal.
0005  *
0006  *  This class stores the generated signal as a SiPMVector<float>
0007  *  representing the sampled analog waveform.
0008  *  It also has some methods that can be used to extract some simple features
0009  *  from the signal.
0010  *
0011  *  The amplitude of the signal is scaled such that the signal from one photoelectron
0012  *  has height equal to 1 (not considering noise). In this way all other values like
0013  *  SNR and CCGV are scaled proportionally.
0014  *
0015  *  @author Edoardo Proserpio
0016  *  @date 2020
0017  */
0018 
0019 #ifndef SIPM_SIPMSIGNAL_H
0020 #define SIPM_SIPMSIGNAL_H
0021 
0022 #include <cmath>
0023 #include <cstdint>
0024 #include <iostream>
0025 #include <sstream>
0026 #include <vector>
0027 
0028 namespace sipm {
0029 class SiPMAnalogSignal {
0030 public:
0031   SiPMAnalogSignal() = default;
0032 
0033   SiPMAnalogSignal(const std::vector<float>& wav, const double sampling) noexcept
0034     : m_Waveform(std::move(wav)), m_Sampling(sampling) {};
0035 
0036   float* data() noexcept { return m_Waveform.data(); }
0037 
0038   inline float& operator[](const uint32_t i) noexcept { return m_Waveform[i]; }
0039   inline float operator[](const uint32_t i) const noexcept { return m_Waveform[i]; }
0040 
0041   /// @brief Returns the number of points in the waveform
0042   inline uint32_t size() const { return m_Waveform.size(); }
0043   /// @brief Returns the sampling time of the signal in ns
0044   inline double sampling() const { return m_Sampling; }
0045   /// @brief Returns the signal length in ns
0046   inline double length() const { return (double)m_Waveform.size() / m_Sampling; }
0047   /// @brief Returns the waveform in an accessible data structure
0048   inline const std::vector<float>& waveform() const noexcept {return m_Waveform; }
0049 
0050 
0051   /// @brief Returns integral of the signal
0052   double integral(const double, const double, const double) const;
0053   /// @brief Returns peak of the signal
0054   double peak(const double, const double, const double) const;
0055   /// @brief Returns time over threshold of the signal
0056   double tot(const double, const double, const double) const;
0057   /// @brief Returns time of arrival of the signal
0058   double toa(const double, const double, const double) const;
0059   /// @brief Returns time of peak
0060   double top(const double, const double, const double) const;
0061 
0062   std::string toString() const {
0063     std::stringstream ss;
0064     ss << *this;
0065     return ss.str();
0066   }
0067   friend std::ostream& operator<<(std::ostream&, const SiPMAnalogSignal&);
0068 
0069 private:
0070   std::vector<float> m_Waveform;
0071   double m_Sampling;
0072 } /* SiPMAnalogSignal */;
0073 
0074 } /* namespace sipm */
0075 #endif /* SIPM_SIPMSIGNAL_H */