5 #include "CLHEP/Random/RandGaussZiggurat.h"
6 #include "CLHEP/Random/RandFlat.h"
8 constexpr
double percentage(
unsigned int numerator,
unsigned int denom) {
23 return StatusCode::SUCCESS;
26 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[0]<<
"/"<<m_allHits[1]<<
" hits. In, "
27 <<percentage(m_acceptedHits[0], m_allHits[0]) <<
"/"
28 <<percentage(m_acceptedHits[1], m_allHits[1]) <<
"% of the cases, the conversion was successful");
29 return StatusCode::SUCCESS;
42 for (
const TimedHit& simHit : hitsToDigit) {
45 if (std::abs(simHit->pdgId()) != 13)
continue;
48 const Amg::Vector3D locPos{xAOD::toEigen(simHit->localPosition())};
54 efficiencyMap, *digiColl, rndEngine);
57 efficiencyMap, *digiColl, rndEngine);
59 addSDO(simHit, sdoContainer);
62 hitTime(simHit), locPos.block<2,1>(0,0),
63 efficiencyMap, *digiColl, rndEngine)) {
64 addSDO(simHit, sdoContainer);
69 return StatusCode::SUCCESS;
72 const bool measuresPhi,
75 const double locPosOnStrip,
78 CLHEP::HepRandomEngine* rndEngine)
const {
84 ++(m_allHits[measuresPhi]);
87 const double uncert = design.stripPitch() / std::sqrt(12.);
88 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPosOnStrip, uncert);
89 const Amg::Vector2D locHitPos{smearedX * Amg::Vector2D::UnitX()};
91 if (!design.insideTrapezoid(locHitPos)) {
93 <<
m_idHelperSvc->toStringGasGap(gasGapId)<<
", measuresPhi: "<<(measuresPhi ?
"yay" :
"nay"));
96 const int strip = design.stripNumber(locHitPos);
99 <<
m_idHelperSvc->toStringGasGap(gasGapId) <<std::endl<<design<<
100 std::endl<<
", measuresPhi: "<<(measuresPhi ?
"yay" :
"nay"));
107 const Identifier digitId{id_helper.channelID(gasGapId,
108 id_helper.doubletZ(gasGapId),
109 id_helper.doubletPhi(gasGapId),
110 id_helper.gasGap(gasGapId),
115 <<
", eta strip "<<strip<<
" & hit "<<
Amg::toString(locHitPos,2 )
120 if (effiMap && effiMap->
getEfficiency(digitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)) {
125 ++(m_acceptedHits[measuresPhi]);
134 CLHEP::HepRandomEngine* rndEngine)
const {
136 ++(m_allHits[
false]);
142 const double uncert = design.stripPitch() / std::sqrt(12.);
143 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos.x(), uncert);
146 const double stripLength = design.stripLength(1);
149 const double stripLeft = -(stripLength / 2);
150 const double stripRight = (stripLength / 2);
151 const double distToL = std::abs(stripLeft - locPos.y());
152 const double distToR = std::abs(stripRight - locPos.y());
159 const double smearedTimeL = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeL,
m_stripTimeResolution);
160 const double smearedTimeR = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeR,
m_stripTimeResolution);
162 const double smearedDeltaT = smearedTimeR - smearedTimeL;
179 if (!design.insideTrapezoid(locHitPos)) {
185 const int strip = design.stripNumber(locHitPos);
188 <<
m_idHelperSvc->toStringGasGap(gasGapId) <<std::endl<<design);
194 const Identifier digitId{id_helper.channelID(gasGapId,
195 id_helper.doubletZ(gasGapId),
196 id_helper.doubletPhi(gasGapId),
197 id_helper.gasGap(gasGapId),
201 <<
", strip: "<<strip);
206 const bool effiSignal1 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0.,1.);
207 const bool effiSignal2 = !effiMap || effiMap->
getEfficiency(gasGapId) >= CLHEP::RandFlat::shoot(rndEngine,0., 1.);
214 if (effiSignal1 || effiSignal2) {
215 ++(m_acceptedHits[
false]);
223 constexpr
double tot_mean_narrow = 16.;
224 constexpr
double tot_sigma_narrow = 2.;
225 constexpr
double tot_mean_wide = 15.;
226 constexpr
double tot_sigma_wide = 4.5;
230 if (CLHEP::RandFlat::shoot(rndmEngine)<0.75) {
231 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_narrow, tot_sigma_narrow);
233 thetot = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tot_mean_wide, tot_sigma_wide);