6 #include "CLHEP/Random/RandGaussZiggurat.h" 
    7 #include "CLHEP/Random/RandFlat.h" 
   10     constexpr 
double percentage(
unsigned int numerator, 
unsigned int denom) {
 
   25         return StatusCode::SUCCESS;
 
   28         ATH_MSG_INFO(
"Tried to convert "<<m_allHits[channelType::Strip]<<
"/" 
   29                                         <<m_allHits[channelType::Wire]<<
"/" 
   30                                         <<m_allHits[channelType::Pad]<<
" strip/wire/pad hits. In, " 
   31                     <<percentage(m_acceptedHits[channelType::Strip], m_allHits[channelType::Strip]) <<
"/" 
   32                     <<percentage(m_acceptedHits[channelType::Wire], m_allHits[channelType::Wire])<<
"/" 
   33                     <<percentage(m_acceptedHits[channelType::Pad], m_allHits[channelType::Pad])
 
   34                     <<
"% of the cases, the conversion was successful");
 
   35         return StatusCode::SUCCESS;
 
   52             for (
const TimedHit& simHit : viewer) {
 
   59                 ATH_MSG_VERBOSE(
"Hit with Energy Deposit of " << simHit->energyDeposit()
 
   64                 const double hitKineticEnergy = simHit->kineticEnergy();
 
   66                   ATH_MSG_DEBUG(
"Skip electron hit with kinetic energy " << hitKineticEnergy
 
   71                 const bool digitizedStrip = 
digitizeStrip(ctx, simHit, nswUncertDB, efficiencyMap, rndEngine, *digiColl);
 
   72                 const bool digitizedWire = 
digitizeWire(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
 
   73                 const bool digitizedPad = 
digitizePad(ctx, simHit, efficiencyMap, rndEngine, *digiColl);
 
   77                     size_t stripIdx = digiColl->
size() - 1 - digitizedWire - digitizedPad;
 
   79                 } 
else if (digitizedWire || digitizedPad) {
 
   85                                                     re->localToGlobalTrans(
getGeoCtx(ctx), 
re->layerHash(simHit->identify()))};
 
   91         } 
while (viewer.next());
 
   94                                       idHelper.module_hash_max()));
 
   95         return StatusCode::SUCCESS;
 
  101                                          CLHEP::HepRandomEngine* rndEngine,
 
  107         ++m_allHits[channelType::Strip];
 
  113         const int gasGap = idHelper.gasGap(hitId);
 
  116         const Amg::Vector2D stripPos{xAOD::toEigen(timedHit->localPosition()).block<2,1>(0,0)};
 
  121                           <<
" is out of range "<<std::endl<<design);
 
  127         const Identifier stripId = idHelper.channelID(hitId, readOutEle->multilayer(),
 
  132                             <<
m_idHelperSvc->toStringGasGap(hitId)<<
" strip: "<<stripNum);
 
  137         bool isInnerQ1 = readOutEle->isEtaZero(readOutEle->measurementHash(hitId), stripPos);
 
  138         if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
 
  139             ATH_MSG_VERBOSE(
"Simulated strip hit "<<xAOD::toEigen(timedHit->localPosition())
 
  140                             << 
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
 
  145         errorCalibInput.
stripId= stripId;
 
  146         errorCalibInput.locTheta = 
M_PI - timedHit->localDirection().theta();
 
  147         errorCalibInput.clusterAuthor = 3; 
 
  150         const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, stripPos.x(), uncert);
 
  152         const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
 
  154         const int digitStrip = design.stripNumber(digitPos);
 
  155         if (digitStrip < 0) {
 
  157                           <<
" is out of range "<<std::endl<<design);
 
  160         const Identifier digitId = idHelper.channelID(hitId, readOutEle->multilayer(),
 
  165                             <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitStrip);
 
  168         constexpr 
double dummyCharge = 66666;
 
  189         const double pull = (smearedX - (*design.center(digitStrip)).
x()) / design.stripPitch();
 
  190         const double w1 = CLHEP::RandFlat::shoot(rndEngine, 0., 0.5 *(1. - 
pull)); 
 
  191         const double w2 = 1. - 
