6 #include "CLHEP/Random/RandPoissonQ.h"
7 #include "CLHEP/Random/RandGaussQ.h"
13 bxTime_(
pset.getParameter<double>(
"bxTime")),
14 testBeamMIPTimeRes_(
pset.getParameter<double>(
"TestBeamMIPTimeRes")),
15 ScintillatorRiseTime_(
pset.getParameter<double>(
"ScintillatorRiseTime")),
16 ScintillatorDecayTime_(
pset.getParameter<double>(
"ScintillatorDecayTime")),
17 ChannelTimeOffset_(
pset.getParameter<double>(
"ChannelTimeOffset")),
18 smearChannelTimeOffset_(
pset.getParameter<double>(
"smearChannelTimeOffset")),
19 EnergyThreshold_(
pset.getParameter<double>(
"EnergyThreshold")),
20 TimeThreshold1_(
pset.getParameter<double>(
"TimeThreshold1")),
21 TimeThreshold2_(
pset.getParameter<double>(
"TimeThreshold2")),
22 ReferencePulseNpe_(
pset.getParameter<double>(
"ReferencePulseNpe")),
23 SinglePhotonTimeResolution_(
pset.getParameter<double>(
"SinglePhotonTimeResolution")),
24 DarkCountRate_(
pset.getParameter<double>(
"DarkCountRate")),
25 SigmaElectronicNoise_(
pset.getParameter<double>(
"SigmaElectronicNoise")),
26 SigmaClock_(
pset.getParameter<double>(
"SigmaClock")),
27 smearTimeForOOTtails_(
pset.getParameter<
bool>(
"SmearTimeForOOTtails")),
28 Npe_to_pC_(
pset.getParameter<double>(
"Npe_to_pC")),
29 Npe_to_V_(
pset.getParameter<double>(
"Npe_to_V")),
30 adcNbits_(
pset.getParameter<uint32_t>(
"adcNbits")),
31 tdcNbits_(
pset.getParameter<uint32_t>(
"tdcNbits")),
32 adcSaturation_MIP_(
pset.getParameter<double>(
"adcSaturation_MIP")),
33 adcBitSaturation_(
std::
pow(2, adcNbits_) - 1),
34 adcLSB_MIP_(adcSaturation_MIP_ / adcBitSaturation_),
35 adcThreshold_MIP_(
pset.getParameter<double>(
"adcThreshold_MIP")),
36 toaLSB_ns_(
pset.getParameter<double>(
"toaLSB_ns")),
37 tdcBitSaturation_(
std::
pow(2, tdcNbits_) - 1),
38 CorrCoeff_(
pset.getParameter<double>(
"CorrelationCoefficient")),
39 cosPhi_(0.5 * (
sqrt(1. + CorrCoeff_) +
sqrt(1. - CorrCoeff_))),
40 sinPhi_(0.5 * CorrCoeff_ / cosPhi_),
41 ScintillatorDecayTime2_(ScintillatorDecayTime_ * ScintillatorDecayTime_),
42 ScintillatorDecayTimeInv_(1. / ScintillatorDecayTime_),
43 SPTR2_(SinglePhotonTimeResolution_ * SinglePhotonTimeResolution_),
44 DCRxRiseTime_(DarkCountRate_ * ScintillatorRiseTime_),
45 SigmaElectronicNoise2_(SigmaElectronicNoise_ * SigmaElectronicNoise_),
46 SigmaClock2_(SigmaClock_ * SigmaClock_) {}
50 CLHEP::HepRandomEngine* hre)
const {
53 for (MTDSimHitDataAccumulator::const_iterator it =
input.begin(); it !=
input.end(); it++) {
60 for (
size_t iside = 0; iside < 2; iside++) {
62 float Npe = CLHEP::RandPoissonQ::shoot(hre, (it->second).hit_info[2 * iside][iBX]);
76 std::array<float, 3> times =
83 float finalToA2 = finalToA1 + times[1];
84 finalToA1 += times[0];
91 if ((it->second).hit_info[2 * iside][ibx] > 0.) {
93 float npe_oot = CLHEP::RandPoissonQ::shoot(hre, (it->second).hit_info[2 * iside][ibx]);
100 float smearing_oot = CLHEP::RandGaussQ::shoot(hre, 0., sigma_oot);
101 finalToA1 += smearing_oot;
102 finalToA2 += smearing_oot;
111 float smearing_stat_thr1 = CLHEP::RandGaussQ::shoot(hre, 0., sigma);
112 float smearing_stat_thr2 = CLHEP::RandGaussQ::shoot(hre, 0., sigma);
114 finalToA1 += smearing_stat_thr1;
115 finalToA2 += smearing_stat_thr2;
120 float smearing_stat_thr1 =
122 float smearing_stat_thr2 = CLHEP::RandGaussQ::shoot(
124 finalToA1 += smearing_stat_thr1;
125 finalToA2 += smearing_stat_thr1 + smearing_stat_thr2;
132 float sigma2_tot_thr1 =
134 float sigma2_tot_thr2 =
138 float smearing_thr1_uncorr = CLHEP::RandGaussQ::shoot(hre, 0.,
sqrt(sigma2_tot_thr1));
139 float smearing_thr2_uncorr = CLHEP::RandGaussQ::shoot(hre, 0.,
sqrt(sigma2_tot_thr2));
141 finalToA1 +=
cosPhi_ * smearing_thr1_uncorr +
sinPhi_ * smearing_thr2_uncorr;
142 finalToA2 +=
sinPhi_ * smearing_thr1_uncorr +
cosPhi_ * smearing_thr2_uncorr;
146 toa1[iside] = finalToA1;
147 toa2[iside] = finalToA2;
153 runTrivialShaper(rawDataFrame, chargeColl, toa1, toa2, it->first.row_, it->first.column_);
164 const uint8_t
col)
const {
167 for (
int it = 0; it < (
int)(chargeColl.size()); it++)
175 for (
int it = 0; it < (
int)(chargeColl.size()); it++) {
177 newSample.
set(
false,
false, 0, 0, 0, row,
col);
193 std::ostringstream
msg;
202 bool putInEvent(
false);
203 for (
int it = 0; it <
dfSIZE; ++it) {
204 dataFrame.setSample(it, rawDataFrame[it]);
206 putInEvent = rawDataFrame[it].threshold();
215 float OneOverR = 1. /
R;
216 float OneOverR2 = OneOverR * OneOverR;
219 float sigma2 = Q * OneOverR2 *
220 (1. + 2. * (Q + 1.) * OneOverR + (Q + 1.) * (6. * Q + 11) * OneOverR2 +
221 (Q + 1.) * (Q + 2.) * (2. * Q + 5.) * OneOverR2 * OneOverR);