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 MuonR4 {
31  public:
32  MuonDigitizationTool(const std::string& type,
33  const std::string& name,
34  const IInterface* pIID);
35 
36  StatusCode initialize() override;
37 
38 
39  StatusCode processBunchXing(int bunchXing,
40  SubEventIterator bSubEvents,
41  SubEventIterator eSubEvents) override final;
42 
43  StatusCode mergeEvent(const EventContext& ctx) override final;
44 
46  StatusCode prepareEvent(const EventContext& ctx,
47  const unsigned int /*nInputEvents*/) override final;
48 
49 
52  StatusCode processAllSubEvents(const EventContext& ctx) override final;
54  StatusCode processAllSubEvents(const EventContext& ctx) const;
55 
56  protected:
57  CLHEP::HepRandomEngine* getRandomEngine(const EventContext&ctx) const;
58 
60  using TimedHits = std::vector<TimedHitPtr<xAOD::MuonSimHit>>;
61 
66  virtual StatusCode digitize(const EventContext& ctx,
67  const TimedHits& hitsToDigit,
68  xAOD::MuonSimHitContainer* sdoContainer) const = 0;
69 
73  void addSDO(const TimedHit& hit, xAOD::MuonSimHitContainer* sdoContainer) const;
74 
76  const ActsGeometryContext& getGeoCtx(const EventContext& ctx) const;
77 
78 
83  template <class Container> StatusCode retrieveContainer(const EventContext& ctx,
85  const Container* & contPtr) const;
89  template <class Container> StatusCode retrieveConditions(const EventContext&ctx,
91  const Container* & contPtr) const;
92 
93 
98  template <class DetType> using OutDigitCache_t = std::vector<std::unique_ptr<DetType>>;
99 
103  template <class DigitColl>
104  DigitColl* fetchCollection(const Identifier& hitId,
105  OutDigitCache_t<DigitColl>& digitCache) const;
110  template <class DigitCont, class DigitColl>
111  StatusCode writeDigitContainer(const EventContext& ctx,
113  OutDigitCache_t<DigitColl>&& digitCache,
114  unsigned int hashMax) const;
115 
117  static double hitTime(const TimedHit& hit);
118 
119 
121 
123  "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
124  private:
126 
128  StatusCode fillTimedHits(PileUpHits&& hitColl, TimedHits& timedHits) const;
129 
131 
132  SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment",
133  "Geometry context"};
134 
135  ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""};
136 
137  Gaudi::Property<std::string> m_streamName{this, "StreamName", ""};
138 
139  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service
140 
142 
143  Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", false,
144  "Don't use the ReadHandleKey directly. Just extract the container name from it."};
145 
146  Gaudi::Property<bool> m_includePileUpTruth{this, "IncludePileUpTruth", true, "Include pile-up truth info"};
147 
148  std::string m_inputObjectName{""};
149 
152  using SimHitLocalCopy = std::pair<std::unique_ptr<xAOD::MuonSimHitContainer>,
153  std::unique_ptr<xAOD::MuonSimHitAuxContainer>>;
154  std::vector<SimHitLocalCopy> m_simHits{};
155 
156 
157 };
158 
159 }
161 #endif
162 
MuonR4::MuonDigitizationTool::m_inputObjectName
std::string m_inputObjectName
Definition: MuonDigitizationTool.h:148
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:132
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:130
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:137
MuonR4::MuonDigitizationTool::PileUpHits
PileUpMergeSvc::TimedList< xAOD::MuonSimHitContainer >::type PileUpHits
Definition: MuonDigitizationTool.h:125
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:61
ActsGeometryContext.h
MuonR4::MuonDigitizationTool::m_onlyUseContainerName
Gaudi::Property< bool > m_onlyUseContainerName
Definition: MuonDigitizationTool.h:143
MuonR4::MuonDigitizationTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: MuonDigitizationTool.h:135
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:153
MuonR4::MuonDigitizationTool::m_sdoKey
SG::WriteHandleKey< xAOD::MuonSimHitContainer > m_sdoKey
Definition: MuonDigitizationTool.h:141
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:98
MuonSimHitAuxContainer.h
TimedHitPtr< xAOD::MuonSimHit >
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::addSDO
void addSDO(const TimedHit &hit, xAOD::MuonSimHitContainer *sdoContainer) const
Adds the timed simHit to the output SDO container.
Definition: MuonDigitizationTool.cxx:148
MuonR4::MuonDigitizationTool::m_timedHits
TimedHits m_timedHits
Definition: MuonDigitizationTool.h:150
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...
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
The CsvMuonSimHitDumper reads a Simulation Hit container for muons and dumps information to csv files...
Definition: MuonSpacePoint.h:11
MuonR4::MuonDigitizationTool::initialize
StatusCode initialize() override
Definition: MuonDigitizationTool.cxx:17
MuonR4::MuonDigitizationTool::m_includePileUpTruth
Gaudi::Property< bool > m_includePileUpTruth
Definition: MuonDigitizationTool.h:146
SG::ReadCondHandleKey
Definition: ReadCondHandleKey.h:20
MuonR4::MuonDigitizationTool::m_simHits
std::vector< SimHitLocalCopy > m_simHits
Definition: MuonDigitizationTool.h:154
MuonDigitizationTool.icc
MuonR4::MuonDigitizationTool
Barebone implementation of the I/O infrastructure for all MuonDigitizationTools.
Definition: MuonDigitizationTool.h:30
MuonR4::MuonDigitizationTool::TimedHits
std::vector< TimedHitPtr< xAOD::MuonSimHit > > TimedHits
Definition: MuonDigitizationTool.h:60
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:122
MuonR4::MuonDigitizationTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: MuonDigitizationTool.h:139
MuonR4::MuonDigitizationTool::m_detMgr
const MuonGMR4::MuonDetectorManager * m_detMgr
Definition: MuonDigitizationTool.h:120
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
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 ...
IMuonIdHelperSvc.h
IAthRNGSvc.h
ServiceHandle< Muon::IMuonIdHelperSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37