ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasG4SyncEventUserInfo.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef G4RUNMANAGEMENT_AtlasG4SyncEventUserInfo_H
6#define G4RUNMANAGEMENT_AtlasG4SyncEventUserInfo_H
7
8#include <functional>
9#include <memory>
10#include <mutex>
11#include <condition_variable>
12
13#include "GaudiKernel/EventContext.h"
14
17
18// Forward declaration
19namespace CLHEP{
20 class HepRandomEngine;
21}
22
23class G4Event;
24
25// Synchronization variables stored in a separate structure
26// to allow access from Athena thread after G4EventInfo are destroyed
28{
29 enum class EventStatus {
33 };
34 public:
41
42 EventStatus Status() const;
44 void Complete(EventOutcome outcome) noexcept;
46 EventOutcome Outcome() const;
47
48 private:
49 void WaitStatus(const EventStatus&);
50
53 mutable std::mutex m_mutex;
54 std::condition_variable m_cv;
55};
56
57// Extension of AtlasG4EventUserInfo to store Athena-G4 interface data necessary for synchronized event processing
59{
60 public:
61 using EventFactoryFunction = std::function<StatusCode(G4Event&)>;
62 using SPSyncInterface = std::shared_ptr<G4EventSynchronizationInterface>;
63
64 AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine*, EventFactoryFunction&&, const EventContext&);
65
67 return GetEventContext().eventID().event_number();
68 }
69
70 CLHEP::HepRandomEngine* HepRandomEngine() {
71 return m_rng_engine;
72 }
73
75 return m_event_factory;
76 }
77
81
84 }
85
89
90 private:
91 // Random engine for this event seeded by Athena
92 CLHEP::HepRandomEngine* m_rng_engine{nullptr};
93 // Factory function for Athena to prepare the G4 event
95 // Set on the Geant4 worker if the event factory returns failure.
97 // Synchronization interface between Athena and Geant4 for this event
98 // held in a shared pointer to allow access from Athena after G4Event is destroyed
100};
101
102#endif // G4RUNMANAGEMENT_AtlasG4SyncEventUserInfo_H
EventIDBase::event_number_t event_number_t
AtlasG4EventUserInfo(const EventContext &ctx)
const EventContext & GetEventContext() const
AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine *, EventFactoryFunction &&, const EventContext &)
std::function< StatusCode(G4Event &)> EventFactoryFunction
SPSyncInterface SyncInterface() const
event_number_t AthenaEventID() const
std::shared_ptr< G4EventSynchronizationInterface > SPSyncInterface
EventFactoryFunction m_event_factory
CLHEP::HepRandomEngine * m_rng_engine
CLHEP::HepRandomEngine * HepRandomEngine()
const EventFactoryFunction & EventFactory() const
void Complete(EventOutcome outcome) noexcept
Record the first completion outcome and wake Athena.