ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::MdtDigitizationTool Class Referencefinal

#include <MdtDigitizationTool.h>

Inheritance diagram for MuonR4::MdtDigitizationTool:
Collaboration diagram for MuonR4::MdtDigitizationTool:

Public Member Functions

 MdtDigitizationTool (const std::string &type, const std::string &name, const IInterface *pIID)
StatusCode initialize () override final
StatusCode processBunchXing (int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
StatusCode mergeEvent (const EventContext &ctx) override final
StatusCode prepareEvent (const EventContext &ctx, const unsigned int) override final
 When being run from PileUpToolsAlgs, this method is called at the start of the subevts loop.
StatusCode processAllSubEvents (const EventContext &ctx) override final
 alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.
StatusCode processAllSubEvents (const EventContext &ctx) const
 Reentrant version of the digitization tool.
 PileUpToolBase (const std::string &type, const std::string &name, const IInterface *parent)

Protected Types

using TimedHit = TimedHitPtr<xAOD::MuonSimHit>
using TimedHits = std::vector<TimedHitPtr<xAOD::MuonSimHit>>
template<class DetType>
using OutDigitCache_t = std::vector<std::unique_ptr<DetType>>
 DigitContainers are sorted by DigitCollections which are the ensemble of all hits in a given MuonChamber.
using DeadTimeMap = std::unordered_map<Identifier, double>

Protected Member Functions

StatusCode digitize (const EventContext &ctx, const TimedHits &hitsToDigit, xAOD::MuonSimHitContainer *sdoContainer) const override final
 Digitize the time ordered hits and write them to the digit format specific for the detector technology.
CLHEP::HepRandomEngine * getRandomEngine (const EventContext &ctx) const
xAOD::MuonSimHitaddSDO (const TimedHit &hit, xAOD::MuonSimHitContainer *sdoContainer) const
 Adds the timed simHit to the output SDO container.
const ActsTrk::GeometryContextgetGeoCtx (const EventContext &ctx) const
 Returns the reference to the ActsTrk::GeometryContext needed to fetch global positions from the Readout geometry.
template<class DigitColl>
DigitColl * fetchCollection (const Identifier &hitId, OutDigitCache_t< DigitColl > &digitCache) const
 Helper function that provides fetches the proper DigitCollection from the DigitCache for a given hit identifier If the Collection is fetched for the first time, it's inserted into the cache first.
template<class DigitCont, class DigitColl>
StatusCode writeDigitContainer (const EventContext &ctx, const SG::WriteHandleKey< DigitCont > &key, OutDigitCache_t< DigitColl > &&digitCache, unsigned int hashMax) const
 Helper function to move the collected digits into the final DigitContainer.

Static Protected Member Functions

static double hitTime (const TimedHit &hit)
 Returns the global time of the hit which is the sum of eventTime & individual hit time.
static bool passDeadTime (const Identifier &channelId, const double hitTime, const double deadTimeWindow, DeadTimeMap &deadTimeMap)
 Returns whether the new digit is within the dead time window.

Protected Attributes

const MuonGMR4::MuonDetectorManagerm_detMgr {nullptr}
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc

Private Types

using DigiCache = OutDigitCache_t<MdtDigitCollection>
using PileUpHits = PileUpMergeSvc::TimedList<xAOD::MuonSimHitContainer>::type
using SimHitLocalCopy
 Create a local copy of the sim hits to ensure overlayed hits across the events remain valid.

Private Member Functions

StatusCode fillTimedHits (PileUpHits &&hitColl, TimedHits &timedHits) const
 Translates the PileUpHits into the timed hits format.

Private Attributes

SG::WriteHandleKey< MdtDigitContainerm_writeKey {this, "OutputObjectName", "MDT_Digits"}
SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainerm_calibDbKey
SG::ReadCondHandleKey< MdtCondDbDatam_badTubeKey {this, "BadTubeKey", "MdtCondDbData", "Key of MdtCondDbData"}
SG::ReadCondHandleKey< Muon::TwinTubeMapm_twinTubeKey {this, "TwinTubeKey", "MdtTwinTubeMap"}
ToolHandle< IMDT_DigitizationToolm_digiTool {this, "DigitizationTool", ""}
Gaudi::Property< double > m_timeResTDC {this, "ResolutionTDC", 0.5 * Gaudi::Units::ns, "TDC time resolution"}
Gaudi::Property< double > m_timeResADC {this, "ResolutionADC", 0.5 * Gaudi::Units::ns, "ADC time resolution"}
Gaudi::Property< double > m_deadTime {this, "DeadTime", 700., "MDT drift tube dead time"}
Gaudi::Property< bool > m_digitizeMuonOnly {this, "ProcessTrueMuonsOnly", false, "If set to true hit with pdgId != 13 are skipped"}
Gaudi::Property< bool > m_useTwinTube {this, "useTwinTubes", false}
 Properties to model the Twin tube signals.
Gaudi::Property< double > m_resTwin {this, "ResolutionTwinTube", 1.05 * Gaudi::Units::ns, "Twin Tube resolution"}
SG::ReadHandleKey< xAOD::MuonSimHitContainerm_simHitKey {this, "SimHitKey", ""}
SG::ReadHandleKey< ActsTrk::GeometryContextm_geoCtxKey
ServiceHandle< PileUpMergeSvcm_mergeSvc {this, "PileUpMergeSvc", "PileUpMergeSvc", ""}
Gaudi::Property< std::string > m_streamName {this, "StreamName", ""}
ServiceHandle< IAthRNGSvcm_rndmSvc {this, "RndmSvc", "AthRNGSvc", ""}
SG::WriteHandleKey< xAOD::MuonSimHitContainerm_sdoKey {this, "OutputSDOName", ""}
Gaudi::Property< bool > m_onlyUseContainerName
Gaudi::Property< bool > m_includePileUpTruth {this, "IncludePileUpTruth", true, "Include pile-up truth info"}
std::string m_inputObjectName {""}
TimedHits m_timedHits {}
std::vector< SimHitLocalCopym_simHits {}

structors and AlgTool implementation

virtual bool toProcess (int bunchXing) const override
 the method this base class helps implementing
virtual bool filterPassed () const override
 dummy implementation of passing filter
virtual void resetFilter () override
 dummy implementation of filter reset
Gaudi::Property< int > m_firstXing
Gaudi::Property< int > m_lastXing
Gaudi::Property< int > m_vetoPileUpTruthLinks
bool m_filterPassed {true}

Detailed Description

Member Typedef Documentation

◆ DeadTimeMap

using MuonR4::MuonDigitizationTool::DeadTimeMap = std::unordered_map<Identifier, double>
protectedinherited

Definition at line 100 of file MuonDigitizationTool.h.

◆ DigiCache

◆ OutDigitCache_t

template<class DetType>
using MuonR4::MuonDigitizationTool::OutDigitCache_t = std::vector<std::unique_ptr<DetType>>
protectedinherited

DigitContainers are sorted by DigitCollections which are the ensemble of all hits in a given MuonChamber.

To fill the final DigitContainer thread-safely, the DigitCollections shall be cached pre cached in a OutDigitCache_t vector which is later moved to the final DigitContainer

Definition at line 80 of file MuonDigitizationTool.h.

◆ PileUpHits

◆ SimHitLocalCopy

Initial value:
std::pair<std::unique_ptr<xAOD::MuonSimHitContainer>,
std::unique_ptr<xAOD::MuonSimHitAuxContainer>>

Create a local copy of the sim hits to ensure overlayed hits across the events remain valid.

Definition at line 143 of file MuonDigitizationTool.h.

◆ TimedHit

Definition at line 57 of file MuonDigitizationTool.h.

◆ TimedHits

using MuonR4::MuonDigitizationTool::TimedHits = std::vector<TimedHitPtr<xAOD::MuonSimHit>>
protectedinherited

Definition at line 58 of file MuonDigitizationTool.h.

Constructor & Destructor Documentation

◆ MdtDigitizationTool()

MdtDigitizationTool::MdtDigitizationTool ( const std::string & type,
const std::string & name,
const IInterface * pIID )

Member Function Documentation

◆ addSDO()

xAOD::MuonSimHit * MuonR4::MuonDigitizationTool::addSDO ( const TimedHit & hit,
xAOD::MuonSimHitContainer * sdoContainer ) const
protectedinherited

Adds the timed simHit to the output SDO container.

The hit may be rejected if it's originating from pile-up and the pile-up truth skimming strategy is applied

Definition at line 142 of file MuonDigitizationTool.cxx.

143 {
144 if(!sdoContainer) {
145 ATH_MSG_VERBOSE("No SDO container setup of writing");
146 return nullptr;
147 }
148 if (!m_includePileUpTruth && HepMC::ignoreTruthLink(hit->genParticleLink(), m_vetoPileUpTruthLinks)) {
149 ATH_MSG_VERBOSE("Hit "<<m_idHelperSvc->toString(hit->identify())<<" is a pile-up truth link");
150 return nullptr;
151 }
152 ATH_MSG_VERBOSE(m_idHelperSvc->toString(hit->identify())<<", pdgID: "<<hit->pdgId()<< " genParticleLink :"<<hit->genParticleLink());
153 ATH_MSG_VERBOSE("Genparticle: "<<hit->genParticleLink());
154 xAOD::MuonSimHit* sdoHit = sdoContainer->push_back(std::make_unique<xAOD::MuonSimHit>());
155 (*sdoHit) = (*hit);
156 static const SG::Accessor<float> acc_eventTime{"MuSim_evtTime"};
157 static const SG::Accessor<unsigned short> acc_eventID{"MuSim_evtID"};
158 static const SG::Accessor<unsigned short> acc_puType{"MuSim_puType"};
159 acc_eventTime(*sdoHit) = hit.eventTime();
160 acc_eventID(*sdoHit) = hit.eventId();
161 acc_puType(*sdoHit) = hit.pileupType();
162 return sdoHit;
163 }
#define ATH_MSG_VERBOSE(x)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_includePileUpTruth
Gaudi::Property< int > m_vetoPileUpTruthLinks
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition MuonSimHit.h:12

◆ digitize()

StatusCode MdtDigitizationTool::digitize ( const EventContext & ctx,
const TimedHits & hitsToDigit,
xAOD::MuonSimHitContainer * sdoContainer ) const
finaloverrideprotectedvirtual

Digitize the time ordered hits and write them to the digit format specific for the detector technology.

A new MuonSimHitContainer pointer is parsed to also create the MuonSDO. If a new SDO should be added to the container plese use the addSDO() method as defined below.

Fetch the needed conditions

Hit is masked in the database for whatever reason

Total tdc time is the sum of the drift time, the time of flight of the muon, the propgation along the wire and finally the constant t0 tube offset

Question: What happens if there're 2 digits such close by that their adc needs to be merged?

The HPTdc has 4 times higher clock frequency. Smear both

Put also in the twin tube digit

The signal for the twin tube needs to travel to the HV side & then through the complete twin tube

Total tdc time is the sum of the drift time, the time of flight of the muon, the propgation along the wire and finally the constant t0 tube offset

The digitization might have produced digits which are overlapping in time, in particular if twin tubes are hit. Filter tube digits which are produced within the dead time interval

Find the next digit which is either another tube or beyond the dead time

Write everything at the end into the final digit container

Implements MuonR4::MuonDigitizationTool.

Definition at line 28 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.cxx.

30 {
31
32
33 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
34 // Prepare the temporary cache
35
36 using DigitSDOPair = std::pair<std::unique_ptr<MdtDigit>, TimedHit>;
38 const MuonCalib::MdtCalibDataContainer* calibData{nullptr};
39 ATH_CHECK(SG::get(calibData, m_calibDbKey, ctx));
40 const MdtCondDbData* badTubes{nullptr};
41 ATH_CHECK(SG::get(badTubes, m_badTubeKey, ctx));
42 const Muon::TwinTubeMap* twinTubes{nullptr};
43 ATH_CHECK(SG::get(twinTubes, m_twinTubeKey, ctx));
44 CLHEP::HepRandomEngine* rndEngine = getRandomEngine(ctx);
45
46 DigiCache digitCache{};
47
48 xAOD::ChamberViewer viewer{hitsToDigit, m_idHelperSvc.get()};
49 do {
50 Identifier lastTube{};
51 double deadTime{0.};
52 std::vector<DigitSDOPair> digitsInChamber{};
53
54 for (const TimedHitPtr<xAOD::MuonSimHit>& simHit : viewer) {
55 const Identifier hitId{simHit->identify()};
57 if (!badTubes->isGood(hitId)) {
58 ATH_MSG_VERBOSE("Hit "<<m_idHelperSvc->toString(hitId)<<" is rejected due to masking in DB.");
59 continue;
60 }
61 ATH_MSG_VERBOSE("Process sim hit "<<m_idHelperSvc->toString(hitId) <<", pdgId: "<<simHit->pdgId()<<", "
62 <<Amg::toString(xAOD::toEigen(simHit->localPosition()))<<" + "<<Amg::toString(xAOD::toEigen(simHit->localDirection()))
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());
66 const MuonGMR4::MdtReadoutElement* readOutEle = m_detMgr->getMdtReadoutElement(hitId);
67 const IdentifierHash measHash{readOutEle->measurementHash(hitId)};
68 if (m_digitizeMuonOnly && !MC::isMuon(simHit)) {
69 ATH_MSG_VERBOSE("Hit is not from a muon");
70 continue;
71 }
72
73 const Amg::Vector3D locPos{xAOD::toEigen(simHit->localPosition())};
74 const double distRO = readOutEle->distanceToReadout(measHash, locPos);
75
76 const MdtDigiToolInput digiInput(std::abs(locPos.perp()), distRO, 0., 0., 0., 0., hitId);
77 const MdtDigiToolOutput digiOutput(m_digiTool->digitize(ctx, digiInput, rndEngine));
78 if (!digiOutput.wasEfficient()) {
79 ATH_MSG_VERBOSE("Hit "<<m_idHelperSvc->toString(hitId)<<" is rejected due to inefficiency modelling.");
80 continue;
81 }
82 const double arrivalTime{simHit->globalTime()};
83
84 const MuonCalib::MdtFullCalibData* tubeConstants = calibData->getCalibData(hitId, msgStream());
85 assert(tubeConstants != nullptr);
86 assert(tubeConstants->tubeCalib.get() != nullptr);
87 assert(tubeConstants->tubeCalib->getCalib(hitId) != nullptr);
88
89 const MuonCalib::MdtTubeCalibContainer::SingleTubeCalib& tubeCalib{*tubeConstants->tubeCalib->getCalib(hitId)};
90
91 const double sigPropTime = calibData->inversePropSpeed()*distRO;
92 ATH_MSG_VERBOSE(m_idHelperSvc->toString(hitId)<<" "<<Amg::toString(locPos)<<" distance to readout: "<<distRO<<" --> "<<sigPropTime);
95 const double totalTdcTime = digiOutput.driftTime() + arrivalTime + tubeCalib.t0 + sigPropTime;
96 if (lastTube != hitId || deadTime < totalTdcTime) {
97 lastTube = hitId;
98 deadTime = totalTdcTime + m_deadTime;
99 } else {
100 ATH_MSG_VERBOSE("Hit "<<m_idHelperSvc->toString(hitId)<<" has been produced within dead time");
101 continue;
102 }
104
105 const bool hasHPTdc = m_idHelperSvc->hasHPTDC(hitId);
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);
109
110 auto digit = std::make_unique<MdtDigit>(hitId, tdcCounts, adcCounts, false);
111 ATH_MSG_VERBOSE("Add digit "<<m_idHelperSvc->toString(digit->identify())<<", tdc: "<<digit->tdc()<<", adc: "<<digit->adc());
112 digitsInChamber.push_back(std::make_pair(std::move(digit), simHit));
114 if (!twinTubes || !twinTubes->isTwinTubeLayer(hitId)) {
115 continue;
116 }
117 const Identifier twinId{twinTubes->twinId(hitId)};
118 if (twinId == hitId) {
119 ATH_MSG_VERBOSE("The hit "<<m_idHelperSvc->toString(hitId)<<" has no twins.");
120 continue;
121 }
122 const IdentifierHash twinHash{readOutEle->measurementHash(twinId)};
123 if (!readOutEle->isValid(twinHash)) {
124 ATH_MSG_VERBOSE("Reject "<<m_idHelperSvc->toString(twinId)<<" as there's no tube ");
125 continue;
126 }
128 const double twinDist = readOutEle->activeTubeLength(measHash) - distRO +
129 readOutEle->activeTubeLength(twinHash);
130
131 ATH_MSG_VERBOSE("Twin hit :"<<m_idHelperSvc->toString(twinId)<< ", local Z: "<<simHit->localPosition().z()
132 <<", tube length: "<<readOutEle->activeTubeLength(measHash)<<", distRO: "<<distRO
133 <<", twin length: "<<readOutEle->activeTubeLength(twinHash)
134 <<", twin distance: "<<twinDist);
135 const MuonCalib::MdtTubeCalibContainer::SingleTubeCalib& twinCalib{*tubeConstants->tubeCalib->getCalib(twinId)};
136
137 const double twinPropTime = calibData->inversePropSpeed()*twinDist;
140 const double twinTdcTime = digiOutput.driftTime() + arrivalTime + twinPropTime
141 + twinCalib.t0 + twinTubes->hvDelayTime(twinId);
142
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);
146 ATH_MSG_VERBOSE("Add twin digit "<<m_idHelperSvc->toString(digit->identify())<<", tdc: "<<digit->tdc()
147 <<", adc: "<<digit->adc()<<", local z: "<<simHit->localPosition().z());
148 digitsInChamber.push_back(std::make_pair(std::move(digit), simHit));
149 }
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();
155 }
156 return a.first->tdc() < b.first->tdc();
157 });
158
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));
162 const uint16_t deadInterval = saved->tdc() + timeToTdcCnv*(m_idHelperSvc->hasHPTDC(saved->identify()) ?4 : 1)*m_deadTime;
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();
167 });
168 }
169 } while (viewer.next());
171 ATH_CHECK(writeDigitContainer(ctx, m_writeKey, std::move(digitCache), idHelper.module_hash_max()));
172 return StatusCode::SUCCESS;
173 }
#define ATH_CHECK
Evaluate an expression and check for errors.
Obj * get()
Get (non-const) access to the underlying object.
bool isGood(const Identifier &Id) const
Returns if the identifier (tube/multiLayer/chamber) is masked in the conditions database.
int16_t tdc() const
Definition MdtDigit.h:26
const MdtFullCalibData * getCalibData(const Identifier &measId, MsgStream &msg) const
Returns the calibration data associated with this station.
Identifier identify() const
Definition MuonDigit.h:30
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
double distanceToReadout(const ActsTrk::GeometryContext &ctx, const Identifier &measId, const Amg::Vector3D &globPoint) const
Returns the distance along the wire from the readout card The distance is given as the delta z of the...
bool isValid(const IdentifierHash &measHash) const
size_type module_hash_max() const
the maximum hash value
SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainer > m_calibDbKey
xAOD::MuonSimHit * addSDO(const TimedHit &hit, xAOD::MuonSimHitContainer *sdoContainer) const
Adds the timed simHit to the output SDO container.
CLHEP::HepRandomEngine * getRandomEngine(const EventContext &ctx) const
TimedHitPtr< xAOD::MuonSimHit > TimedHit
DigitColl * fetchCollection(const Identifier &hitId, OutDigitCache_t< DigitColl > &digitCache) const
Helper function that provides fetches the proper DigitCollection from the DigitCache for a given hit ...
const MuonGMR4::MuonDetectorManager * m_detMgr
StatusCode writeDigitContainer(const EventContext &ctx, const SG::WriteHandleKey< DigitCont > &key, OutDigitCache_t< DigitColl > &&digitCache, unsigned int hashMax) const
Helper function to move the collected digits into the final DigitContainer.
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.
TList * a
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D
float deadTime
bool isMuon(const T &p)
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
setWord1 uint16_t

