File indexing completed on 2025-04-01 09:06:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef SIPM_SIPMSENSOR_H
0012 #define SIPM_SIPMSENSOR_H
0013 #include <cstdint>
0014 #include <iostream>
0015 #include <sstream>
0016 #include <vector>
0017
0018 #include "SiPMAnalogSignal.h"
0019 #include "SiPMDebugInfo.h"
0020 #include "SiPMHit.h"
0021 #include "SiPMProperties.h"
0022 #include "SiPMRandom.h"
0023 #include "SiPMTypes.h"
0024
0025 namespace sipm {
0026 class SiPMSensor {
0027 public:
0028
0029
0030
0031 explicit SiPMSensor(const SiPMProperties&);
0032
0033 SiPMSensor();
0034
0035
0036 const SiPMProperties& properties() const { return m_Properties; }
0037
0038
0039
0040
0041
0042 SiPMAnalogSignal signal() const { return m_Signal; }
0043
0044
0045
0046
0047
0048 std::vector<SiPMHit*> hits() const { return m_Hits; }
0049
0050
0051 const SiPMRandom rng() const { return m_rng; }
0052
0053 SiPMRandom& rng() { return m_rng; }
0054
0055
0056 SiPMDebugInfo debug() const {
0057 return SiPMDebugInfo{static_cast<uint32_t>(m_PhotonTimes.size()), m_nPe, m_nDcr, m_nXt, m_nDXt, m_nAp};
0058 }
0059
0060
0061
0062
0063
0064 void setProperty(const std::string&, const double);
0065
0066
0067
0068
0069 void setProperties(const SiPMProperties&);
0070
0071
0072 void addPhoton(const double);
0073
0074
0075 void addPhoton(const double, const double);
0076
0077
0078 void addPhotons(const std::vector<double>&);
0079
0080
0081 void addPhotons(const std::vector<double>&, const std::vector<double>&);
0082
0083
0084 void runEvent();
0085
0086
0087
0088
0089 void resetState();
0090
0091 friend std::ostream& operator<<(std::ostream&, const SiPMSensor&);
0092 std::string toString() const {
0093 std::stringstream ss;
0094 ss << *this;
0095 return ss.str();
0096 }
0097
0098 private:
0099 double evaluatePde(const double) const;
0100 constexpr bool isInSensor(const int32_t r, const int32_t c) const noexcept {
0101 const int32_t nSideCells = m_Properties.nSideCells();
0102 return (r >= 0) & (c >= 0) & (r < nSideCells) & (c < nSideCells);
0103 }
0104 pair<uint32_t> hitUniform() const;
0105 pair<uint32_t> hitCircle() const;
0106 pair<uint32_t> hitGaussian() const;
0107 pair<uint32_t> hitCell() const;
0108 void signalShape();
0109
0110 void addDcrEvents();
0111 void addPhotoelectrons();
0112 void addCorrelatedNoise();
0113
0114 SiPMHit* generateXtHit(const SiPMHit*) const;
0115 SiPMHit* generateApHit(const SiPMHit*) const;
0116
0117 void calculateSignalAmplitudes();
0118 void generateSignal();
0119
0120 SiPMProperties m_Properties;
0121 mutable SiPMRandom m_rng;
0122
0123 uint32_t m_nTotalHits = 0;
0124 uint32_t m_nPe = 0;
0125 uint32_t m_nDcr = 0;
0126 uint32_t m_nXt = 0;
0127 uint32_t m_nDXt = 0;
0128 uint32_t m_nAp = 0;
0129
0130 std::vector<double> m_PhotonTimes;
0131 std::vector<double> m_PhotonWavelengths;
0132 std::vector<SiPMHit*> m_Hits;
0133
0134 std::vector<float> m_SignalShape;
0135 SiPMAnalogSignal m_Signal;
0136 };
0137
0138 }
0139 #endif