pull -2.*w1;
 
  192         const double w3 = 
pull + w1;
 
  195             const Identifier stripIdB = idHelper.channelID(hitId, readOutEle->multilayer(),
 
  196                                                        gasGap, channelType::Strip, digitStrip -1);
 
  197             outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdB,
 
  199                                                                 hitTime(timedHit), dummyCharge * w1, 
false, 
false));
 
  201         outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
 
  203                                                             hitTime(timedHit), dummyCharge * w2, 
false, 
false));
 
  205         if (digitStrip + 1 <= design.numStrips()) {
 
  206             const Identifier stripIdA = idHelper.channelID(hitId, readOutEle->multilayer(),
 
  207                                                            gasGap, channelType::Strip, digitStrip + 1);
 
  209             outCollection.
push_back(std::make_unique<sTgcDigit>(stripIdA,
 
  211                                                                 hitTime(timedHit), dummyCharge * w3, 
false, 
false));
 
  213         ++m_acceptedHits[channelType::Strip];
 
  220                                         CLHEP::HepRandomEngine* rndEngine,
 
  227         ++m_allHits[channelType::Wire];
 
  231         if (efficiencyMap && efficiencyMap->
getEfficiency(hitId) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
 
  232             ATH_MSG_VERBOSE(
"Simulated wire hit "<<xAOD::toEigen(timedHit->localPosition())
 
  233                             << 
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
 
  238         const int gasGap = idHelper.gasGap(hitId);
 
  250         const Amg::Vector2D wirePos{(toWire*xAOD::toEigen(timedHit->localPosition())).block<2,1>(0,0)};
 
  253         if(isInnerQ1) 
return false;
 
  256         if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
 
  257             ATH_MSG_VERBOSE(
"Simulated wire hit "<<xAOD::toEigen(timedHit->localPosition())
 
  258                             << 
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
 
  264         const int wireGrpNum = design.
stripNumber(wirePos);
 
  265         if (wireGrpNum < 0) {
 
  267                         <<
" is outside of the acceptance of "<<std::endl<<design);
 
  270         const double uncert = design.stripPitch() * design.numWiresInGroup(wireGrpNum);
 
  272         const double smearedX = CLHEP::RandGaussZiggurat::shoot(rndEngine, wirePos.x(), uncert);
 
  274         const Amg::Vector2D digitPos{smearedX * Amg::Vector2D::UnitX()};
 
  276         const int digitWire = design.stripNumber(digitPos);
 
  279             <<
" is out of range "<<std::endl<<design);
 
  288                             <<
m_idHelperSvc->toStringGasGap(hitId)<<
" digit: "<<digitWire);
 
  291         outCollection.
push_back(std::make_unique<sTgcDigit>(digitId,
 
  293                                                             hitTime(timedHit), 666, 
false, 
false));
 
  296         ++m_acceptedHits[channelType::Wire];
 
  308                                        CLHEP::HepRandomEngine* rndEngine,
 
  315         ++m_allHits[channelType::Pad];
 
  320         const int gasGap = idHelper.gasGap(hitId);
 
  332         const Amg::Vector2D padPos{(toPad*xAOD::toEigen(timedHit->localPosition())).block<2,1>(0,0)};
 
  337         if (padEta < 0 || padPhi < 0) {
 
  339                         <<
" is outside of the acceptance of "<<std::endl<<design);
 
  355         if (efficiencyMap && efficiencyMap->
getEfficiency(hitId, isInnerQ1) < CLHEP::RandFlat::shoot(rndEngine,0.,1.)){
 
  356             ATH_MSG_VERBOSE(
"Simulated pad hit "<<xAOD::toEigen(timedHit->localPosition())
 
  357                             << 
m_idHelperSvc->toString(hitId) <<
" is rejected because of efficency modelling");
 
  363         outCollection.
push_back(std::make_unique<sTgcDigit>(padId,
 
  365                                                             hitTime(timedHit), 666, 
false, 
false));
 
  367         ++m_acceptedHits[channelType::Pad];