14
14
#ifndef SIPM_SIPMPROPERTIES_H
15
15
#define SIPM_SIPMPROPERTIES_H
16
16
17
- #include < algorithm>
18
17
#include < cmath>
19
18
#include < cstdint>
20
- #include < fstream>
21
- #include < iomanip>
22
19
#include < iostream>
23
20
#include < map>
24
21
#include < sstream>
@@ -45,6 +42,8 @@ class SiPMProperties {
45
42
kGaussian // /< 95% of photons have a gaussian distribution
46
43
};
47
44
45
+ SiPMProperties ();
46
+
48
47
// / @brief Used to read settings from a json file
49
48
static SiPMProperties readSettings (const std::string&);
50
49
@@ -55,13 +54,13 @@ class SiPMProperties {
55
54
constexpr uint32_t pitch () const { return m_Pitch; }
56
55
57
56
// / @brief Returns total number of cells in the sensor
58
- constexpr uint32_t nCells () const ;
57
+ constexpr uint32_t nCells () const { return m_Ncells; }
59
58
60
59
// / @brief Returns number of cells in the side of the sensor
61
- constexpr uint32_t nSideCells () const ;
60
+ constexpr uint32_t nSideCells () const { return m_SideCells; }
62
61
63
62
// / @brief Returns total number of points in the signal
64
- constexpr uint32_t nSignalPoints () const ;
63
+ constexpr uint32_t nSignalPoints () const { return m_SignalPoints; }
65
64
66
65
// / @brief Returns @ref HitDistribution type of the sensor
67
66
constexpr HitDistribution hitDistribution () const { return m_HitDistribution; }
@@ -114,7 +113,7 @@ class SiPMProperties {
114
113
constexpr double apSlowFraction () const { return m_ApSlowFraction; }
115
114
116
115
// / @brief Returns value of cell-to-cell gain variation.
117
- constexpr double ccgv () const { return m_Ccgv; }
116
+ constexpr float ccgv () const { return m_Ccgv; }
118
117
119
118
// / @brief Returns relative gain.
120
119
constexpr double gain () const { return m_Gain; }
@@ -123,13 +122,13 @@ class SiPMProperties {
123
122
constexpr double snrdB () const { return m_SnrdB; }
124
123
125
124
// / @brief Returns RMS of the noise.
126
- constexpr double snrLinear () const ;
125
+ constexpr double snrLinear () const { return m_SnrLinear; }
127
126
128
127
// / @brief Returns value of PDE if PdeType::kSimplePde is set.
129
128
constexpr double pde () const { return m_Pde; }
130
129
131
130
// / @brief Returns wavelength-PDE values if PdeType::kSpectrumPde is set
132
- const std::map<double , double >& pdeSpectrum () const { return m_PdeSpectrum; }
131
+ std::map<double , double > pdeSpectrum () const { return m_PdeSpectrum; }
133
132
134
133
// / @brief Returns type of PDE calculation used.
135
134
constexpr PdeType pdeType () { return m_HasPde; }
@@ -170,11 +169,17 @@ class SiPMProperties {
170
169
}
171
170
172
171
// / @brief Set sampling time of the signal in ns
173
- void setSampling (const double );
172
+ void setSampling (const double x) {
173
+ m_Sampling = x;
174
+ m_SignalPoints = m_SignalLength / m_Sampling;
175
+ }
174
176
175
177
// / @brief Set length of the signa in ns
176
- // / @parame x Signal length in ns
177
- constexpr void setSignalLength (const double x) { m_SignalLength = x; }
178
+ // / @param x Signal length in ns
179
+ constexpr void setSignalLength (const double x) {
180
+ m_SignalLength = x;
181
+ m_SignalPoints = m_SignalLength / m_Sampling;
182
+ }
178
183
179
184
// / @brief Set rising time constant of signal @sa SiPMSensor::signalShape
180
185
// / @param x Signal risign time constant in ns
@@ -220,11 +225,11 @@ class SiPMProperties {
220
225
221
226
// / @brief Set probability to have slow afterpulses over fast ones
222
227
// / @param x Fraction of afterpulses generated using slow component
223
- constexpr void setTauApSlowFraction (const double x) { m_ApSlowFraction = x; }
228
+ constexpr void setApSlowFraction (const double x) { m_ApSlowFraction = x; }
224
229
225
230
// / @brief Set cell-to-cell gain variation @sa m_Ccgv
226
231
// / @param x Value of ccgv as a fraction of signal
227
- constexpr void setCcgv (const double x) { m_Ccgv = x; }
232
+ constexpr void setCcgv (const float x) { m_Ccgv = x; }
228
233
229
234
// / @brief Set value for PDE (and sets @ref PdeType::kSimplePde)
230
235
// / @param x Flat value of PDE to be applied
@@ -304,17 +309,17 @@ class SiPMProperties {
304
309
private:
305
310
double m_Size = 1 ;
306
311
double m_Pitch = 25 ;
307
- mutable uint32_t m_Ncells = 0 ;
308
- mutable uint32_t m_SideCells = 0 ;
312
+ uint32_t m_Ncells;
313
+ uint32_t m_SideCells;
309
314
HitDistribution m_HitDistribution = HitDistribution::kUniform ;
310
315
311
316
double m_Sampling = 1 ;
312
317
double m_SignalLength = 500 ;
313
- mutable uint32_t m_SignalPoints = 0 ;
318
+ uint32_t m_SignalPoints = 0 ;
314
319
double m_RiseTime = 1 ;
315
320
double m_FallTimeFast = 50 ;
316
321
double m_FallTimeSlow = 100 ;
317
- double m_SlowComponentFraction;
322
+ double m_SlowComponentFraction = 0.2 ;
318
323
double m_RecoveryTime = 50 ;
319
324
320
325
double m_Dcr = 200e3 ;
@@ -325,10 +330,10 @@ class SiPMProperties {
325
330
double m_TauApFastComponent = 10 ;
326
331
double m_TauApSlowComponent = 80 ;
327
332
double m_ApSlowFraction = 0.5 ;
328
- double m_Ccgv = 0.05 ;
333
+ float m_Ccgv = 0.05 ;
329
334
double m_SnrdB = 30 ;
330
- double m_Gain = 1.0 ;
331
- mutable double m_SnrLinear = 0 ;
335
+ float m_Gain = 1.0 ;
336
+ double m_SnrLinear;
332
337
333
338
double m_Pde = 1 ;
334
339
std::map<double , double > m_PdeSpectrum;
@@ -340,40 +345,5 @@ class SiPMProperties {
340
345
bool m_HasAp = true ;
341
346
bool m_HasSlowComponent = false ;
342
347
};
343
- // Constexpr assumes inline
344
-
345
- constexpr uint32_t SiPMProperties::nCells () const {
346
- // m_SideCells and m_Ncells are cached
347
- if ((m_SideCells == 0 ) || (m_Ncells == 0 )) {
348
- m_SideCells = 1000 * m_Size / m_Pitch;
349
- m_Ncells = m_SideCells * m_SideCells;
350
- }
351
- return m_Ncells;
352
- }
353
-
354
- constexpr uint32_t SiPMProperties::nSideCells () const {
355
- // m_SideCells and m_Ncells are cached
356
- if ((m_SideCells == 0 ) || (m_Ncells == 0 )) {
357
- m_SideCells = 1000 * m_Size / m_Pitch;
358
- m_Ncells = m_SideCells * m_SideCells;
359
- }
360
- return m_SideCells;
361
- }
362
-
363
- constexpr uint32_t SiPMProperties::nSignalPoints () const {
364
- // m_Signalpoints is cached
365
- if (m_SignalPoints == 0 ) {
366
- m_SignalPoints = m_SignalLength / m_Sampling;
367
- }
368
- return m_SignalPoints;
369
- }
370
-
371
- constexpr double SiPMProperties::snrLinear () const {
372
- // m_SnrLinear is cached
373
- if (m_SnrLinear == 0 ) {
374
- m_SnrLinear = pow (10 , -m_SnrdB / 20 );
375
- }
376
- return m_SnrLinear;
377
- }
378
348
} // namespace sipm
379
349
#endif /* SIPM_SIPMPROPERTIES_H */
0 commit comments