◆ fetchCollection()

template<class DigitColl>
DigitColl * MuonR4::MuonDigitizationTool::fetchCollection ( const Identifier & hitId,
OutDigitCache_t< DigitColl > & digitCache ) const
protectedinherited

Helper function that provides fetches the proper DigitCollection from the DigitCache for a given hit identifier If the Collection is fetched for the first time, it's inserted into the cache first.

◆ fillTimedHits()

StatusCode MuonR4::MuonDigitizationTool::fillTimedHits ( PileUpHits && hitColl,
TimedHits & timedHits ) const
privateinherited

Translates the PileUpHits into the timed hits format.

Definition at line 44 of file MuonDigitizationTool.cxx.

44 {
45 for (const auto& [timeIndex, simHitColl] : hitColl) {
46 timedHits.reserve(timedHits.capacity() + simHitColl->size());
47 for (const xAOD::MuonSimHit* simHit : *simHitColl) {
48 timedHits.emplace_back(timeIndex.time(), timeIndex.index(), simHit, timeIndex.type());
49 }
50 }
51 std::stable_sort(timedHits.begin(), timedHits.end(),
52 [](const TimedHit& a, const TimedHit& b){
53 if (a->identify() != b->identify()){
54 return a->identify() < b->identify();
55 }
56 if (a.eventId() != b.eventId()) {
57 return a.eventId() < b.eventId();
58 }
59 return a.eventTime() < b.eventTime();
60 });
61 return StatusCode::SUCCESS;
62 }
if(febId1==febId2)
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

