Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /** @class sipm::SiPMProperties SimSiPM/SimSiPM/SiPMProperties.h
0002  * SiPMDigitalSignal.h
0003  *
0004  *  @brief Class storing all the parameters that describe a SiPM.
0005  *
0006  *  This class stores all the parameters and values used to describe a SiPM
0007  *  sensor or signal. It also allows to switch on or off some noise effects
0008  *  and can set different levels of detail in the evaluation of PDE.
0009  *
0010  *  @author Edoardo Proserpio
0011  *  @date 2020
0012  */
0013 
0014 #ifndef SIPM_SIPMPROPERTIES_H
0015 #define SIPM_SIPMPROPERTIES_H
0016 
0017 #include <algorithm>
0018 #include <fstream>
0019 #include <iomanip>
0020 #include <iostream>
0021 #include <map>
0022 #include <cmath>
0023 #include <stdint.h>
0024 #include <string>
0025 #include <vector>
0026 
0027 namespace sipm {
0028 
0029 class SiPMProperties {
0030 public:
0031   /** @enum PdeType
0032    * @brief Used to set different methods to evaluate PDE for each photon.
0033    */
0034   enum class PdeType {
0035     kNoPde,      ///< No PDE applied, all photons will turn in photoelectrons
0036     kSimplePde,  ///< Same PDE value used for all photons
0037     kSpectrumPde ///< PDE calculated considering the wavelength of each photon
0038   };
0039   /** @enum HitDistribution
0040    * Used to describe how photoelectrons are distributed on the SiPM surface
0041    */
0042   enum class HitDistribution {
0043     kUniform, ///< Photons uniformly distributed on the sensor surface
0044     kCircle,  ///< 95% of photons are uniformly distributed on a circle
0045     kGaussian ///< 95% of photons have a gaussian distribution
0046   };
0047 
0048   /// @brief Used to read settings from a json file
0049   void readSettings(std::string&); ///< @todo Still to implement
0050 
0051   /// @brief Returns size of sensor in mm
0052   uint32_t size() const { return m_Size; }
0053 
0054   /// @brief Returns pitch of cell in um
0055   uint32_t pitch() const { return m_Pitch; }
0056 
0057   /// @brief Returns total number of cells in the sensor
0058   uint32_t nCells() const;
0059 
0060   /// @brief Returns number of cells in the side of the sensor
0061   uint32_t nSideCells() const;
0062 
0063   /// @brief Returns total number of points in the signal
0064   uint32_t nSignalPoints() const;
0065 
0066   /// @brief Returns @ref HitDistribution type of the sensor
0067   HitDistribution hitDistribution() const { return m_HitDistribution; }
0068 
0069   /// @brief Returns total signal length in ns
0070   double signalLength() const { return m_SignalLength; }
0071 
0072   /// @brief Returns sampling time considered by the sensor in ns
0073   double sampling() const { return m_Sampling; }
0074 
0075   /// @brief Returns rising time constant @sa SiPMSensor::signalShape
0076   double risingTime() const { return m_RiseTime; }
0077 
0078   /// @brief Returns falling time constant @sa SiPMSensor::signalShape
0079   double fallingTimeFast() const { return m_FallTimeFast; }
0080 
0081   /// @brief Returns falling time constant of slow component @sa
0082   /// SiPMSensor::signalShape
0083   double fallingTimeSlow() const { return m_FallTimeSlow; }
0084 
0085   /// @brief Returns weight of slow component of the signal @sa
0086   /// SiPMSensor::signalShape.
0087   double slowComponentFraction() const { return m_SlowComponentFraction; }
0088 
0089   /// @brief Returns recovery time of SiPM cells.
0090   double recoveryTime() const { return m_RecoveryTime; }
0091 
0092   /// @brief Returns DCR value.
0093   double dcr() const { return m_Dcr; }
0094 
0095   /// @brief Returns XT value.
0096   double xt() const { return m_Xt; }
0097 
0098   /// @brief Returns Delayed XT value.
0099   double dxt() const { return m_DXt; }
0100 
0101   /// @brief Returns Delayed XT tau.
0102   double dxtTau() const { return m_DXtTau; }
0103 
0104   /// @brief Returns AP value.
0105   double ap() const { return m_Ap; }
0106 
0107   /// @brief Returns fast time constant for AP.
0108   double tauApFast() const { return m_TauApFastComponent; }
0109 
0110   /// @brief Returns slow time constant for AP.
0111   double tauApSlow() const { return m_TauApSlowComponent; }
0112 
0113   /// @brief Returns fraction of AP generated as slow.
0114   double apSlowFraction() const { return m_ApSlowFraction; }
0115 
0116   /// @brief Returns value of cell-to-cell gain variation.
0117   double ccgv() const { return m_Ccgv; }
0118 
0119   /// @brief Returns relative gain.
0120   double gain() const { return m_Gain; }
0121 
0122   /// @brief Returns SNR in dB.
0123   double snrdB() const { return m_SnrdB; }
0124 
0125   /// @brief Returns RMS of the noise.
0126   double snrLinear() const;
0127 
0128   /// @brief Returns value of PDE if PdeType::kSimplePde is set.
0129   double pde() const { return m_Pde; }
0130 
0131   /// @brief Returns wavelength-PDE values if PdeType::kSpectrumPde is set
0132   const std::map<double, double>& pdeSpectrum() const { return m_PdeSpectrum; }
0133 
0134   /// @brief Returns type of PDE calculation used.
0135   PdeType pdeType() { return m_HasPde; }
0136 
0137   /// @brief Returns true if DCR is considered.
0138   bool hasDcr() const { return m_HasDcr; }
0139 
0140   /// @brief Returns true if XT is considered.
0141   bool hasXt() const { return m_HasXt; }
0142 
0143   /// @brief Returns true if Delayes XT is considered.
0144   bool hasDXt() const { return m_HasDXt; }
0145 
0146   /// @brief Returns true if AP is considered.
0147   bool hasAp() const { return m_HasAp; }
0148 
0149   /// @brief Returns true if slow component of the signal is considered.
0150   /// @sa SiPMSensor::signalShape
0151   bool hasSlowComponent() const { return m_HasSlowComponent; }
0152 
0153   /// @brief Sets a property using its name
0154   void setProperty(const std::string&, const double);
0155 
0156   /// @brief Set size of SiPM sensitive area (side in mm)
0157   void setSize(const double x) { m_Size = x; }
0158 
0159   /// @brief Set pitch of SiPM cells (side in um)
0160   void setPitch(const double x) { m_Pitch = x; }
0161 
0162   /// @brief Set sampling time of the signal in ns
0163   void setSampling(const double x);
0164 
0165   /// @brief Set length of the signa in ns
0166   void setSignalLength(const double x) { m_SignalLength = x; }
0167 
0168   /// @brief Set rising time constant of signal @sa SiPMSensor::signalShape
0169   void setRiseTime(const double x) { m_RiseTime = x; }
0170 
0171   /// @brief Set falling time constant of signal @sa SiPMSensor::signalShape
0172   void setFallTimeFast(const double x) { m_FallTimeFast = x; }
0173 
0174   /// @brief Set falling time constant for the slow component of signal @sa
0175   /// SiPMSensor::signalShape
0176   void setFallTimeSlow(const double x) { m_FallTimeSlow = x; }
0177 
0178   /// @brief Set weigth of slow component in the signal
0179   void setSlowComponentFraction(const double x) { m_SlowComponentFraction = x; }
0180 
0181   /// @brief Set recovery time of the SiPM cell
0182   void setRecoveryTime(const double x) { m_RecoveryTime = x; }
0183 
0184   /// @brief Set SNR value in dB
0185   void setSnr(const double x) {
0186     m_SnrdB = x;
0187     m_SnrLinear = pow(10, -x / 20);
0188   }
0189 
0190   /// @brief Set time constant for the delay of fast afterpulses
0191   void setTauApFastComponent(const double x) { m_TauApFastComponent = x; }
0192 
0193   /// @brief Set time constant for the delay of slow afterpulses
0194   void setTauApSlowComponent(const double x) { m_TauApSlowComponent = x; }
0195 
0196   /// @brief Set probability to have slow afterpulses over fast ones
0197   void setTauApSlowFraction(const double x) { m_ApSlowFraction = x; }
0198 
0199   /// @brief Set cell-to-cell gain variation @sa m_Ccgv
0200   void setCcgv(const double x) { m_Ccgv = x; }
0201 
0202   /// @brief Set value for PDE (and sets @ref PdeType::kSimplePde)
0203   void setPde(const double x) { m_Pde = x; }
0204 
0205   /// @brief Set dark counts rate
0206   /// @param aDcr Dark counts rate in Hz
0207   void setDcr(const double aDcr) { m_Dcr = aDcr; }
0208 
0209   /// @brief Set optical crosstalk probability
0210   /// @param aXt optical crosstalk probability [0-1]
0211   void setXt(const double aXt) { m_Xt = aXt; }
0212 
0213   /// @brief Set delayed optical crosstalk probability as a fraction of total xt probability
0214   /// @param aDXt delayed optical crosstalk probability [0-1]
0215   void setDXt(const double aDXt) { m_DXt = aDXt; }
0216 
0217   /// @brief Set tau of delayed optical crosstalk in ns
0218   /// @param aDXt tau of delayed optical crosstalk
0219   void setDXtTau(const double aDXtTau) { m_DXtTau = aDXtTau; }
0220 
0221   /// @brief Set afterpulse probability
0222   /// @param aAp afterpulse probability [0-1]
0223   void setAp(const double aAp) { m_Ap = aAp; }
0224 
0225   /// @brief Turn off dark counts
0226   void setDcrOff() { m_HasDcr = false; }
0227   /// @brief Turn off optical crosstalk
0228   void setXtOff() { m_HasXt = false; }
0229   /// @brief Turn off delayed optical crosstalk
0230   void setDXtOff() { m_HasXt = false; }
0231   /// @brief Turn off afterpulses
0232   void setApOff() { m_HasAp = false; }
0233   /// @brief Turns off slow component of the signal
0234   void setSlowComponentOff() { m_HasSlowComponent = false; }
0235   /// @brief Turn on dark counts
0236   void setDcrOn() { m_HasDcr = true; }
0237   /// @brief Turn on optical crosstalk
0238   void setXtOn() { m_HasXt = true; }
0239   /// @brief Turn on delayed optical crosstalk
0240   void setDXtOn() { m_HasDXt = true; }
0241   /// @brief Turn on afterpulses
0242   void setApOn() { m_HasAp = true; }
0243   /// @brief Turns on slow component of the signal
0244   void setSlowComponentOn() { m_HasSlowComponent = true; }
0245   /// @brief Turn off PDE: set @ref PdeType::kNoPde
0246   void setPdeType(PdeType aPdeType) { m_HasPde = aPdeType; }
0247   /// @brief Set a spectral response of the SiPM and sets @ref
0248   /// PdeType::kSpectrumPde
0249   void setPdeSpectrum(const std::map<double, double>&);
0250   /// @brief Set a spectral response of the SiPM and sets @ref
0251   /// PdeType::kSpectrumPde
0252   void setPdeSpectrum(const std::vector<double>&, const std::vector<double>&);
0253 
0254   void setHitDistribution(const HitDistribution aHitDistribution) { m_HitDistribution = aHitDistribution; }
0255 
0256   friend std::ostream& operator<< (std::ostream&, const SiPMProperties&);
0257 
0258 private:
0259   double m_Size = 1;
0260   double m_Pitch = 25;
0261   mutable uint32_t m_Ncells = 0;
0262   mutable uint32_t m_SideCells = 0;
0263   HitDistribution m_HitDistribution = HitDistribution::kUniform;
0264 
0265   double m_Sampling = 1;
0266   double m_SignalLength = 500;
0267   mutable uint32_t m_SignalPoints = 0;
0268   double m_RiseTime = 1;
0269   double m_FallTimeFast = 50;
0270   double m_FallTimeSlow;
0271   double m_SlowComponentFraction;
0272   double m_RecoveryTime = 50;
0273 
0274   double m_Dcr = 200e3;
0275   double m_Xt = 0.05;
0276   double m_DXt = 0.05;
0277   double m_DXtTau = 15;
0278   double m_Ap = 0.03;
0279   double m_TauApFastComponent = 10;
0280   double m_TauApSlowComponent = 80;
0281   double m_ApSlowFraction = 0.5;
0282   double m_Ccgv = 0.05;
0283   double m_SnrdB = 30;
0284   double m_Gain = 1.0;
0285   mutable double m_SnrLinear = 0;
0286 
0287   double m_Pde;
0288   std::map<double, double> m_PdeSpectrum;
0289   PdeType m_HasPde = PdeType::kNoPde;
0290 
0291   bool m_HasDcr = true;
0292   bool m_HasXt = true;
0293   bool m_HasDXt = false;
0294   bool m_HasAp = true;
0295   bool m_HasSlowComponent = false;
0296 };
0297 
0298 } // namespace sipm
0299 #endif /* SIPM_SIPMPROPERTIES_H  */