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);
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));
118 if (twinId == hitId) {
123 if (!readOutEle->
isValid(twinHash)) {
132 <<
", tube length: "<<readOutEle->
activeTubeLength(measHash)<<
", distRO: "<<distRO
134 <<
", twin distance: "<<twinDist);
140 const double twinTdcTime = digiOutput.
driftTime() + arrivalTime + twinPropTime
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();
159 for (std::vector<DigitSDOPair>::iterator saveMe = digitsInChamber.begin(); saveMe != digitsInChamber.end() ; ) {
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;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
ATLAS-specific HepMC functions.
Handle class for recording to StoreGate.
Obj * get()
Get (non-const) access to the underlying object.
This is a "hash" representation of an Identifier.
bool isGood(const Identifier &Id) const
Returns if the identifier (tube/multiLayer/chamber) is masked in the conditions database.
float inversePropSpeed() const
const MdtFullCalibData * getCalibData(const Identifier &measId, MsgStream &msg) const
Returns the calibration data associated with this station.
Identifier identify() const
Readout element to describe the Monitored Drift Tube (Mdt) chambers Mdt chambers usually comrpise out...
double activeTubeLength(const IdentifierHash &hash) const
double distanceToReadout(const ActsTrk::GeometryContext &ctx, const Identifier &measId, const Amg::Vector3D &globPoint) const
Returns the distance to the readout card along the wire.
bool isValid(const IdentifierHash &measHash) const
Checks whether the passed meaurement hash corresponds to a valid tube described by the readout elemen...
static IdentifierHash measurementHash(unsigned layerNumber, unsigned tubeNumber)
Constructs a Measurement hash from layer && tube number.
size_type module_hash_max() const
the maximum hash value
double hvDelayTime(const Identifier &channelId) const
Returns the HV time delay for a given twin tube pair.
bool isTwinTubeLayer(const Identifier &channelId) const
Returns whether the multilayer is equipped with twin-tubes or not.
Identifier twinId(const Identifier &channelId) const
Returns the Identifier of the mapped twin tube.
a smart pointer to a hit that also provides access to the extended timing info of the host event.
bool next() noexcept
Loads the hits from the next chamber.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.
class which holds the full set of calibration constants for a given tube
TubeContainerPtr tubeCalib
float t0
< relative t0 in chamber (ns)