5 #include "CLHEP/Random/RandGaussZiggurat.h"
6 #include "CLHEP/Random/RandFlat.h"
9 constexpr
double percentage(
unsigned int numerator,
unsigned int denom) {
23 return StatusCode::SUCCESS;
26 std::stringstream statstr{};
28 for (
unsigned int g = 0;
g < m_allHits.size(); ++
g) {
29 allHits += m_allHits[
g];
30 statstr<<
" *** Layer "<<(
g+1)<<
" "<<percentage(m_acceptedHits[
g],m_allHits[
g])
31 <<
"% of "<<m_allHits[
g]<<std::endl;
33 if(!allHits)
return StatusCode::SUCCESS;
34 ATH_MSG_INFO(
"Tried to convert "<<allHits<<
" hits. Successes rate per layer "<<std::endl<<statstr.str());
35 return StatusCode::SUCCESS;
50 for (
const TimedHit& simHit : hitsToDigit) {
53 if (std::abs(simHit->pdgId()) != 13)
continue;
56 const Amg::Vector2D locPos{xAOD::toEigen(simHit->localPosition()).block<2,1>(0,0)};
59 const unsigned int hitGapInNsw = (idHelper.multilayer(hitId) -1) * 4 + idHelper.gasGap(hitId) -1;
60 ++m_allHits[hitGapInNsw];
65 int channelNumber = design.stripNumber(locPos);
67 if (!design.insideTrapezoid(locPos)) {
69 <<
" is outside bounds "<<std::endl<<design<<
" rejecting it");
73 const Identifier clusId = idHelper.channelID(hitId,
74 idHelper.multilayer(hitId),
75 idHelper.gasGap(hitId),
80 <<
" channel " << channelNumber <<
" locPos " <<
Amg::toString(locPos));
84 if(efficiencyMap && efficiencyMap->getEfficiency(clusId) < CLHEP::RandFlat::shoot(rndEngine, 0., 1.)){
89 errorCalibInput.
stripId = clusId;
90 errorCalibInput.locTheta =
M_PI- simHit->localDirection().theta();
91 errorCalibInput.clusterAuthor=66;
92 const double uncert = errorCalibDB->clusterUncertainty(errorCalibInput);
98 constexpr
int dummyResponseTime = 100;
99 constexpr
float dummyDepositedCharge = 66666;
101 const double newLocalX = CLHEP::RandGaussZiggurat::shoot(rndEngine, locPos.x(), uncert);
102 const int newChannel = design.stripNumber(newLocalX * Amg::Vector2D::UnitX());
103 if (newChannel < 0) {
107 const Identifier digitId = idHelper.channelID(hitId,
108 idHelper.multilayer(hitId),
109 idHelper.gasGap(hitId),
114 <<
" channel " << newChannel <<
" locPos " <<
Amg::toString(locPos));
139 const double pull = (newLocalX - (*design.center(newChannel)).
x()) / (design.stripPitch() *
std::cos(design.stereoAngle()));
140 const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. -
pull));
141 const double w2 = 1 -
pull -2*w1;
142 const double w3 =
pull + w1;
145 const Identifier digitIdB = idHelper.channelID(hitId,
146 idHelper.multilayer(hitId),
147 idHelper.gasGap(hitId),
151 outColl->
push_back(std::make_unique<MmDigit>(digitIdB, dummyResponseTime, w1 * dummyDepositedCharge));
153 outColl->
push_back(std::make_unique<MmDigit>(digitId,dummyResponseTime, w2 * dummyDepositedCharge));
155 const Identifier digitIdA = idHelper.channelID(hitId,
156 idHelper.multilayer(hitId),
157 idHelper.gasGap(hitId),
160 outColl->
push_back(std::make_unique<MmDigit>(digitIdA, dummyResponseTime, w3 * dummyDepositedCharge));
163 addSDO(simHit, sdoContainer);
164 ++m_acceptedHits[hitGapInNsw];
168 return StatusCode::SUCCESS;