16 #include <CLHEP/Random/RandGaussZiggurat.h>
17 #include <CLHEP/Random/RandFlat.h>
18 #include <GaudiKernel/PhysicalConstants.h>
24 constexpr
double percentage(
unsigned int numerator,
unsigned int denom) {
28 using CheckVector2D = MuonGMR4::CheckVector2D;
33 ISvcLocator* pSvcLocator):
45 return StatusCode::SUCCESS;
49 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[0]<<
" | "<<m_allHits[1]<<
" hits. In, "
50 <<percentage(m_acceptedHits[0], m_allHits[0]) <<
" | "
51 <<percentage(m_acceptedHits[1], m_allHits[1]) <<
" cases, the conversion was successful");
52 return StatusCode::SUCCESS;
56 const double locPosOnStrip,
59 const bool measuresPhi,
61 CLHEP::HepRandomEngine* rndEngine)
const {
69 const double uncert = design.stripPitch() / std::sqrt(12.);
70 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPosOnStrip, uncert);
71 const Amg::Vector2D locHitPos{smearedX * Amg::Vector2D::UnitX()};
72 ++(m_allHits[measuresPhi]);
73 if (!design.insideTrapezoid(locHitPos)) {
75 <<
m_idHelperSvc->toStringGasGap(gasGapId)<<
", measuresPhi: "<<(measuresPhi ?
"yay" :
"nay"));
81 <<
m_idHelperSvc->toStringGasGap(gasGapId) <<
", measuresPhi: "<<(measuresPhi ?
"yay" :
"nay"));
88 const Identifier prdId{id_helper.channelID(gasGapId,
89 id_helper.doubletZ(gasGapId),
90 id_helper.doubletPhi(gasGapId),
91 id_helper.gasGap(gasGapId),
100 ++(m_acceptedHits[measuresPhi]);
109 std::move(lPos), std::move(
cov));
125 CLHEP::HepRandomEngine* rndEngine)
const{
132 ++(m_allHits[
false]);
135 const double uncertX = design.stripPitch() / std::sqrt(12.);
136 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPosOnStrip.x(), uncertX);
140 const double stripTimeResolution = 0.6;
141 const double stripLength = design.lenLeftEdge();
144 const double stripLeft = -(stripLength / 2);
145 const double stripRight = (stripLength / 2);
146 double distToL = std::abs( stripLeft - locPosOnStrip.y() );
147 double distToR = std::abs( stripRight - locPosOnStrip.y() );
150 double propagationTimeL = distToL / propagationVelocity;
151 double propagationTimeR = distToR / propagationVelocity;
154 const double smearedTimeL = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeL, stripTimeResolution);
155 const double smearedTimeR = CLHEP::RandGaussZiggurat::shoot(rndEngine, propagationTimeR, stripTimeResolution);
156 const double smearedDeltaT = smearedTimeR - smearedTimeL;
169 const double uncertY = 0.5 * propagationVelocity * sqrt(2)*stripTimeResolution;
170 const double smearedY = -0.5 * propagationVelocity * smearedDeltaT;
174 if (!design.insideTrapezoid(locHitPos)) {
189 const Identifier prdId{id_helper.channelID(gasGapId,
190 id_helper.doubletZ(gasGapId),
191 id_helper.doubletPhi(gasGapId),
192 id_helper.gasGap(gasGapId),
201 ++(m_acceptedHits[
false]);
209 cov(0,0) = uncertX * uncertX;
210 cov(1,1) = uncertY * uncertY;
233 if ( (*firstStrip).x() - 0.5 *design.
stripPitch() < locHitPos.x()) {
235 }
else if ( (*lastStrip).x() + 0.5 * design.
stripPitch() > locHitPos.x()) {
243 if (!simHitContainer.isPresent()){
245 return StatusCode::FAILURE;
253 ATH_CHECK(prdContainer.record(std::make_unique<xAOD::RpcStripContainer>(),
254 std::make_unique<xAOD::RpcStripAuxContainer>()));
259 ATH_CHECK(prd2DContainer.record(std::make_unique<xAOD::RpcStrip2DContainer>(),
260 std::make_unique<xAOD::RpcStrip2DAuxContainer>()));
269 if (std::abs(simHit->pdgId()) != 13)
continue;
271 const Amg::Vector3D locSimHitPos{xAOD::toEigen(simHit->localPosition())};
279 *prd2DContainer, rndEngine);
283 return StatusCode::SUCCESS;
289 rngWrapper->
setSeed(rngName, ctx);