11 #include "CLHEP/Random/RandFlat.h"
12 #include "CLHEP/Random/RandGaussQ.h"
13 #include "CLHEP/Random/RandPoissonQ.h"
14 #include "GaudiKernel/MsgStream.h"
50 double qdcChannelsPerPE,
52 double qdcFedNoiseFactor,
53 double tdcPmtNoiseFactor,
54 double tdcFedNoiseFactor,
60 double dynodeGammaFactor,
61 std::vector<double> pmtSmearing,
62 std::vector<double> pmtScaling,
63 std::vector<double> gasScaling,
64 std::vector<double> npeThreshold,
66 m_numTubes (numTubes),
67 m_qdcChannelsPerPE (qdcChannelsPerPE),
68 m_qdcPedestal (qdcPedestal),
69 m_qdcFedNoiseFactor (qdcFedNoiseFactor),
70 m_tdcPmtNoiseFactor (tdcPmtNoiseFactor),
71 m_tdcFedNoiseFactor (tdcFedNoiseFactor),
72 m_TotalPMTgain (TotalPMTgain),
73 m_AmpFactor (AmpFactor),
75 m_NoiseCharge (NoiseCharge),
76 m_numDyinodes (numDyinodes),
77 m_dynodeGammaFactor (dynodeGammaFactor),
78 m_pmtSmearing (std::move(pmtSmearing)),
79 m_pmtScaling (std::move(pmtScaling)),
80 m_gasScaling (std::move(gasScaling)),
81 m_npeThreshold (std::move(npeThreshold)),
82 m_fillRootTree (fillRootTree),
101 m_tubeInfo =
new TTree(
"t",
"LUCID_LUMI_SUMMARY");
105 if (
sc.isFailure())
return StatusCode::FAILURE;
114 return StatusCode::SUCCESS;
120 assert(
x >= INT_MIN-0.5);
121 assert(
x <= INT_MAX+0.5);
123 if (
x >= 0)
return static_cast<int>(
x+0.5);
125 return static_cast<int>(
x-0.5);
133 double npeTot = npeGas + npePmt;
140 double tdcTotSmeared = 0;
144 tdcTotSmeared = (npeTot) ? tdcTotSmeared/npeTot : tdcTotSmeared;
145 tdcTotSmeared = (tdcTotSmeared < 0) ? 0 : tdcTotSmeared;
147 m_tdc =
static_cast<unsigned int>(tdcTotSmeared);
158 return StatusCode::SUCCESS;
176 if (
m_tubeID != (*hitIt)->GetTubeID())
continue;
178 if (!(*hitIt)->isDetected(rndEngine))
continue;
180 if ((*hitIt)->GetGenVolume() == 1)
m_npeGas++;
181 if ((*hitIt)->GetGenVolume() == 2)
m_npeGas++;
182 if ((*hitIt)->GetGenVolume() == 3)
m_npePmt++;
184 m_tdcTot += (*hitIt)->GetPreStepTime();
190 return StatusCode::SUCCESS;
207 for (; hitIt != hitItE; ++hitIt) {
209 if (
m_tubeID != (*hitIt).GetTubeID())
continue;
211 if (!(*hitIt).isDetected(rndEngine))
continue;
213 if ((*hitIt).GetGenVolume() == 1)
m_npeGas++;
214 if ((*hitIt).GetGenVolume() == 2)
m_npeGas++;
215 if ((*hitIt).GetGenVolume() == 3)
m_npePmt++;
217 m_tdcTot += (*hitIt).GetPreStepTime();
223 return StatusCode::SUCCESS;
240 double smearedQDC = 0;
258 if (npe < 20)
return CLHEP::RandPoissonQ::shoot(rndEngine, npe);
259 else return CLHEP::RandGaussQ::shoot (rndEngine, npe, std::sqrt(npe));