Back to home page

EIC code displayed by LXR

 
 

    


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

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 std::vector<double>
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 <algorithm>
0023 #include <cmath>
0024 #include <iomanip>
0025 #include <iostream>
0026 #include <numeric>
0027 #include <stdint.h>
0028 #include <vector>
0029 
0030 namespace sipm {
0031 
0032 class SiPMAnalogSignal {
0033 public:
0034   /// @brief SiPMAnalogSignal default constructor
0035   SiPMAnalogSignal() = default;
0036 
0037   /// @brief SiPMAnalogSignal constructor from a std::vector
0038   SiPMAnalogSignal(const std::vector<double>& wav, const double sampling) noexcept
0039     : m_Waveform(wav), m_Sampling(sampling){}; /// @brief Move assignement operator from a std::vector
0040 
0041   /// @brief Move assignement operator from a std::vector
0042   SiPMAnalogSignal& operator=(const std::vector<double>&& aVect) noexcept {
0043     m_Waveform = std::move(aVect);
0044     return *this;
0045   }
0046 
0047   /// @brief Used to access signal elements as if it is a std::vector
0048   inline double& operator[](const uint32_t i) noexcept { return m_Waveform[i]; }
0049   /// @brief Used to access signal elements as if it is a std::vector
0050   inline double operator[](const uint32_t i) const noexcept { return m_Waveform[i]; }
0051 
0052   /// @brief Returns the size of the vector containing the signal
0053   uint32_t size() const { return m_Waveform.size(); }
0054   /// @brief Clears all elements of the vector containing the signal
0055   void clear() { m_Waveform.clear(); m_peak = -1;}
0056   /// @brief Returns the sampling time of the signal in ns
0057   double sampling() const { return m_Sampling; }
0058   /// @brief Returns a std::vector containing the sampled waveform
0059   std::vector<double> waveform() const { return m_Waveform; }
0060 
0061   /// @brief Returns integral of the signal
0062   double integral(const double, const double, const double) const;
0063   /// @brief Returns peak of the signal
0064   double peak(const double, const double, const double) const;
0065   /// @brief Returns time over threshold of the signal
0066   double tot(const double, const double, const double) const;
0067   /// @brief Returns time of arrival of the signal
0068   double toa(const double, const double, const double) const;
0069   /// @brief Returns time of peak
0070   double top(const double, const double, const double) const;
0071 
0072   /// @brief Sets the sampligng time of the signal
0073   void setSampling(const double x) { m_Sampling = x; }
0074 
0075   /// @brief Applies a low-pass filter to the input vector
0076   SiPMAnalogSignal lowpass(const double) const;
0077 
0078   friend std::ostream& operator<<(std::ostream&, const SiPMAnalogSignal&);
0079 
0080 private:
0081   std::vector<double> m_Waveform;
0082   double m_Sampling;
0083   mutable double m_peak = -1;
0084 
0085 } /* SiPMAnalogSignal */;
0086 } /* namespace sipm */
0087 #endif /* SIPM_SIPMSIGNAL_H */