ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasG4EventUserInfo.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MCTRUTH_ATLASG4EVENTUSERINFO_H
6#define MCTRUTH_ATLASG4EVENTUSERINFO_H
7
8
9#include <GaudiKernel/EventContext.h>
14
15#include <G4EventManager.hh>
16#include "G4VUserEventInformation.hh"
17
18#include <memory>
26class AtlasG4EventUserInfo: public G4VUserEventInformation {
27public:
28 AtlasG4EventUserInfo(const EventContext& ctx)
29 : G4VUserEventInformation()
30 , m_eventContext(ctx)
31 , m_eventStore(Atlas::getExtendedEventContext(ctx).proxy())
32 {}
33
44
59 void SetLastProcessedTrackID(int trackID) { m_lastProcessedTrackID = trackID; }
60
76 void SetLastProcessedStep(int stepNumber) { m_lastProcessedStep = stepNumber; }
77
82 std::shared_ptr<HitCollectionMap> GetHitCollectionMap() const { return m_hitCollectionMap; }
83
87 void SetHitCollectionMap(std::shared_ptr<HitCollectionMap> hitCollections) { m_hitCollectionMap = hitCollections; }
88
89 const EventContext& GetEventContext() const { return m_eventContext; }
90
92
93 void Print() const {}
94
95 // Static helper method to get the AtlasG4EventUserInfo from G4EventManager
97 {
98 // Event manager may be null in unit tests.
99 G4EventManager* eventManager = G4EventManager::GetEventManager();
100 if (!eventManager) {
101 return nullptr;
102 }
103 // User info may be null
104 return static_cast<AtlasG4EventUserInfo*>(eventManager->GetUserInformation());
105 }
106
107
108private:
109 const EventContext& m_eventContext;
112
113 std::shared_ptr<HitCollectionMap> m_hitCollectionMap{std::make_shared<HitCollectionMap>()};
114
115 // These next two variables are used by the CaloCalibrationHit
116 // recording code as event-level flags They correspond to the Track
117 // ID and step number of the last G4Step processed by a
118 // CaloCalibrationHit SD Both are needed, because a particle might
119 // have only one step
122};
123
124#endif // MCTRUTH_ATLASG4EVENTUSERINFO_H
void SetHepMCEvent(HepMC::GenEvent *)
set m_theEvent, the pointer to the HepMC::GenEvent used to create the G4Event.
void SetLastProcessedStep(int stepNumber)
record value of the G4Track::GetCurrentStepNumber() for the current G4Step.
std::shared_ptr< HitCollectionMap > m_hitCollectionMap
std::shared_ptr< HitCollectionMap > GetHitCollectionMap() const
Get the HitCollectionMap object with shared ownership.
static AtlasG4EventUserInfo * GetEventUserInfo()
int GetLastProcessedTrackID() const
return the value of G4Track::GetTrackID() for the last G4Step processed by a CaloCalibrationHit Sensi...
int GetLastProcessedStep() const
return the value of the G4Track::GetCurrentStepNumber() for the last G4Step processed by a CaloCalibr...
HepMC::GenEvent * m_theEvent
AtlasG4EventUserInfo(const EventContext &ctx)
void SetHitCollectionMap(std::shared_ptr< HitCollectionMap > hitCollections)
Set the HitCollectionMap object.
const EventContext & m_eventContext
HepMC::GenEvent * GetHepMCEvent()
return a pointer to the HepMC::GenEvent used to create the G4Event.
void SetLastProcessedTrackID(int trackID)
record the value of G4Track::GetTrackID() for the current G4Step.
const EventContext & GetEventContext() const
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39