11 #include "CLHEP/Random/RandFlat.h"
12 #include "CLHEP/Random/RandGaussQ.h"
13 #include "CLHEP/Random/RandPoissonQ.h"
14 #include "GaudiKernel/MsgStream.h"
15 #include "GaudiKernel/Bootstrap.h"
16 #include "GaudiKernel/ITHistSvc.h"
52 double qdcChannelsPerPE,
54 double qdcFedNoiseFactor,
55 double tdcPmtNoiseFactor,
56 double tdcFedNoiseFactor,
62 double dynodeGammaFactor,
63 std::vector<double> pmtSmearing,
64 std::vector<double> pmtScaling,
65 std::vector<double> gasScaling,
66 std::vector<double> npeThreshold,
68 m_numTubes (numTubes),
69 m_qdcChannelsPerPE (qdcChannelsPerPE),
70 m_qdcPedestal (qdcPedestal),
71 m_qdcFedNoiseFactor (qdcFedNoiseFactor),
72 m_tdcPmtNoiseFactor (tdcPmtNoiseFactor),
73 m_tdcFedNoiseFactor (tdcFedNoiseFactor),
74 m_TotalPMTgain (TotalPMTgain),
75 m_AmpFactor (AmpFactor),
77 m_NoiseCharge (NoiseCharge),
78 m_numDyinodes (numDyinodes),
79 m_dynodeGammaFactor (dynodeGammaFactor),
80 m_pmtSmearing (std::move(pmtSmearing)),
81 m_pmtScaling (std::move(pmtScaling)),
82 m_gasScaling (std::move(gasScaling)),
83 m_npeThreshold (std::move(npeThreshold)),
84 m_fillRootTree (fillRootTree),
102 SmartIF<ITHistSvc> digitHistSvc{Gaudi::svcLocator()->service(
"THistSvc")};
103 if (!digitHistSvc) {
return StatusCode::FAILURE; }
105 m_tubeInfo =
new TTree(
"t",
"LUCID_LUMI_SUMMARY");
109 if (
sc.isFailure())
return StatusCode::FAILURE;
118 return StatusCode::SUCCESS;
124 assert(
x >= INT_MIN-0.5);
125 assert(
x <= INT_MAX+0.5);
127 if (
x >= 0)
return static_cast<int>(
x+0.5);
129 return static_cast<int>(
x-0.5);
137 double npeTot = npeGas + npePmt;
144 double tdcTotSmeared = 0;
148 tdcTotSmeared = (npeTot) ? tdcTotSmeared/npeTot : tdcTotSmeared;
149 tdcTotSmeared = (tdcTotSmeared < 0) ? 0 : tdcTotSmeared;
151 m_tdc =
static_cast<unsigned int>(tdcTotSmeared);
162 return StatusCode::SUCCESS;
180 if (
m_tubeID != (*hitIt)->GetTubeID())
continue;
182 if (!(*hitIt)->isDetected(rndEngine))
continue;
184 if ((*hitIt)->GetGenVolume() == 1)
m_npeGas++;
185 if ((*hitIt)->GetGenVolume() == 2)
m_npeGas++;
186 if ((*hitIt)->GetGenVolume() == 3)
m_npePmt++;
188 m_tdcTot += (*hitIt)->GetPreStepTime();
194 return StatusCode::SUCCESS;
211 for (; hitIt != hitItE; ++hitIt) {
213 if (
m_tubeID != (*hitIt).GetTubeID())
continue;
215 if (!(*hitIt).isDetected(rndEngine))
continue;
217 if ((*hitIt).GetGenVolume() == 1)
m_npeGas++;
218 if ((*hitIt).GetGenVolume() == 2)
m_npeGas++;
219 if ((*hitIt).GetGenVolume() == 3)
m_npePmt++;
221 m_tdcTot += (*hitIt).GetPreStepTime();
227 return StatusCode::SUCCESS;
244 double smearedQDC = 0;
262 if (npe < 20)
return CLHEP::RandPoissonQ::shoot(rndEngine, npe);
263 else return CLHEP::RandGaussQ::shoot (rndEngine, npe, std::sqrt(npe));