◆ filterPassed()

virtual bool PileUpToolBase::filterPassed ( ) const
inlineoverridevirtualinherited

dummy implementation of passing filter

Definition at line 49 of file PileUpToolBase.h.

49{ return m_filterPassed; }

◆ getGeoCtx()

const ActsTrk::GeometryContext & MuonR4::MuonDigitizationTool::getGeoCtx ( const EventContext & ctx) const
protectedinherited

Returns the reference to the ActsTrk::GeometryContext needed to fetch global positions from the Readout geometry.

Definition at line 135 of file MuonDigitizationTool.cxx.

135 {
136 const ActsTrk::GeometryContext* gctx{};
137 if (!SG::get(gctx, m_geoCtxKey, ctx).isSuccess()) {
138 THROW_EXCEPTION("Failed to retrieve the geometry context "<<m_geoCtxKey.fullKey());
139 }
140 return *gctx;
141 }
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ getRandomEngine()

CLHEP::HepRandomEngine * MuonR4::MuonDigitizationTool::getRandomEngine ( const EventContext & ctx) const
protectedinherited

Definition at line 129 of file MuonDigitizationTool.cxx.

129 {
130 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, m_streamName);
131 std::string rngName = m_streamName;
132 rngWrapper->setSeed(rngName, ctx);
133 return rngWrapper->getEngine(ctx);
134 }
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
ServiceHandle< IAthRNGSvc > m_rndmSvc
Gaudi::Property< std::string > m_streamName

