ATLAS Offline Software
MuonDigitizationTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONDIGITIZATIONR4_MUONDIGITIZATIONTOOL_H
5 #define MUONDIGITIZATIONR4_MUONDIGITIZATIONTOOL_H
6 
9 
10 #include "CLHEP/Random/RandomEngine.h"
13 
16 
19 
24 
25 
26 namespace std{
27  template<> class remove_pointer<TimedHitPtr<xAOD::MuonSimHit>>{
28  public:
30  };
31  template<> class remove_pointer<TimedHitPtr<const xAOD::MuonSimHit>>{
32  public:
34  };
35 }
36 
37 namespace MuonR4 {
42  public:
43  MuonDigitizationTool(const std::string& type,
44  const std::string& name,
45  const IInterface* pIID);
46 
47  StatusCode initialize() override;
48 
49 
50  StatusCode processBunchXing(int bunchXing,
51  SubEventIterator bSubEvents,
52  SubEventIterator eSubEvents) override final;
53 
54  StatusCode mergeEvent(const EventContext& ctx) override final;
55 
57  StatusCode prepareEvent(const EventContext& ctx,
58  const unsigned int /*nInputEvents*/) override final;
59 
60 
63  StatusCode processAllSubEvents(const EventContext& ctx) override final;
65  StatusCode processAllSubEvents(const EventContext& ctx) const;
66 
67  protected:
68  CLHEP::HepRandomEngine* getRandomEngine(const EventContext&ctx) const;
69 
71  using TimedHits = std::vector<TimedHitPtr<xAOD::MuonSimHit>>;
72 
77  virtual StatusCode digitize(const EventContext& ctx,
78  const TimedHits& hitsToDigit,
79  xAOD::MuonSimHitContainer* sdoContainer) const = 0;
80 
84  xAOD::MuonSimHit* addSDO(const TimedHit& hit, xAOD::MuonSimHitContainer* sdoContainer) const;
85 
87  const ActsGeometryContext& getGeoCtx(const EventContext& ctx) const;
88 
89 
94  template <class Container> StatusCode retrieveContainer(const EventContext& ctx,
96  const Container* & contPtr) const;
100  template <class Container> StatusCode retrieveConditions(const EventContext&ctx,
102  const Container* & contPtr) const;
103 
104 
109  template <class DetType> using OutDigitCache_t = std::vector<std::unique_ptr<DetType>>;
110 
114  template <class DigitColl>
115  DigitColl* fetchCollection(const Identifier& hitId,
116  OutDigitCache_t<DigitColl>& digitCache) const;
121  template <class DigitCont, class DigitColl>
122  StatusCode writeDigitContainer(const EventContext& ctx,
124  OutDigitCache_t<DigitColl>&& digitCache,
125  unsigned int hashMax) const;
126 
128  static double hitTime(const TimedHit& hit);
129  using DeadTimeMap = std::unordered_map<Identifier, double>;
135  static bool passDeadTime(const Identifier& channelId,
136  const double hitTime,
137  const double deadTimeWindow,
138  DeadTimeMap& deadTimeMap);
139 
141 
143  "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
144  private:
146 
148  StatusCode fillTimedHits(PileUpHits&& hitColl, TimedHits& timedHits) const;
149 
151 
152  SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment",
153  "Geometry context"};
154 
155  ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""};
156 
157  Gaudi::Property<std::string> m_streamName{this, "StreamName", ""};
158 
159  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service
160 
162 
163  Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", false,
164  "Don't use the ReadHandleKey directly. Just extract the container name from it."};
165 
166  Gaudi::Property<bool> m_includePileUpTruth{this, "IncludePileUpTruth", true, "Include pile-up truth info"};
167 
168  std::string m_inputObjectName{""};
169 
172  using SimHitLocalCopy = std::pair<std::unique_ptr<xAOD::MuonSimHitContainer>,
173  std::unique_ptr<xAOD::MuonSimHitAuxContainer>>;
174  std::vector<SimHitLocalCopy> m_simHits{};
175 
176 
177 };
178 
179 }
181 #endif
182 
MuonR4::MuonDigitizationTool::m_inputObjectName
std::string m_inputObjectName
Definition: MuonDigitizationTool.h:168
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
MuonR4::MuonDigitizationTool::retrieveContainer
StatusCode retrieveContainer(const EventContext &ctx, const SG::ReadHandleKey< Container > &key, const Container *&contPtr) const
Helper function to retrieve a container from StoreGate.
MuonR4::MuonDigitizationTool::m_geoCtxKey
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Definition: MuonDigitizationTool.h:152
MuonR4::MuonDigitizationTool::passDeadTime
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.
Definition: MuonDigitizationTool.cxx:169
xAOD::MuonSimHit_v1
Definition: MuonSimHit_v1.h:18
MuonR4::MuonDigitizationTool::processBunchXing
StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
Definition: MuonDigitizationTool.cxx:114
MuonR4::MuonDigitizationTool::m_simHitKey
SG::ReadHandleKey< xAOD::MuonSimHitContainer > m_simHitKey
Definition: MuonDigitizationTool.h:150
MuonR4::MuonDigitizationTool::fillTimedHits
StatusCode fillTimedHits(PileUpHits &&hitColl, TimedHits &timedHits) const
Translates the PileUpHits into the timed hits format.
Definition: MuonDigitizationTool.cxx:50
MuonR4::MuonDigitizationTool::m_streamName
Gaudi::Property< std::string > m_streamName
Definition: MuonDigitizationTool.h:157
MuonR4::MuonDigitizationTool::PileUpHits
PileUpMergeSvc::TimedList< xAOD::MuonSimHitContainer >::type PileUpHits
Definition: MuonDigitizationTool.h:145
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:62
ActsGeometryContext.h
MuonR4::MuonDigitizationTool::m_onlyUseContainerName
Gaudi::Property< bool > m_onlyUseContainerName
Definition: MuonDigitizationTool.h:163
MuonR4::MuonDigitizationTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: MuonDigitizationTool.h:155
MuonR4::MuonDigitizationTool::SimHitLocalCopy
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.
Definition: MuonDigitizationTool.h:173
MuonR4::MuonDigitizationTool::m_sdoKey
SG::WriteHandleKey< xAOD::MuonSimHitContainer > m_sdoKey
Definition: MuonDigitizationTool.h:161
MuonR4::MuonDigitizationTool::OutDigitCache_t
std::vector< std::unique_ptr< DetType > > OutDigitCache_t
DigitContainers are sorted by DigitCollections which are the ensemble of all hits in a given MuonCham...
Definition: MuonDigitizationTool.h:109
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
MuonSimHitAuxContainer.h
TimedHitPtr
a smart pointer to a hit that also provides access to the extended timing info of the host event....
Definition: SCT_SurfaceChargesGenerator.h:77
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
MuonR4::MuonDigitizationTool::retrieveConditions
StatusCode retrieveConditions(const EventContext &ctx, const SG::ReadCondHandleKey< Container > &key, const Container *&contPtr) const
Helper function to access the conditions data.
PileUpMergeSvc::TimedList::type
std::list< value_t > type
type of the collection of timed data object
Definition: PileUpMergeSvc.h:75
MuonR4::MuonDigitizationTool::mergeEvent
StatusCode mergeEvent(const EventContext &ctx) override final
Definition: MuonDigitizationTool.cxx:98
Container
storage of the time histories of all the cells
TimedHitPtr.h
MuonR4::MuonDigitizationTool::MuonDigitizationTool
MuonDigitizationTool(const std::string &type, const std::string &name, const IInterface *pIID)
Definition: MuonDigitizationTool.cxx:12
MuonR4::MuonDigitizationTool::m_timedHits
TimedHits m_timedHits
Definition: MuonDigitizationTool.h:170
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
MuonR4::MuonDigitizationTool::digitize
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...
MuonR4::MuonDigitizationTool::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const EventContext &ctx) const
Definition: MuonDigitizationTool.cxx:135
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
MuonDetectorManager.h
MuonR4::MuonDigitizationTool::prepareEvent
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.
Definition: MuonDigitizationTool.cxx:41
MuonSimHitContainer.h
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
PileUpToolBase
Definition: PileUpToolBase.h:18
ReadCondHandleKey.h
MuonR4::MuonDigitizationTool::getGeoCtx
const ActsGeometryContext & getGeoCtx(const EventContext &ctx) const
Returns the reference to the ActsGeometryContext needed to fetch global positions from the Readout ge...
Definition: MuonDigitizationTool.cxx:141
MuonR4::MuonDigitizationTool::addSDO
xAOD::MuonSimHit * addSDO(const TimedHit &hit, xAOD::MuonSimHitContainer *sdoContainer) const
Adds the timed simHit to the output SDO container.
Definition: MuonDigitizationTool.cxx:148
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonR4::MuonDigitizationTool::writeDigitContainer
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.
MuonR4::MuonDigitizationTool::hitTime
static double hitTime(const TimedHit &hit)
Returns the global time of the hit which is the sum of eventTime & individual hit time.
Definition: MuonDigitizationTool.cxx:69
MuonR4::MuonDigitizationTool::processAllSubEvents
StatusCode processAllSubEvents(const EventContext &ctx) override final
alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.
Definition: MuonDigitizationTool.cxx:72
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonR4::MuonDigitizationTool::initialize
StatusCode initialize() override
Definition: MuonDigitizationTool.cxx:17
MuonR4::MuonDigitizationTool::m_includePileUpTruth
Gaudi::Property< bool > m_includePileUpTruth
Definition: MuonDigitizationTool.h:166
SG::ReadCondHandleKey
Definition: ReadCondHandleKey.h:20
MuonR4::MuonDigitizationTool::m_simHits
std::vector< SimHitLocalCopy > m_simHits
Definition: MuonDigitizationTool.h:174
MuonDigitizationTool.icc
MuonR4::MuonDigitizationTool
Barebone implementation of the I/O infrastructure for all MuonDigitizationTools.
Definition: MuonDigitizationTool.h:41
MuonR4::MuonDigitizationTool::TimedHits
std::vector< TimedHitPtr< xAOD::MuonSimHit > > TimedHits
Definition: MuonDigitizationTool.h:71
PileUpMergeSvc.h
the preferred mechanism to access information from the different event stores in a pileup job.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonR4::MuonDigitizationTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonDigitizationTool.h:142
MuonR4::MuonDigitizationTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: MuonDigitizationTool.h:159
MuonR4::MuonDigitizationTool::m_detMgr
const MuonGMR4::MuonDetectorManager * m_detMgr
Definition: MuonDigitizationTool.h:140
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
MuonR4::MuonDigitizationTool::DeadTimeMap
std::unordered_map< Identifier, double > DeadTimeMap
Definition: MuonDigitizationTool.h:129
PileUpToolBase.h
helper base class IPileUpTool::toProcess().
MuonR4::MuonDigitizationTool::fetchCollection
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 ...
xAOD::MuonSimHit
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition: MuonSimHit.h:12
IMuonIdHelperSvc.h
IAthRNGSvc.h
ServiceHandle< Muon::IMuonIdHelperSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Identifier
Definition: IdentifierFieldParser.cxx:14