5 #include "CLHEP/Random/RandPoissonQ.h"
6 #include "CLHEP/Random/RandGaussQ.h"
12 bxTime_(
pset.getParameter<double>(
"bxTime")),
13 testBeamMIPTimeRes_(
pset.getParameter<double>(
"TestBeamMIPTimeRes")),
14 ScintillatorRiseTime_(
pset.getParameter<double>(
"ScintillatorRiseTime")),
15 ScintillatorDecayTime_(
pset.getParameter<double>(
"ScintillatorDecayTime")),
16 ChannelTimeOffset_(
pset.getParameter<double>(
"ChannelTimeOffset")),
17 smearChannelTimeOffset_(
pset.getParameter<double>(
"smearChannelTimeOffset")),
18 EnergyThreshold_(
pset.getParameter<double>(
"EnergyThreshold")),
19 TimeThreshold1_(
pset.getParameter<double>(
"TimeThreshold1")),
20 TimeThreshold2_(
pset.getParameter<double>(
"TimeThreshold2")),
21 ReferencePulseNpe_(
pset.getParameter<double>(
"ReferencePulseNpe")),
22 SinglePhotonTimeResolution_(
pset.getParameter<double>(
"SinglePhotonTimeResolution")),
23 DarkCountRate_(
pset.getParameter<double>(
"DarkCountRate")),
24 SigmaElectronicNoise_(
pset.getParameter<double>(
"SigmaElectronicNoise")),
25 SigmaClock_(
pset.getParameter<double>(
"SigmaClock")),
26 smearTimeForOOTtails_(
pset.getParameter<
bool>(
"SmearTimeForOOTtails")),
27 Npe_to_pC_(
pset.getParameter<double>(
"Npe_to_pC")),
28 Npe_to_V_(
pset.getParameter<double>(
"Npe_to_V")),
29 adcNbits_(
pset.getParameter<uint32_t>(
"adcNbits")),
30 tdcNbits_(
pset.getParameter<uint32_t>(
"tdcNbits")),
31 adcSaturation_MIP_(
pset.getParameter<double>(
"adcSaturation_MIP")),
32 adcBitSaturation_(
std::
pow(2, adcNbits_) - 1),
33 adcLSB_MIP_(adcSaturation_MIP_ / adcBitSaturation_),
34 adcThreshold_MIP_(
pset.getParameter<double>(
"adcThreshold_MIP")),
35 toaLSB_ns_(
pset.getParameter<double>(
"toaLSB_ns")),
36 tdcBitSaturation_(
std::
pow(2, tdcNbits_) - 1),
37 CorrCoeff_(
pset.getParameter<double>(
"CorrelationCoefficient")),
38 cosPhi_(0.5 * (
sqrt(1. + CorrCoeff_) +
sqrt(1. - CorrCoeff_))),
39 sinPhi_(0.5 * CorrCoeff_ / cosPhi_),
40 ScintillatorDecayTime2_(ScintillatorDecayTime_ * ScintillatorDecayTime_),
41 ScintillatorDecayTimeInv_(1. / ScintillatorDecayTime_),
42 SPTR2_(SinglePhotonTimeResolution_ * SinglePhotonTimeResolution_),
43 DCRxRiseTime_(DarkCountRate_ * ScintillatorRiseTime_),
44 SigmaElectronicNoise2_(SigmaElectronicNoise_ * SigmaElectronicNoise_),
45 SigmaClock2_(SigmaClock_ * SigmaClock_) {}
49 CLHEP::HepRandomEngine* hre)
const {
52 for (MTDSimHitDataAccumulator::const_iterator it =
input.begin(); it !=
input.end(); it++) {
59 for (
size_t iside = 0; iside < 2; iside++) {
61 float Npe = CLHEP::RandPoissonQ::shoot(hre, (it->second).hit_info[2 * iside][iBX]);
75 std::array<float, 3> times =
82 float finalToA2 = finalToA1 + times[1];
83 finalToA1 += times[0];
90 if ((it->second).hit_info[2 * iside][ibx] > 0.) {
92 float npe_oot = CLHEP::RandPoissonQ::shoot(hre, (it->second).hit_info[2 * iside][ibx]);
99 float smearing_oot = CLHEP::RandGaussQ::shoot(hre, 0., sigma_oot);
100 finalToA1 += smearing_oot;
101 finalToA2 += smearing_oot;
110 float smearing_stat_thr1 = CLHEP::RandGaussQ::shoot(hre, 0., sigma);
111 float smearing_stat_thr2 = CLHEP::RandGaussQ::shoot(hre, 0., sigma);
113 finalToA1 += smearing_stat_thr1;
114 finalToA2 += smearing_stat_thr2;
119 float smearing_stat_thr1 =
121 float smearing_stat_thr2 = CLHEP::RandGaussQ::shoot(
123 finalToA1 += smearing_stat_thr1;
124 finalToA2 += smearing_stat_thr1 + smearing_stat_thr2;
131 float sigma2_tot_thr1 =
133 float sigma2_tot_thr2 =
137 float smearing_thr1_uncorr = CLHEP::RandGaussQ::shoot(hre, 0.,
sqrt(sigma2_tot_thr1));
138 float smearing_thr2_uncorr = CLHEP::RandGaussQ::shoot(hre, 0.,
sqrt(sigma2_tot_thr2));
140 finalToA1 +=
cosPhi_ * smearing_thr1_uncorr +
sinPhi_ * smearing_thr2_uncorr;
141 finalToA2 +=
sinPhi_ * smearing_thr1_uncorr +
cosPhi_ * smearing_thr2_uncorr;
145 toa1[iside] = finalToA1;
146 toa2[iside] = finalToA2;
152 runTrivialShaper(rawDataFrame, chargeColl, toa1, toa2, it->first.row_, it->first.column_);
163 const uint8_t
col)
const {
166 for (
int it = 0; it < (
int)(chargeColl.size()); it++)
174 for (
int it = 0; it < (
int)(chargeColl.size()); it++) {
176 newSample.
set(
false,
false, 0, 0, 0, row,
col);
192 std::ostringstream
msg;
201 bool putInEvent(
false);
202 for (
int it = 0; it <
dfSIZE; ++it) {
203 dataFrame.setSample(it, rawDataFrame[it]);
205 putInEvent = rawDataFrame[it].threshold();
214 float OneOverR = 1. /
R;
215 float OneOverR2 = OneOverR * OneOverR;
218 float sigma2 =
Q * OneOverR2 *
219 (1. + 2. * (
Q + 1.) * OneOverR + (
Q + 1.) * (6. *
Q + 11) * OneOverR2 +
220 (
Q + 1.) * (
Q + 2.) * (2. *
Q + 5.) * OneOverR2 * OneOverR);