File indexing completed on 2025-01-17 09:55:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
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
0030 SiPMAdc() = default;
0031
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
0040 SiPMDigitalSignal digitize(const SiPMAnalogSignal&) const;
0041
0042
0043 void setJitter(const double jit) { m_Jitter = jit; }
0044
0045 void setRange(const double rng) { m_Range = rng; }
0046
0047 void setGain(const double gn) { m_Gain = gn; }
0048
0049 void setBits(const double bts) { m_Nbits = bts; }
0050
0051 void setJitterOff() { m_Jitter = 0; }
0052
0053 private:
0054
0055 std::vector<int32_t> quantize(const std::vector<double>&, uint32_t, double, double) const __attribute__((hot));
0056
0057
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 };
0068 }
0069 #endif