ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSensitiveDetector.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONSENSITIVEDETECTORSR4_MUONSENSITIVEDETECTOR_H
5#define MUONSENSITIVEDETECTORSR4_MUONSENSITIVEDETECTOR_H
6
9
17
18#include <G4VSensitiveDetector.hh>
19
24namespace MuonG4R4 {
31 container->setStore(auxContainer.get());
32 }
33
34 std::unique_ptr<xAOD::MuonSimHitContainer> container{std::make_unique<xAOD::MuonSimHitContainer>()};
36 std::unique_ptr<xAOD::MuonSimHitAuxContainer> auxContainer{std::make_unique<xAOD::MuonSimHitAuxContainer>()};
37 };
38
39 class MuonSensitiveDetector : public G4VSensitiveDetector, public AthMessaging {
40 public:
46 MuonSensitiveDetector(const std::string& name,
47 const std::string& output_key,
48 const std::string& trf_storeKey,
49 const MuonGMR4::MuonDetectorManager* detMgr);
52
54 virtual void Initialize(G4HCofThisEvent* HCE) override final;
55
56 private:
58 std::string m_writeKey{};
64 protected:
69 bool processStep(const G4Step* step) const;
70
73 ActsTrk::GeometryContext getGeoContext(const EventContext& ctx) const;
74
80 const G4Step* hitStep);
81
91 const Amg::Transform3D& toGasGap,
92 const G4Step* hitStep);
93
100 xAOD::MuonSimHit* saveHit(const Identifier& hitId,
101 const Amg::Vector3D& hitPos,
102 const Amg::Vector3D& hitDir,
103 const double globTime,
104 const G4Step* hitStep);
105
108
109
110 };
111}
115template<> inline StatusCode HitCollectionMap::Record<MuonG4R4::MuonSimHitsVec>(std::string const& sgKey, std::string const& hitCollectionName, EventContext const& ctx) {
116 SG::WriteHandle<xAOD::MuonSimHitContainer> writeHandle{sgKey, ctx};
117 auto simHitVec = Extract<MuonG4R4::MuonSimHitsVec>(hitCollectionName);
118 if (!simHitVec) {
119 THROW_EXCEPTION("The Muon sim hit collection "<<hitCollectionName<<" does not exist");
120 }
122 return writeHandle.record(std::move(simHitVec->container),
123 std::move(simHitVec->auxContainer));
124
125}
126
127#endif
Handle class for recording to StoreGate.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
StatusCode Record(std::string const &sgKey, std::string const &hitCollectionName, EventContext const &ctx)
Record the hit collection hitCollectionName to the StoreGate sgKey.
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the underlying detector manager.
~MuonSensitiveDetector()=default
default desructor
xAOD::MuonSimHit * lastSnapShot(const Identifier &gasGapId, const G4Step *hitStep)
Returns the last snap shot of the traversing particle.
ActsTrk::GeometryContext getGeoContext(const EventContext &ctx) const
Returns the current geometry context in the event.
virtual void Initialize(G4HCofThisEvent *HCE) override final
Create the output container at the beginning of the event.
MuonSensitiveDetector(const std::string &name, const std::string &output_key, const std::string &trf_storeKey, const MuonGMR4::MuonDetectorManager *detMgr)
Constructor.
SG::ReadHandleKey< ActsTrk::DetectorAlignStore > m_trfCacheKey
ReadHandleKey to the DetectorAlignmentStore caching the relevant transformations needed in this event...
xAOD::MuonSimHit * propagateAndSaveStrip(const Identifier &hitId, const Amg::Transform3D &toGasGap, const G4Step *hitStep)
Records the G4Step in the sim hit.
bool processStep(const G4Step *step) const
Checks whether the current step shall be processed at all.
std::string m_writeKey
Key under which the output container is stored in the G4 event.
xAOD::MuonSimHit * saveHit(const Identifier &hitId, const Amg::Vector3D &hitPos, const Amg::Vector3D &hitDir, const double globTime, const G4Step *hitStep)
Saves the current Step as a xAOD::MuonSimHit snapshot.
xAOD::MuonSimHitContainer * m_outContainer
Pointer to the MuonSimHit output container.
Property holding a SG store/key/clid from which a ReadHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Include the common definitions from the MuonReadoutGeometry.
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition MuonSimHit.h:12
MuonSimHitsVec()
Default constructor to connect the xAOD container with the Aux store class.
std::unique_ptr< xAOD::MuonSimHitAuxContainer > auxContainer
Auxiliary container actully holding the sim hit variables.
std::unique_ptr< xAOD::MuonSimHitContainer > container
Container to which the new sim hits will be appended.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10