10 #include "CLHEP/Random/RandGaussZiggurat.h"
26 return StatusCode::SUCCESS;
36 using DigitSDOPair = std::pair<std::unique_ptr<MdtDigit>,
TimedHit>;
52 std::vector<DigitSDOPair> digitsInChamber{};
57 if (!badTubes->isGood(hitId)) {
63 <<
", time: "<<simHit->globalTime()<<
", energy: "<<simHit->kineticEnergy() /
Gaudi::Units::GeV
64 <<
" [GeV], mass: "<<simHit->mass()<<
", deposited energy: "<<simHit->energyDeposit() /
Gaudi::Units::eV
65 <<
" [eV], genLink: "<<simHit->genParticleLink());
73 const Amg::Vector3D locPos{xAOD::toEigen(simHit->localPosition())};
76 const MdtDigiToolInput digiInput(std::abs(locPos.perp()), distRO, 0., 0., 0., 0., hitId);
82 const double arrivalTime{simHit->globalTime()};
85 assert(tubeConstants !=
nullptr);
87 assert(tubeConstants->
tubeCalib->getCalib(hitId) !=
nullptr);
91 const double sigPropTime = calibData->inversePropSpeed()*distRO;
95 const double totalTdcTime = digiOutput.
driftTime() + arrivalTime + tubeCalib.t0 + sigPropTime;
96 if (lastTube != hitId ||
deadTime < totalTdcTime) {
107 const uint16_t tdcCounts = timeToTdcCnv*(hasHPTdc ? 4 : 1)*CLHEP::RandGaussZiggurat::shoot(rndEngine, totalTdcTime,
m_timeResTDC);
108 const uint16_t adcCounts = (hasHPTdc ? 4 : 1) *CLHEP::RandGaussZiggurat::shoot(rndEngine, digiOutput.
adc(),
m_timeResADC);
110 auto digit = std::make_unique<MdtDigit>(hitId, tdcCounts, adcCounts,
false);
112 digitsInChamber.push_back(std::make_pair(std::move(
digit), simHit));
114 if (!twinTubes || !twinTubes->isTwinTubeLayer(hitId)) {
117 const Identifier twinId{twinTubes->twinId(hitId)};
118 if (twinId == hitId) {
123 if (!readOutEle->
isValid(twinHash)) {
132 <<
", tube length: "<<readOutEle->
activeTubeLength(measHash)<<
", distRO: "<<distRO
134 <<
", twin distance: "<<twinDist);
137 const double twinPropTime = calibData->inversePropSpeed()*twinDist;
140 const double twinTdcTime = digiOutput.
driftTime() + arrivalTime + twinPropTime
141 + twinCalib.t0 + twinTubes->hvDelayTime(twinId);
143 const uint16_t twinTdcCounts = timeToTdcCnv*(hasHPTdc ? 4 : 1)*CLHEP::RandGaussZiggurat::shoot(rndEngine, twinTdcTime,
m_resTwin);
144 const uint16_t twinAdcCoutns = (hasHPTdc ? 4 : 1) *CLHEP::RandGaussZiggurat::shoot(rndEngine, digiOutput.
adc(),
m_timeResADC);
145 digit = std::make_unique<MdtDigit>(twinId, twinTdcCounts, twinAdcCoutns,
false);
147 <<
", adc: "<<
digit->adc()<<
", local z: "<<simHit->localPosition().z());
148 digitsInChamber.push_back(std::make_pair(std::move(
digit), simHit));
152 std::ranges::sort(digitsInChamber,[](
const DigitSDOPair&
a,
const DigitSDOPair&
b){
153 if (
a.first->identify() !=
b.first->identify()) {
154 return a.first->identify() < b.first->identify();
156 return a.first->tdc() <
b.first->tdc();
160 addSDO(saveMe->second, sdoContainer);
161 const MdtDigit* saved =
fetchCollection(saveMe->first->identify(), digitCache)->push_back(std::move(saveMe->first));
164 saveMe = std::find_if(saveMe +1, digitsInChamber.end(),
165 [deadInterval, saved](
const DigitSDOPair& digitized) {
166 return saved->identify() != digitized.first->identify() || deadInterval < digitized.first->tdc();
169 }
while (viewer.next());
172 return StatusCode::SUCCESS;