ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4RunManagement
G4RunManagement
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
15
#include "
AthenaKernel/IEvtIdModifierSvc.h
"
16
#include "
MCTruth/AtlasG4EventUserInfo.h
"
17
18
// Forward declaration
19
namespace
CLHEP
{
20
class
HepRandomEngine;
21
}
22
23
class
G4Event;
24
25
// Synchronization variables stored in a separate structure
26
// to allow access from Athena thread after G4EventInfo are destroyed
27
class
G4EventSynchronizationInterface
28
{
29
enum class
EventStatus
{
30
Ready
,
31
Done
,
32
Size
33
};
34
public
:
35
EventStatus
Status
()
const
;
37
void
Complete
(
bool
eventAborted);
38
void
WaitStatusDone
() {
WaitStatus
(
EventStatus::Done
);};
39
bool
EventAborted
()
const
{
40
std::scoped_lock lk(
m_mutex
);
41
return
m_event_aborted
;
42
}
43
44
private
:
45
void
WaitStatus
(
const
EventStatus
&);
46
47
bool
m_event_aborted
{
false
};
48
EventStatus
m_status
{
EventStatus::Ready
};
49
mutable
std::mutex
m_mutex
;
50
std::condition_variable
m_cv
;
51
};
52
53
// Extension of AtlasG4EventUserInfo to store Athena-G4 interface data necessary for synchronized event processing
54
class
AtlasG4SyncEventUserInfo
:
public
AtlasG4EventUserInfo
55
{
56
public
:
57
using
EventFactoryFunction
= std::function<StatusCode(G4Event&, std::unique_ptr<AtlasG4SyncEventUserInfo>)>;
58
using
SPSyncInterface
= std::shared_ptr<G4EventSynchronizationInterface>;
59
60
AtlasG4SyncEventUserInfo
(CLHEP::HepRandomEngine*,
EventFactoryFunction
&&,
const
EventContext&);
61
62
event_number_t
AthenaEventID
()
const
{
63
return
GetEventContext
().eventID().event_number();
64
}
65
66
CLHEP::HepRandomEngine*
HepRandomEngine
() {
67
return
m_rng_engine
;
68
}
69
70
EventFactoryFunction
EventFactory
()
const
{
71
return
m_event_factory
;
72
}
73
74
SPSyncInterface
SyncInterface
()
const
{
75
return
m_sync_interface
;
76
}
77
78
private
:
79
// Random engine for this event seeded by Athena
80
CLHEP::HepRandomEngine*
m_rng_engine
{
nullptr
};
81
// Factory function for Athena to prepare the G4 event
82
EventFactoryFunction
m_event_factory
;
83
// Synchronization interface between Athena and Geant4 for this event
84
// held in a shared pointer to allow access from Athena after G4Event is destroyed
85
SPSyncInterface
m_sync_interface
;
86
};
87
88
#endif
// G4RUNMANAGEMENT_AtlasG4SyncEventUserInfo_H
AtlasG4EventUserInfo.h
IEvtIdModifierSvc.h
event_number_t
EventIDBase::event_number_t event_number_t
Definition
IEvtIdModifierSvc.h:30
AtlasG4EventUserInfo::AtlasG4EventUserInfo
AtlasG4EventUserInfo(const EventContext &ctx)
Definition
AtlasG4EventUserInfo.h:28
AtlasG4EventUserInfo::GetEventContext
const EventContext & GetEventContext() const
Definition
AtlasG4EventUserInfo.h:89
AtlasG4SyncEventUserInfo::EventFactoryFunction
std::function< StatusCode(G4Event &, std::unique_ptr< AtlasG4SyncEventUserInfo >)> EventFactoryFunction
Definition
AtlasG4SyncEventUserInfo.h:57
AtlasG4SyncEventUserInfo::AtlasG4SyncEventUserInfo
AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine *, EventFactoryFunction &&, const EventContext &)
Definition
AtlasG4SyncEventUserInfo.cxx:14
AtlasG4SyncEventUserInfo::SyncInterface
SPSyncInterface SyncInterface() const
Definition
AtlasG4SyncEventUserInfo.h:74
AtlasG4SyncEventUserInfo::AthenaEventID
event_number_t AthenaEventID() const
Definition
AtlasG4SyncEventUserInfo.h:62
AtlasG4SyncEventUserInfo::SPSyncInterface
std::shared_ptr< G4EventSynchronizationInterface > SPSyncInterface
Definition
AtlasG4SyncEventUserInfo.h:58
AtlasG4SyncEventUserInfo::EventFactory
EventFactoryFunction EventFactory() const
Definition
AtlasG4SyncEventUserInfo.h:70
AtlasG4SyncEventUserInfo::m_event_factory
EventFactoryFunction m_event_factory
Definition
AtlasG4SyncEventUserInfo.h:82
AtlasG4SyncEventUserInfo::m_rng_engine
CLHEP::HepRandomEngine * m_rng_engine
Definition
AtlasG4SyncEventUserInfo.h:80
AtlasG4SyncEventUserInfo::HepRandomEngine
CLHEP::HepRandomEngine * HepRandomEngine()
Definition
AtlasG4SyncEventUserInfo.h:66
AtlasG4SyncEventUserInfo::m_sync_interface
SPSyncInterface m_sync_interface
Definition
AtlasG4SyncEventUserInfo.h:85
G4EventSynchronizationInterface
Definition
AtlasG4SyncEventUserInfo.h:28
G4EventSynchronizationInterface::EventStatus
EventStatus
Definition
AtlasG4SyncEventUserInfo.h:29
G4EventSynchronizationInterface::EventStatus::Size
@ Size
Definition
AtlasG4SyncEventUserInfo.h:32
G4EventSynchronizationInterface::EventStatus::Ready
@ Ready
Definition
AtlasG4SyncEventUserInfo.h:30
G4EventSynchronizationInterface::EventStatus::Done
@ Done
Definition
AtlasG4SyncEventUserInfo.h:31
G4EventSynchronizationInterface::m_cv
std::condition_variable m_cv
Definition
AtlasG4SyncEventUserInfo.h:50
G4EventSynchronizationInterface::EventAborted
bool EventAborted() const
Definition
AtlasG4SyncEventUserInfo.h:39
G4EventSynchronizationInterface::Status
EventStatus Status() const
Definition
AtlasG4SyncEventUserInfo.cxx:28
G4EventSynchronizationInterface::m_mutex
std::mutex m_mutex
Definition
AtlasG4SyncEventUserInfo.h:49
G4EventSynchronizationInterface::WaitStatusDone
void WaitStatusDone()
Definition
AtlasG4SyncEventUserInfo.h:38
G4EventSynchronizationInterface::WaitStatus
void WaitStatus(const EventStatus &)
Definition
AtlasG4SyncEventUserInfo.cxx:44
G4EventSynchronizationInterface::Complete
void Complete(bool eventAborted)
Mark all Geant4 processing for this event as complete and wake Athena.
Definition
AtlasG4SyncEventUserInfo.cxx:34
G4EventSynchronizationInterface::m_status
EventStatus m_status
Definition
AtlasG4SyncEventUserInfo.h:48
G4EventSynchronizationInterface::m_event_aborted
bool m_event_aborted
Definition
AtlasG4SyncEventUserInfo.h:47
CLHEP
STD'S.
Definition
CaloNoiseCompCondAlg.h:57
Generated on
for ATLAS Offline Software by
1.17.0