◆ hitTime()

double MuonR4::MuonDigitizationTool::hitTime ( const TimedHit & hit)
staticprotectedinherited

Returns the global time of the hit which is the sum of eventTime & individual hit time.

Definition at line 63 of file MuonDigitizationTool.cxx.

63 {
64 return hit.eventTime() + hit->globalTime();
65 }

◆ initialize()

StatusCode MdtDigitizationTool::initialize ( )
finaloverridevirtual

Reimplemented from PileUpToolBase.

Definition at line 20 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.cxx.

20 {
22 ATH_CHECK(m_writeKey.initialize());
23 ATH_CHECK(m_calibDbKey.initialize());
24 ATH_CHECK(m_badTubeKey.initialize());
26 return StatusCode::SUCCESS;
27 }
Gaudi::Property< bool > m_useTwinTube
Properties to model the Twin tube signals.

◆ mergeEvent()

StatusCode MuonR4::MuonDigitizationTool::mergeEvent ( const EventContext & ctx)
finaloverrideinherited

Definition at line 92 of file MuonDigitizationTool.cxx.

92 {
93 ATH_MSG_DEBUG("mergeEvent()");
94
95 SG::WriteHandle<xAOD::MuonSimHitContainer> sdoContainer{};
96 if (!m_sdoKey.empty()) {
97 sdoContainer = SG::WriteHandle<xAOD::MuonSimHitContainer>{m_sdoKey, ctx};
98 ATH_CHECK(sdoContainer.record(std::make_unique<xAOD::MuonSimHitContainer>(),
99 std::make_unique<xAOD::MuonSimHitAuxContainer>()));
100 }
101 ATH_CHECK(digitize(ctx, m_timedHits, !m_sdoKey.empty() ? sdoContainer.ptr() : nullptr));
102 m_timedHits.clear();
103 m_simHits.clear();
104 return StatusCode::SUCCESS;
105 }
#define ATH_MSG_DEBUG(x)
std::vector< SimHitLocalCopy > m_simHits
virtual StatusCode digitize(const EventContext &ctx, const TimedHits &hitsToDigit, xAOD::MuonSimHitContainer *sdoContainer) const =0
Digitize the time ordered hits and write them to the digit format specific for the detector technolog...
SG::WriteHandleKey< xAOD::MuonSimHitContainer > m_sdoKey
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.

