Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /** @class sipm::SiPMAdc SimSiPM/SimSiPM/SiPMAdc.h SiPMAdc.h
0002  *
0003  *  @brief Class that simulates the operation of an ADC converter.
0004  *
0005  *  This class is used to convert a @ref SiPMAnalogSignal into a @ref
0006  *  SiPMDigitalSignal. The signal is quantized using a given number of bits
0007  *  after it is amplified using a given gain.
0008  *
0009  *  @author Edoardo Proserpio
0010  *  @date 2020
0011  */
0012 
0013 #ifndef SIPM_SIPMADC_H
0014 #define SIPM_SIPMADC_H
0015 
0016 #include <algorithm>
0017 #include <cmath>
0018 #include <stdint.h>
0019 #include <vector>
0020 
0021 #include "SiPMAnalogSignal.h"
0022 #include "SiPMDigitalSignal.h"
0023 #include "SiPMRandom.h"
0024 
0025 namespace sipm {
0026 
0027 class SiPMAdc {
0028 public:
0029   /// @brief SiPMAdc default constructor
0030   SiPMAdc() = default;
0031   /// @brief SiPMAdc contructor with given parameters
0032   SiPMAdc(const uint32_t, const double, const double);
0033 
0034   uint32_t nBits() const { return m_Nbits; }
0035   double range() const { return m_Range; }
0036   double gain() const { return m_Gain; }
0037   double jitter() const { return m_Jitter; }
0038 
0039   /// @brief Digitizes an analog signalt to a digital one
0040   SiPMDigitalSignal digitize(const SiPMAnalogSignal&) const;
0041 
0042   /// @brief Sets jitter parameter
0043   void setJitter(const double jit) { m_Jitter = jit; }
0044   /// @brief Sets range parameter
0045   void setRange(const double rng) { m_Range = rng; }
0046   /// @brief Sets gain parameter
0047   void setGain(const double gn) { m_Gain = gn; }
0048   /// @brief Sets number of bits
0049   void setBits(const double bts) { m_Nbits = bts; }
0050   // @ Turns off jitter effect
0051   void setJitterOff() { m_Jitter = 0; }
0052 
0053 private:
0054   /// @brief Quantizes a signal using a given number of bits
0055   std::vector<int32_t> quantize(const std::vector<double>&, uint32_t, double, double) const __attribute__((hot));
0056   /// @brief Adds jitter to a signal
0057   /// @todo Maybe better to return by reference here
0058   std::vector<double> addJitter(std::vector<double>&, const double) const __attribute__((hot));
0059 
0060   uint32_t m_Nbits;
0061   double m_Range;
0062   double m_Gain;
0063 
0064   double m_Jitter = 0;
0065 
0066   mutable SiPMRandom rng;
0067 }; /* SiPMAdc */
0068 } // namespace sipm
0069 #endif /* SIPM_SIPMADC_H */