LDMX Software
SimQIE.h
1#ifndef TRIGSCINT_SIMQIE_H
2#define TRIGSCINT_SIMQIE_H
3
4#include <iostream>
5
6#include "TMath.h"
7#include "TRandom3.h"
8#include "TrigScint/QIEInputPulse.h"
9
10namespace trigscint {
11
17class SimQIE {
18 public:
23 SimQIE();
24
31 SimQIE(float pd, float sg, uint64_t seed);
32
38 void setTDCThreshold(const float thr) { tdc_thr_ = thr; }
39
46 void setGain(const float gg = 1e+6) { gain_ = gg * 16e-5; }
47
53 void setFreq(const float sf = 40) { tau_ = 1000 / sf; }
54
60 void setNTimeSamples(const int maxts = 5) { maxts_ = maxts; }
61
65 float QErr(float Q);
66
72 int Q2ADC(float Charge);
73
78 float ADC2Q(int ADC);
79
85 int TDC(QIEInputPulse* pp, float T0);
86
91 std::vector<int> Out_ADC(QIEInputPulse* pp);
92
97 std::vector<int> Out_TDC(QIEInputPulse* pp);
98
103 std::vector<int> CapID(QIEInputPulse* pp);
104
110 bool PulseCut(QIEInputPulse* pulse, float cut);
111
112 private:
114 int nbins_[5] = {0, 16, 36, 57, 64};
116 float edges_[17] = {-16, 34, 158, 419, 517, 915,
117 1910, 3990, 4780, 7960, 15900, 32600,
118 38900, 64300, 128000, 261000, 350000};
120 float sense_[16] = {3.1, 6.2, 12.4, 24.8, 24.8, 49.6, 99.2, 198.4,
121 198.4, 396.8, 793.6, 1587, 1587, 3174, 6349, 12700};
122
124 float gain_{1};
126 float tau_{25};
128 int maxts_{0};
129
131 float tdc_thr_{3.74};
132
134 std::unique_ptr<TRandom3> rand_ptr{nullptr};
135 TRandom3* trg_;
136
138 float mu_{0};
140 float sg_{0};
142 bool isnoise_{false};
143};
144} // namespace trigscint
145#endif
The base class to store the most important functions.
class for simulating QIE chip output
Definition SimQIE.h:17
float edges_[17]
Charge lower limit of all the 16 subranges.
Definition SimQIE.h:116
std::vector< int > Out_ADC(QIEInputPulse *pp)
Complete set of ADCs for the pulse.
Definition SimQIE.cxx:88
int nbins_[5]
Indices of first bin of each subrange.
Definition SimQIE.h:114
int TDC(QIEInputPulse *pp, float T0)
TDC of the input pulse.
Definition SimQIE.cxx:100
bool PulseCut(QIEInputPulse *pulse, float cut)
Method to check if the pulse is good to be stored.
Definition SimQIE.cxx:134
float tau_
time period of one time sample [in ns]
Definition SimQIE.h:126
void setGain(const float gg=1e+6)
Set gain of SiPM.
Definition SimQIE.h:46
int Q2ADC(float Charge)
Digitizing input charge.
Definition SimQIE.cxx:29
std::unique_ptr< TRandom3 > rand_ptr
Random number generator (required for noise simulation)
Definition SimQIE.h:134
float tdc_thr_
TDC threshold (default 3.74 microAmpere)
Definition SimQIE.h:131
float QErr(float Q)
Quantization error.
Definition SimQIE.cxx:71
float sg_
std. dev. of gaussian noise (Actual noise level)
Definition SimQIE.h:140
float sense_[16]
sensitivity of the subranges (Total charge/no. of bins)
Definition SimQIE.h:120
void setNTimeSamples(const int maxts=5)
Set the number of time samples to analyze.
Definition SimQIE.h:60
float ADC2Q(int ADC)
Converting ADC back to charge.
Definition SimQIE.cxx:52
float mu_
mean of gaussian noise (Pedestal)
Definition SimQIE.h:138
bool isnoise_
Whether noise is added to the system.
Definition SimQIE.h:142
int maxts_
No. of time samples to analyze.
Definition SimQIE.h:128
std::vector< int > CapID(QIEInputPulse *pp)
Complete set of Capacitor IDs for the pulse.
Definition SimQIE.cxx:124
SimQIE()
Defaut constructor.
Definition SimQIE.cxx:11
void setFreq(const float sf=40)
Set sampling frequency of QIE.
Definition SimQIE.h:53
float gain_
QIE gain -> to convert from no. of e- to charge in fC.
Definition SimQIE.h:124
void setTDCThreshold(const float thr)
Set current threshold for TDC latch.
Definition SimQIE.h:38
std::vector< int > Out_TDC(QIEInputPulse *pp)
Complete set of TDCs for the pulse.
Definition SimQIE.cxx:113