◆ passDeadTime()

bool MuonR4::MuonDigitizationTool::passDeadTime ( const Identifier & channelId,
const double hitTime,
const double deadTimeWindow,
DeadTimeMap & deadTimeMap )
staticprotectedinherited

Returns whether the new digit is within the dead time window.

channelId: Identifier of the fired channel

hitTime: Current hit time

deadTimeWindow: Dead time to pass before the next hit may be accepted

deadTimeMap: Map storing the last hit times from each Identifier

Channel not seen before

Update dead time map & accept hit

Definition at line 164 of file MuonDigitizationTool.cxx.

167 {
168 auto insertItr = deadTimeMap.insert(std::make_pair(channelId,hitTime));
170 if (insertItr.second) {
171 return true;
172 }
173 if (hitTime - insertItr.first->second < deadTimeWindow) {
174 return false;
175 }
177 insertItr.first->second = hitTime;
178 return true;
179 }
static double hitTime(const TimedHit &hit)
Returns the global time of the hit which is the sum of eventTime & individual hit time.

◆ PileUpToolBase()

PileUpToolBase::PileUpToolBase ( const std::string & type,
const std::string & name,
const IInterface * parent )
inherited

Definition at line 22 of file PileUpToolBase.cxx.

10 : base_class(type, name, parent)
11{
12}

