ATLAS Offline Software
Loading...
Searching...
No Matches
MuonDigitizationTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONDIGITIZATIONR4_MUONDIGITIZATIONTOOL_H
5#define MUONDIGITIZATIONR4_MUONDIGITIZATIONTOOL_H
6
9
10
11#include "CLHEP/Random/RandomEngine.h"
13
14
17
21
22#include "Acts/Utilities/PointerTraits.hpp"
24
25
26
27namespace MuonR4 {
29 static_assert(Acts::PointerConcept<TimedHitPtr<xAOD::MuonSimHit>>);
31 public:
33
34 StatusCode initialize() override;
35
36
37 StatusCode processBunchXing(int bunchXing,
38 SubEventIterator bSubEvents,
39 SubEventIterator eSubEvents) override final;
40
41 StatusCode mergeEvent(const EventContext& ctx) override final;
42
44 StatusCode prepareEvent(const EventContext& ctx,
45 const unsigned int /*nInputEvents*/) override final;
46
47
50 StatusCode processAllSubEvents(const EventContext& ctx) override final;
52 StatusCode processAllSubEvents(const EventContext& ctx) const;
53
54 protected:
55 CLHEP::HepRandomEngine* getRandomEngine(const EventContext&ctx) const;
56
58 using TimedHits = std::vector<TimedHitPtr<xAOD::MuonSimHit>>;
59
64 virtual StatusCode digitize(const EventContext& ctx,
65 const TimedHits& hitsToDigit,
66 xAOD::MuonSimHitContainer* sdoContainer) const = 0;
67
71 xAOD::MuonSimHit* addSDO(const TimedHit& hit, xAOD::MuonSimHitContainer* sdoContainer) const;
72
74 const ActsTrk::GeometryContext& getGeoCtx(const EventContext& ctx) const;
75
80 template <class DetType> using OutDigitCache_t = std::vector<std::unique_ptr<DetType>>;
81
85 template <class DigitColl>
86 DigitColl* fetchCollection(const Identifier& hitId,
87 OutDigitCache_t<DigitColl>& digitCache) const;
92 template <class DigitCont, class DigitColl>
93 StatusCode writeDigitContainer(const EventContext& ctx,
95 OutDigitCache_t<DigitColl>&& digitCache,
96 unsigned int hashMax) const;
97
99 static double hitTime(const TimedHit& hit);
100 using DeadTimeMap = std::unordered_map<Identifier, double>;
106 static bool passDeadTime(const Identifier& channelId,
107 const double hitTime,
108 const double deadTimeWindow,
109 DeadTimeMap& deadTimeMap);
110
112
114 "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
115 private:
117
119 StatusCode fillTimedHits(PileUpHits&& hitColl, TimedHits& timedHits) const;
120
122
123 SG::ReadHandleKey<ActsTrk::GeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment",
124 "Geometry context"};
125
126 ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""};
127
128 Gaudi::Property<std::string> m_streamName{this, "StreamName", ""};
129
130 ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service
131
133
134 Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", false,
135 "Don't use the ReadHandleKey directly. Just extract the container name from it."};
136
137 Gaudi::Property<bool> m_includePileUpTruth{this, "IncludePileUpTruth", true, "Include pile-up truth info"};
138
139 std::string m_inputObjectName{""};
140
143 using SimHitLocalCopy = std::pair<std::unique_ptr<xAOD::MuonSimHitContainer>,
144 std::unique_ptr<xAOD::MuonSimHitAuxContainer>>;
145 std::vector<SimHitLocalCopy> m_simHits{};
146
147
148};
149
150}
152#endif
153
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
the preferred mechanism to access information from the different event stores in a pileup job.
helper base class IPileUpTool::toProcess().
Barebone implementation of the I/O infrastructure for all MuonDigitizationTools.
xAOD::MuonSimHit * addSDO(const TimedHit &hit, xAOD::MuonSimHitContainer *sdoContainer) const
Adds the timed simHit to the output SDO container.
ServiceHandle< PileUpMergeSvc > m_mergeSvc
std::vector< SimHitLocalCopy > m_simHits
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
std::vector< TimedHitPtr< xAOD::MuonSimHit > > TimedHits
ServiceHandle< IAthRNGSvc > m_rndmSvc
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
std::vector< std::unique_ptr< DetType > > OutDigitCache_t
DigitContainers are sorted by DigitCollections which are the ensemble of all hits in a given MuonCham...
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.
Gaudi::Property< bool > m_onlyUseContainerName
StatusCode mergeEvent(const EventContext &ctx) override final
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...
CLHEP::HepRandomEngine * getRandomEngine(const EventContext &ctx) const
Gaudi::Property< std::string > m_streamName
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.
TimedHitPtr< xAOD::MuonSimHit > TimedHit
SG::ReadHandleKey< xAOD::MuonSimHitContainer > m_simHitKey
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 ...
StatusCode processAllSubEvents(const EventContext &ctx) override final
alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.
StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
StatusCode fillTimedHits(PileUpHits &&hitColl, TimedHits &timedHits) const
Translates the PileUpHits into the timed hits format.
Gaudi::Property< bool > m_includePileUpTruth
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.
SG::WriteHandleKey< xAOD::MuonSimHitContainer > m_sdoKey
const ActsTrk::GeometryContext & getGeoCtx(const EventContext &ctx) const
Returns the reference to the ActsTrk::GeometryContext needed to fetch global positions from the Reado...
std::pair< std::unique_ptr< xAOD::MuonSimHitContainer >, std::unique_ptr< xAOD::MuonSimHitAuxContainer > > SimHitLocalCopy
Create a local copy of the sim hits to ensure overlayed hits across the events remain valid.
static double hitTime(const TimedHit &hit)
Returns the global time of the hit which is the sum of eventTime & individual hit time.
PileUpMergeSvc::TimedList< xAOD::MuonSimHitContainer >::type PileUpHits
std::unordered_map< Identifier, double > DeadTimeMap
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
a smart pointer to a hit that also provides access to the extended timing info of the host event.
Definition TimedHitPtr.h:18
This header ties the generic definitions in this package.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition MuonSimHit.h:12
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.
std::list< value_t > type
type of the collection of timed data object