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[channelType::Strip]<<
"/"
27 <<m_allHits[channelType::Wire]<<
"/"
28 <<m_allHits[channelType::Pad]<<
" strip/wire/pad hits. In, "
29 <<percentage(m_acceptedHits[channelType::Strip], m_allHits[channelType::Strip]) <<
"/"
30 <<percentage(m_acceptedHits[channelType::Wire], m_allHits[channelType::Wire])<<
"/"
31 <<percentage(m_acceptedHits[channelType::Pad], m_allHits[channelType::Pad])
32 <<
"% of the cases, the conversion was successful");
33 return StatusCode::SUCCESS;
48 for (
const TimedHit& simHit : hitsToDigit) {
50 if (std::abs(simHit->pdgId()) != 13)
continue;
53 bool digitized{
false};
54 digitized |=
digitizeStrip(ctx, simHit, nswUncertDB, efficiencyMap, rndEngine, *digiColl);
55 digitized |=
digitizeWire(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
56 digitized |=
digitizePad(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
59 addSDO(simHit, sdoContainer);
64 idHelper.module_hash_max()));
65 return StatusCode::SUCCESS;
71 CLHEP::HepRandomEngine* rndEngine,
77 ++m_allHits[channelType::Strip];
83 const int gasGap = idHelper.gasGap(hitId);
86 const Amg::Vector2D stripPos{xAOD::toEigen(timedHit->localPosition()).block<2,1>(0,0)};
91 <<
" is out of range "<<std::endl<<design);
96 const Identifier stripId = idHelper.channelID(hitId, readOutEle->multilayer(),
101 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" strip: "<<stripNum);
106 bool isInnerQ1 = readOutEle->isEtaZero(readOutEle->measurementHash(hitId), stripPos);
107 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
108 ATH_MSG_VERBOSE(
"Simulated strip hit "<<xAOD::toEigen(timedHit->localPosition())
109 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
114 errorCalibInput.
stripId= stripId;
115 errorCalibInput.locTheta =
M_PI - timedHit->localDirection().theta();
116 errorCalibInput.clusterAuthor = 3;
119 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, stripPos.x(), uncert);
121 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
123 const int digitStrip = design.stripNumber(digitPos);
124 if (digitStrip < 0) {
126 <<
" is out of range "<<std::endl<<design);
129 const Identifier digitId = idHelper.channelID(hitId, readOutEle->multilayer(),
134 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitStrip);
137 constexpr
double dummyCharge = 66666;
158 const double pull = (smearedX - (*design.center(digitStrip)).
x()) / design.stripPitch();
159 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. -
pull));
160 const double w2 = 1. -
pull -2.*w1;
161 const double w3 =
pull + w1;
162 const Identifier stripIdB = idHelper.channelID(hitId, readOutEle->multilayer(),
165 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdB,
167 hitTime(timedHit), dummyCharge * w1,
false,
false));
169 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
171 hitTime(timedHit), dummyCharge * w2,
false,
false));
173 const Identifier stripIdA = idHelper.channelID(hitId, readOutEle->multilayer(),
176 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdA,
178 hitTime(timedHit), dummyCharge * w3,
false,
false));
180 ++m_acceptedHits[channelType::Strip];
187 CLHEP::HepRandomEngine* rndEngine,
194 ++m_allHits[channelType::Wire];
198 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
199 ATH_MSG_VERBOSE(
"Simulated wire hit "<<xAOD::toEigen(timedHit->localPosition())
200 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
205 const int gasGap = idHelper.gasGap(hitId);
217 const Amg::Vector2D wirePos{(toWire*xAOD::toEigen(timedHit->localPosition())).block<2,1>(0,0)};
220 if(isInnerQ1)
return false;
223 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
224 ATH_MSG_VERBOSE(
"Simulated wire hit "<<xAOD::toEigen(timedHit->localPosition())
225 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
231 const int wireGrpNum = design.
stripNumber(wirePos);
232 if (wireGrpNum < 0) {
234 <<
" is outside of the acceptance of "<<std::endl<<design);
237 const double uncert = design.stripPitch() * design.numWiresInGroup(wireGrpNum);
239 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, wirePos.x(), uncert);
241 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
243 const int digitWire = design.stripNumber(digitPos);
246 <<
" is out of range "<<std::endl<<design);
255 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitWire);
258 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
260 hitTime(timedHit), 666,
false,
false));
263 ++m_acceptedHits[channelType::Wire];
275 CLHEP::HepRandomEngine* rndEngine,
282 ++m_allHits[channelType::Pad];
287 const int gasGap = idHelper.gasGap(hitId);
299 const Amg::Vector2D padPos{(toPad*xAOD::toEigen(timedHit->localPosition())).block<2,1>(0,0)};
304 if (padEta < 0 || padPhi < 0) {
306 <<
" is outside of the acceptance of "<<std::endl<<design);
322 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
323 ATH_MSG_VERBOSE(
"Simulated pad hit "<<xAOD::toEigen(timedHit->localPosition())
324 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
330 outCollection.
push_back(std::make_unique<sTgcDigit>(padId,
332 hitTime(timedHit), 666,
false,
false));
334 ++m_acceptedHits[channelType::Pad];