◆ prepareEvent()

StatusCode MuonR4::MuonDigitizationTool::prepareEvent ( const EventContext & ctx,
const unsigned int nInputEvents )
finaloverrideinherited

When being run from PileUpToolsAlgs, this method is called at the start of the subevts loop.

Not able to access SubEvents

Definition at line 35 of file MuonDigitizationTool.cxx.

36 {
37
38 ATH_MSG_DEBUG("prepareEvent() called for " << nInputEvents << " input events");
39 m_timedHits.clear();
40 m_simHits.clear();
41 return StatusCode::SUCCESS;
42 }

◆ processAllSubEvents() [1/2]

StatusCode MuonR4::MuonDigitizationTool::processAllSubEvents ( const EventContext & ctx) const
inherited

Reentrant version of the digitization tool.

In case of single hits container just load the collection using read handles

Definition at line 71 of file MuonDigitizationTool.cxx.

71 {
72 PileUpHits hitCollList{};
73 TimedHits timedHits{};
76 const xAOD::MuonSimHitContainer* hitCollection{nullptr};
77 ATH_CHECK(SG::get(hitCollection, m_simHitKey, ctx));
78 hitCollList.emplace_back(PileUpTimeEventIndex(0), hitCollection);
79 } else {
80 ATH_CHECK(m_mergeSvc->retrieveSubEvtsData(m_inputObjectName, hitCollList));
81 }
82 ATH_CHECK(fillTimedHits(std::move(hitCollList), timedHits));
83 SG::WriteHandle<xAOD::MuonSimHitContainer> sdoContainer{};
84 if (!m_sdoKey.empty()) {
85 sdoContainer = SG::WriteHandle<xAOD::MuonSimHitContainer>{m_sdoKey, ctx};
86 ATH_CHECK(sdoContainer.record(std::make_unique<xAOD::MuonSimHitContainer>(),
87 std::make_unique<xAOD::MuonSimHitAuxContainer>()));
88 }
89 ATH_CHECK(digitize(ctx, timedHits, !m_sdoKey.empty() ? sdoContainer.ptr() : nullptr));
90 return StatusCode::SUCCESS;
91 }
ServiceHandle< PileUpMergeSvc > m_mergeSvc
std::vector< TimedHitPtr< xAOD::MuonSimHit > > TimedHits
Gaudi::Property< bool > m_onlyUseContainerName
SG::ReadHandleKey< xAOD::MuonSimHitContainer > m_simHitKey
StatusCode fillTimedHits(PileUpHits &&hitColl, TimedHits &timedHits) const
Translates the PileUpHits into the timed hits format.
PileUpMergeSvc::TimedList< xAOD::MuonSimHitContainer >::type PileUpHits
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.

◆ processAllSubEvents() [2/2]

StatusCode MuonR4::MuonDigitizationTool::processAllSubEvents ( const EventContext & ctx)
finaloverridevirtualinherited

alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.

Reimplemented from PileUpToolBase.

Definition at line 66 of file MuonDigitizationTool.cxx.

66 {
67 const MuonDigitizationTool* digiTool = this;
68 return digiTool->processAllSubEvents(ctx);
69 }

◆ processBunchXing()

StatusCode MuonR4::MuonDigitizationTool::processBunchXing ( int bunchXing,
SubEventIterator bSubEvents,
SubEventIterator eSubEvents )
finaloverridevirtualinherited

Reimplemented from PileUpToolBase.

Definition at line 108 of file MuonDigitizationTool.cxx.

110 {
111 ATH_MSG_DEBUG("processBunchXing()" << bunchXing);
112 PileUpHits hitList{}, hitListPermanent{};
113 ATH_CHECK(m_mergeSvc->retrieveSubSetEvtData(m_inputObjectName, hitList, bunchXing, bSubEvents, eSubEvents));
114 ATH_MSG_VERBOSE(hitList.size() << " hits in xAODMuonSimHitContainer " << m_inputObjectName << " found");
115 for (auto& [hitPtr, hitContainer] : hitList) {
116 auto copyContainer = std::make_unique<xAOD::MuonSimHitContainer>();
117 auto copyAuxContainer = std::make_unique<xAOD::MuonSimHitAuxContainer>();
118 copyContainer->setStore(copyAuxContainer.get());
119 for (const xAOD::MuonSimHit* copyMe : *hitContainer) {
120 (*copyContainer->push_back(std::make_unique<xAOD::MuonSimHit>())) = (*copyMe);
121 }
122 hitListPermanent.emplace_back(hitPtr, copyContainer.get());
123 m_simHits.emplace_back(std::move(copyContainer), std::move(copyAuxContainer));
124 }
125 ATH_CHECK(fillTimedHits(std::move(hitListPermanent), m_timedHits));
126 return StatusCode::SUCCESS;
127 }

