5 #include "CLHEP/Random/RandGaussZiggurat.h"
6 #include "CLHEP/Random/RandFlat.h"
9 constexpr
double percentage(
unsigned int numerator,
unsigned int denom) {
24 return StatusCode::SUCCESS;
27 ATH_MSG_INFO(
"Tried to convert "<<m_allHits[channelType::Strip]<<
"/"
28 <<m_allHits[channelType::Wire]<<
"/"
29 <<m_allHits[channelType::Pad]<<
" strip/wire/pad hits. In, "
30 <<percentage(m_acceptedHits[channelType::Strip], m_allHits[channelType::Strip]) <<
"/"
31 <<percentage(m_acceptedHits[channelType::Wire], m_allHits[channelType::Wire])<<
"/"
32 <<percentage(m_acceptedHits[channelType::Pad], m_allHits[channelType::Pad])
33 <<
"% of the cases, the conversion was successful");
34 return StatusCode::SUCCESS;
51 for (
const TimedHit& simHit : viewer) {
57 const bool digitizedStrip =
digitizeStrip(ctx, simHit, nswUncertDB, efficiencyMap, rndEngine, *digiColl);
58 const bool digitizedWire =
digitizeWire(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
59 const bool digitizedPad =
digitizePad(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
63 size_t stripIdx = digiColl->
size() - 1 - digitizedWire - digitizedPad;
65 }
else if (digitizedWire || digitizedPad) {
71 re->localToGlobalTrans(
getGeoCtx(ctx),
re->layerHash(simHit->identify()))};
77 }
while (viewer.next());
80 idHelper.module_hash_max()));
81 return StatusCode::SUCCESS;
87 CLHEP::HepRandomEngine* rndEngine,
93 ++m_allHits[channelType::Strip];
99 const int gasGap = idHelper.gasGap(hitId);
102 const Amg::Vector2D stripPos{xAOD::toEigen(timedHit->localPosition()).block<2,1>(0,0)};
107 <<
" is out of range "<<std::endl<<design);
112 const Identifier stripId = idHelper.channelID(hitId, readOutEle->multilayer(),
117 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" strip: "<<stripNum);
122 bool isInnerQ1 = readOutEle->isEtaZero(readOutEle->measurementHash(hitId), stripPos);
123 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
124 ATH_MSG_VERBOSE(
"Simulated strip hit "<<xAOD::toEigen(timedHit->localPosition())
125 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
130 errorCalibInput.
stripId= stripId;
131 errorCalibInput.locTheta =
M_PI - timedHit->localDirection().theta();
132 errorCalibInput.clusterAuthor = 3;
135 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, stripPos.x(), uncert);
137 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
139 const int digitStrip = design.stripNumber(digitPos);
140 if (digitStrip < 0) {
142 <<
" is out of range "<<std::endl<<design);
145 const Identifier digitId = idHelper.channelID(hitId, readOutEle->multilayer(),
150 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitStrip);
153 constexpr
double dummyCharge = 66666;
174 const double pull = (smearedX - (*design.center(digitStrip)).
x()) / design.stripPitch();
175 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. -
pull));
176 const double w2 = 1. -
pull -2.*w1;
177 const double w3 =
pull + w1;
178 const Identifier stripIdB = idHelper.channelID(hitId, readOutEle->multilayer(),
181 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdB,
183 hitTime(timedHit), dummyCharge * w1,
false,
false));
185 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
187 hitTime(timedHit), dummyCharge * w2,
false,
false));
189 const Identifier stripIdA = idHelper.channelID(hitId, readOutEle->multilayer(),
192 outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdA,
194 hitTime(timedHit), dummyCharge * w3,
false,
false));
196 ++m_acceptedHits[channelType::Strip];
203 CLHEP::HepRandomEngine* rndEngine,
210 ++m_allHits[channelType::Wire];
214 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
215 ATH_MSG_VERBOSE(
"Simulated wire hit "<<xAOD::toEigen(timedHit->localPosition())
216 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
221 const int gasGap = idHelper.gasGap(hitId);
233 const Amg::Vector2D wirePos{(toWire*xAOD::toEigen(timedHit->localPosition())).block<2,1>(0,0)};
236 if(isInnerQ1)
return false;
239 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
240 ATH_MSG_VERBOSE(
"Simulated wire hit "<<xAOD::toEigen(timedHit->localPosition())
241 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
247 const int wireGrpNum = design.
stripNumber(wirePos);
248 if (wireGrpNum < 0) {
250 <<
" is outside of the acceptance of "<<std::endl<<design);
253 const double uncert = design.stripPitch() * design.numWiresInGroup(wireGrpNum);
255 const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, wirePos.x(), uncert);
257 const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
259 const int digitWire = design.stripNumber(digitPos);
262 <<
" is out of range "<<std::endl<<design);
271 <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitWire);
274 outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
276 hitTime(timedHit), 666,
false,
false));
279 ++m_acceptedHits[channelType::Wire];
291 CLHEP::HepRandomEngine* rndEngine,
298 ++m_allHits[channelType::Pad];
303 const int gasGap = idHelper.gasGap(hitId);
315 const Amg::Vector2D padPos{(toPad*xAOD::toEigen(timedHit->localPosition())).block<2,1>(0,0)};
320 if (padEta < 0 || padPhi < 0) {
322 <<
" is outside of the acceptance of "<<std::endl<<design);
338 if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
339 ATH_MSG_VERBOSE(
"Simulated pad hit "<<xAOD::toEigen(timedHit->localPosition())
340 <<
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
346 outCollection.
push_back(std::make_unique<sTgcDigit>(padId,
348 hitTime(timedHit), 666,
false,
false));
350 ++m_acceptedHits[channelType::Pad];