9 #include "CLHEP/Random/RandGaussZiggurat.h"
10 #include "CLHEP/Random/RandFlat.h"
12 constexpr
double percentage(
unsigned int numerator,
unsigned int denom) {
24 return StatusCode::SUCCESS;
27 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[0]<<
"/"<<m_allHits[1]<<
" hits. In, "
28 <<percentage(m_acceptedHits[0], m_allHits[0]) <<
"/"
29 <<percentage(m_acceptedHits[1], m_allHits[1]) <<
"% of the cases, the conversion was successful");
30 return StatusCode::SUCCESS;
46 for (
const TimedHit& simHit : viewer) {
57 const bool digitizedEta =
digitizeHit(simHit,
false, efficiencyMap, *digiColl, rndEngine, deadTimes);
59 const bool digitizedPhi =
digitizeHit(simHit,
true, efficiencyMap, *digiColl, rndEngine, deadTimes);
61 if (digitizedEta || digitizedPhi) {
65 }
else if (
digitizeHitBI(simHit, efficiencyMap, *digiColl, rndEngine, deadTimes)) {
70 }
while (viewer.next());
73 return StatusCode::SUCCESS;
76 const bool measuresPhi,
79 CLHEP::HepRandomEngine* rndEngine,
82 ++(m_allHits[measuresPhi]);
90 const Identifier layerId = idHelper.channelID(gasGapId,
91 idHelper.doubletZ(gasGapId),
92 idHelper.doubletPhi(gasGapId),
93 idHelper.gasGap(gasGapId),
101 const double uncert = design.stripPitch() / std::sqrt(12.);
102 Amg::Vector3D locHitPos{xAOD::toEigen(hit->localPosition())};
103 locHitPos[measuresPhi] = CLHEP::RandGaussZiggurat::shoot(rndEngine, locHitPos[measuresPhi], uncert);
105 const Amg::Vector2D locPos2D = layerDesign->to2D(locHitPos, measuresPhi);
106 if (!design.insideTrapezoid(locPos2D)) {
108 <<
" is outside of the trapezoid bounds for "<<
m_idHelperSvc->toString(layerId));
111 const int strip = design.stripNumber(locPos2D);
114 <<
" cannot trigger any signal in a strip for " <<
m_idHelperSvc->toString(layerId)
115 <<std::endl<<design);
119 const Identifier digitId{idHelper.channelID(gasGapId,
120 idHelper.doubletZ(gasGapId),
121 idHelper.doubletPhi(gasGapId),
122 idHelper.gasGap(gasGapId),
127 <<
", eta strip "<<strip<<
" & hit "<<
Amg::toString(locHitPos,2 )
132 if (effiMap && effiMap->
getEfficiency(digitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)) {
143 const double digitTime = CLHEP::RandGaussZiggurat::shoot(rndEngine, signalTime,
m_stripTimeResolution);
145 <<
", recorded time: "<<digitTime);
147 ++(m_acceptedHits[measuresPhi]);
153 CLHEP::HepRandomEngine* rndEngine,
156 ++(m_allHits[
false]);
157 const Identifier gasGapId = simHit->identify();
159 const Amg::Vector3D locPos = xAOD::toEigen(simHit->localPosition());
165 const double uncert = design.stripPitch() / std::sqrt(12.);
166 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos.x(), uncert);
175 const double smearedTimeL = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeL,
m_stripTimeResolution);
176 const double smearedTimeR = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeR,
m_stripTimeResolution);
178 const double smearedDeltaT = smearedTimeR - smearedTimeL;
195 if (!design.insideTrapezoid(locHitPos)) {
201 const int strip = design.stripNumber(locHitPos);
204 <<
m_idHelperSvc->toStringGasGap(gasGapId) <<std::endl<<design);
210 const Identifier digitId{idHelper.channelID(gasGapId,
211 idHelper.doubletZ(gasGapId),
212 idHelper.doubletPhi(gasGapId),
213 idHelper.gasGap(gasGapId),
217 <<
", strip: "<<strip);
227 const bool effiSignal1 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0., 1.);
228 const bool effiSignal2 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0., 1.);
235 if (effiSignal1 || effiSignal2) {
236 ++(m_acceptedHits[
false]);
244 constexpr
double tot_mean_narrow = 16.;
245 constexpr
double tot_sigma_narrow = 2.;
246 constexpr
double tot_mean_wide = 15.;
247 constexpr
double tot_sigma_wide = 4.5;
251 if (CLHEP::RandFlat::shoot(rndmEngine)<0.75) {
252 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_narrow, tot_sigma_narrow);
254 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_wide, tot_sigma_wide);