◆ resetFilter()

virtual void PileUpToolBase::resetFilter ( )
inlineoverridevirtualinherited

dummy implementation of filter reset

Reimplemented in MergeTruthJetsTool.

Definition at line 51 of file PileUpToolBase.h.

51{ m_filterPassed=true; }

◆ toProcess()

virtual bool PileUpToolBase::toProcess ( int bunchXing) const
inlineoverridevirtualinherited

the method this base class helps implementing

Reimplemented in MergeHijingParsTool, and MergeTrackRecordCollTool.

Definition at line 32 of file PileUpToolBase.h.

32 {
33 //closed interval [m_firstXing,m_lastXing]
34 return !((m_firstXing > bunchXing) || (bunchXing > m_lastXing));
35 }
Gaudi::Property< int > m_firstXing
Gaudi::Property< int > m_lastXing

◆ writeDigitContainer()

template<class DigitCont, class DigitColl>
StatusCode MuonR4::MuonDigitizationTool::writeDigitContainer ( const EventContext & ctx,
const SG::WriteHandleKey< DigitCont > & key,
OutDigitCache_t< DigitColl > && digitCache,
unsigned int hashMax ) const
protectedinherited

Helper function to move the collected digits into the final DigitContainer.

The function needs the maximal size of the container in advance which is provided by calling the module_hash_max() function of the corresponding MuonIdHelper.

Member Data Documentation

◆ m_badTubeKey

SG::ReadCondHandleKey<MdtCondDbData> MuonR4::MdtDigitizationTool::m_badTubeKey {this, "BadTubeKey", "MdtCondDbData", "Key of MdtCondDbData"}
private

Definition at line 34 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

34{this, "BadTubeKey", "MdtCondDbData", "Key of MdtCondDbData"};

◆ m_calibDbKey

SG::ReadCondHandleKey<MuonCalib::MdtCalibDataContainer> MuonR4::MdtDigitizationTool::m_calibDbKey
private
Initial value:
{this, "CalibDataKey", "MdtCalibConstants",
"Conditions object containing the calibrations"}

Definition at line 30 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

30 {this, "CalibDataKey", "MdtCalibConstants",
31 "Conditions object containing the calibrations"};

◆ m_deadTime

Gaudi::Property<double> MuonR4::MdtDigitizationTool::m_deadTime {this, "DeadTime", 700., "MDT drift tube dead time"}
private

Definition at line 42 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

42{this, "DeadTime", 700., "MDT drift tube dead time"};

◆ m_detMgr

const MuonGMR4::MuonDetectorManager* MuonR4::MuonDigitizationTool::m_detMgr {nullptr}
protectedinherited

Definition at line 111 of file MuonDigitizationTool.h.

111{nullptr};

◆ m_digitizeMuonOnly

Gaudi::Property<bool> MuonR4::MdtDigitizationTool::m_digitizeMuonOnly {this, "ProcessTrueMuonsOnly", false, "If set to true hit with pdgId != 13 are skipped"}
private

Definition at line 43 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

43{this, "ProcessTrueMuonsOnly", false, "If set to true hit with pdgId != 13 are skipped"};

◆ m_digiTool

ToolHandle<IMDT_DigitizationTool> MuonR4::MdtDigitizationTool::m_digiTool {this, "DigitizationTool", ""}
private

Definition at line 38 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

38{this, "DigitizationTool", ""};

◆ m_filterPassed

bool PileUpToolBase::m_filterPassed {true}
protectedinherited

Definition at line 60 of file PileUpToolBase.h.

60{true};

◆ m_firstXing

Gaudi::Property<int> PileUpToolBase::m_firstXing
protectedinherited
Initial value:
{this, "FirstXing", -999,
"First bunch-crossing in which det is live"}

Definition at line 54 of file PileUpToolBase.h.

54 {this, "FirstXing", -999,
55 "First bunch-crossing in which det is live"};

◆ m_geoCtxKey

SG::ReadHandleKey<ActsTrk::GeometryContext> MuonR4::MuonDigitizationTool::m_geoCtxKey
privateinherited
Initial value:
{this, "AlignmentKey", "ActsAlignment",
"Geometry context"}

Definition at line 123 of file MuonDigitizationTool.h.

123 {this, "AlignmentKey", "ActsAlignment",
124 "Geometry context"};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonR4::MuonDigitizationTool::m_idHelperSvc
protectedinherited
Initial value:
{this, "MuonIdHelperSvc",
"Muon::MuonIdHelperSvc/MuonIdHelperSvc"}

Definition at line 113 of file MuonDigitizationTool.h.

