ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasG4SyncEventUserInfo.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 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:
35 EventStatus Status() const;
38 bool EventAborted() const { return m_event_aborted; }
39 void EventAborted(bool aborted) { m_event_aborted = aborted; }
40
41 private:
42 void SetStatus(const EventStatus&);
43 void WaitStatus(const EventStatus&);
44
45 bool m_event_aborted{false};
47 mutable std::mutex m_mutex;
48 std::condition_variable m_cv;
49};
50
51// Extension of AtlasG4EventUserInfo to store Athena-G4 interface data necessary for synchronized event processing
53{
54 public:
55 using EventFactoryFunction = std::function<StatusCode(G4Event&, std::unique_ptr<AtlasG4SyncEventUserInfo>)>;
56 using SPSyncInterface = std::shared_ptr<G4EventSynchronizationInterface>;
57
58 AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine*, EventFactoryFunction&&, const EventContext&);
59
61 return GetEventContext().eventID().event_number();
62 }
63
64 CLHEP::HepRandomEngine* HepRandomEngine() {
65 return m_rng_engine;
66 }
67
71
75
76 private:
77 // Random engine for this event seeded by Athena
78 CLHEP::HepRandomEngine* m_rng_engine{nullptr};
79 // Factory function for Athena to prepare the G4 event
81 // Synchronization interface between Athena and Geant4 for this event
82 // held in a shared pointer to allow access from Athena after G4Event is destroyed
84};
85
86#endif// G4RUNMANAGEMENT_AtlasG4SyncEventUserInfo_H
EventIDBase::event_number_t event_number_t
AtlasG4EventUserInfo(const EventContext &ctx)
const EventContext & GetEventContext() const
std::function< StatusCode(G4Event &, std::unique_ptr< AtlasG4SyncEventUserInfo >)> EventFactoryFunction
AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine *, EventFactoryFunction &&, const EventContext &)
SPSyncInterface SyncInterface() const
event_number_t AthenaEventID() const
std::shared_ptr< G4EventSynchronizationInterface > SPSyncInterface
EventFactoryFunction EventFactory() const
EventFactoryFunction m_event_factory
CLHEP::HepRandomEngine * m_rng_engine
CLHEP::HepRandomEngine * HepRandomEngine()