113 {this, "MuonIdHelperSvc",
114 "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_includePileUpTruth

Gaudi::Property<bool> MuonR4::MuonDigitizationTool::m_includePileUpTruth {this, "IncludePileUpTruth", true, "Include pile-up truth info"}
privateinherited

Definition at line 137 of file MuonDigitizationTool.h.

137{this, "IncludePileUpTruth", true, "Include pile-up truth info"};

◆ m_inputObjectName

std::string MuonR4::MuonDigitizationTool::m_inputObjectName {""}
privateinherited

Definition at line 139 of file MuonDigitizationTool.h.

139{""};

◆ m_lastXing

Gaudi::Property<int> PileUpToolBase::m_lastXing
protectedinherited
Initial value:
{this, "LastXing", 999,
"Last bunch-crossing in which det is live"}

Definition at line 56 of file PileUpToolBase.h.

56 {this, "LastXing", 999,
57 "Last bunch-crossing in which det is live"};

◆ m_mergeSvc

ServiceHandle<PileUpMergeSvc> MuonR4::MuonDigitizationTool::m_mergeSvc {this, "PileUpMergeSvc", "PileUpMergeSvc", ""}
privateinherited

Definition at line 126 of file MuonDigitizationTool.h.

126{this, "PileUpMergeSvc", "PileUpMergeSvc", ""};

◆ m_onlyUseContainerName

Gaudi::Property<bool> MuonR4::MuonDigitizationTool::m_onlyUseContainerName
privateinherited
Initial value:
{this, "OnlyUseContainerName", false,
"Don't use the ReadHandleKey directly. Just extract the container name from it."}

Definition at line 134 of file MuonDigitizationTool.h.

134 {this, "OnlyUseContainerName", false,
135 "Don't use the ReadHandleKey directly. Just extract the container name from it."};

◆ m_resTwin

Gaudi::Property<double> MuonR4::MdtDigitizationTool::m_resTwin {this, "ResolutionTwinTube", 1.05 * Gaudi::Units::ns, "Twin Tube resolution"}
private

Definition at line 46 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

46{this, "ResolutionTwinTube", 1.05 * Gaudi::Units::ns, "Twin Tube resolution"};

◆ m_rndmSvc

ServiceHandle<IAthRNGSvc> MuonR4::MuonDigitizationTool::m_rndmSvc {this, "RndmSvc", "AthRNGSvc", ""}
privateinherited

Definition at line 130 of file MuonDigitizationTool.h.

130{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service

◆ m_sdoKey

SG::WriteHandleKey<xAOD::MuonSimHitContainer> MuonR4::MuonDigitizationTool::m_sdoKey {this, "OutputSDOName", ""}
privateinherited

Definition at line 132 of file MuonDigitizationTool.h.

132{this, "OutputSDOName", ""};

◆ m_simHitKey

SG::ReadHandleKey<xAOD::MuonSimHitContainer> MuonR4::MuonDigitizationTool::m_simHitKey {this, "SimHitKey", ""}
privateinherited

Definition at line 121 of file MuonDigitizationTool.h.

121{this, "SimHitKey", ""};

◆ m_simHits

std::vector<SimHitLocalCopy> MuonR4::MuonDigitizationTool::m_simHits {}
privateinherited

Definition at line 145 of file MuonDigitizationTool.h.

145{};

◆ m_streamName

Gaudi::Property<std::string> MuonR4::MuonDigitizationTool::m_streamName {this, "StreamName", ""}
privateinherited

Definition at line 128 of file MuonDigitizationTool.h.

128{this, "StreamName", ""};

◆ m_timedHits

TimedHits MuonR4::MuonDigitizationTool::m_timedHits {}
privateinherited

Definition at line 141 of file MuonDigitizationTool.h.

141{};

◆ m_timeResADC

Gaudi::Property<double> MuonR4::MdtDigitizationTool::m_timeResADC {this, "ResolutionADC", 0.5 * Gaudi::Units::ns, "ADC time resolution"}
private

Definition at line 41 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

41{this, "ResolutionADC", 0.5 * Gaudi::Units::ns, "ADC time resolution"};

◆ m_timeResTDC

Gaudi::Property<double> MuonR4::MdtDigitizationTool::m_timeResTDC {this, "ResolutionTDC", 0.5 * Gaudi::Units::ns, "TDC time resolution"}
private

Definition at line 40 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

40{this, "ResolutionTDC", 0.5 * Gaudi::Units::ns, "TDC time resolution"};

◆ m_twinTubeKey

SG::ReadCondHandleKey<Muon::TwinTubeMap> MuonR4::MdtDigitizationTool::m_twinTubeKey {this, "TwinTubeKey", "MdtTwinTubeMap"}
private

Definition at line 36 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

36{this, "TwinTubeKey", "MdtTwinTubeMap"};

◆ m_useTwinTube

Gaudi::Property<bool> MuonR4::MdtDigitizationTool::m_useTwinTube {this, "useTwinTubes", false}
private

Properties to model the Twin tube signals.

Definition at line 45 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

45{this, "useTwinTubes", false};

◆ m_vetoPileUpTruthLinks

Gaudi::Property<int> PileUpToolBase::m_vetoPileUpTruthLinks
protectedinherited
Initial value:
{this, "VetoPileUpTruthLinks", true,
"Ignore links to suppressed pile-up truth"}

Definition at line 58 of file PileUpToolBase.h.

58 {this, "VetoPileUpTruthLinks", true,
59 "Ignore links to suppressed pile-up truth"};

◆ m_writeKey

SG::WriteHandleKey<MdtDigitContainer> MuonR4::MdtDigitizationTool::m_writeKey {this, "OutputObjectName", "MDT_Digits"}
private

Definition at line 28 of file MuonPhaseII/MuonDigitization/MdtDigitizationR4/src/MdtDigitizationTool.h.

28{this, "OutputObjectName", "MDT_Digits"};

The documentation for this class was generated from the following files: