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-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
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
enum class
EventOutcome
{
36
Success
,
37
Aborted
,
38
PreparationFailed
,
39
RunTerminated
40
};
41
42
EventStatus
Status
()
const
;
44
void
Complete
(
EventOutcome
outcome)
noexcept
;
45
void
WaitStatusDone
() {
WaitStatus
(
EventStatus::Done
);};
46
EventOutcome
Outcome
()
const
;
47
48
private
:
49
void
WaitStatus
(
const
EventStatus
&);
50
51
EventOutcome
m_outcome
{
EventOutcome::Success
};
52
EventStatus
m_status
{
EventStatus::Ready
};
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
58
class
AtlasG4SyncEventUserInfo
:
public
AtlasG4EventUserInfo
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
66
event_number_t
AthenaEventID
()
const
{
67
return
GetEventContext
().eventID().event_number();
68
}
69
70
CLHEP::HepRandomEngine*
HepRandomEngine
() {
71
return
m_rng_engine
;
72
}
73
74
const
EventFactoryFunction
&
EventFactory
()
const
{
75
return
m_event_factory
;
76
}
77
78
void
SetEventPreparationFailed
() {
79
m_event_preparation_failed
=
true
;
80
}
81
82
bool
EventPreparationFailed
()
const
{
83
return
m_event_preparation_failed
;
84
}
85
86
SPSyncInterface
SyncInterface
()
const
{
87
return
m_sync_interface
;
88
}
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
94
EventFactoryFunction
m_event_factory
;
95
// Set on the Geant4 worker if the event factory returns failure.
96
bool
m_event_preparation_failed
{
false
};
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
99
SPSyncInterface
m_sync_interface
;
100
};
101
102
#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::AtlasG4SyncEventUserInfo
AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine *, EventFactoryFunction &&, const EventContext &)
Definition
AtlasG4SyncEventUserInfo.cxx:14
AtlasG4SyncEventUserInfo::EventPreparationFailed
bool EventPreparationFailed() const
Definition
AtlasG4SyncEventUserInfo.h:82
AtlasG4SyncEventUserInfo::EventFactoryFunction
std::function< StatusCode(G4Event &)> EventFactoryFunction
Definition
AtlasG4SyncEventUserInfo.h:61
AtlasG4SyncEventUserInfo::SyncInterface
SPSyncInterface SyncInterface() const
Definition
AtlasG4SyncEventUserInfo.h:86
AtlasG4SyncEventUserInfo::m_event_preparation_failed
bool m_event_preparation_failed
Definition
AtlasG4SyncEventUserInfo.h:96
AtlasG4SyncEventUserInfo::AthenaEventID
event_number_t AthenaEventID() const
Definition
AtlasG4SyncEventUserInfo.h:66
AtlasG4SyncEventUserInfo::SPSyncInterface
std::shared_ptr< G4EventSynchronizationInterface > SPSyncInterface
Definition
AtlasG4SyncEventUserInfo.h:62
AtlasG4SyncEventUserInfo::m_event_factory
EventFactoryFunction m_event_factory
Definition
AtlasG4SyncEventUserInfo.h:94
AtlasG4SyncEventUserInfo::m_rng_engine
CLHEP::HepRandomEngine * m_rng_engine
Definition
AtlasG4SyncEventUserInfo.h:92
AtlasG4SyncEventUserInfo::HepRandomEngine
CLHEP::HepRandomEngine * HepRandomEngine()
Definition
AtlasG4SyncEventUserInfo.h:70
AtlasG4SyncEventUserInfo::EventFactory
const EventFactoryFunction & EventFactory() const
Definition
AtlasG4SyncEventUserInfo.h:74
AtlasG4SyncEventUserInfo::m_sync_interface
SPSyncInterface m_sync_interface
Definition
AtlasG4SyncEventUserInfo.h:99
AtlasG4SyncEventUserInfo::SetEventPreparationFailed
void SetEventPreparationFailed()
Definition
AtlasG4SyncEventUserInfo.h:78
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:54
G4EventSynchronizationInterface::Status
EventStatus Status() const
Definition
AtlasG4SyncEventUserInfo.cxx:28
G4EventSynchronizationInterface::m_mutex
std::mutex m_mutex
Definition
AtlasG4SyncEventUserInfo.h:53
G4EventSynchronizationInterface::m_outcome
EventOutcome m_outcome
Definition
AtlasG4SyncEventUserInfo.h:51
G4EventSynchronizationInterface::WaitStatusDone
void WaitStatusDone()
Definition
AtlasG4SyncEventUserInfo.h:45
G4EventSynchronizationInterface::WaitStatus
void WaitStatus(const EventStatus &)
Definition
AtlasG4SyncEventUserInfo.cxx:56
G4EventSynchronizationInterface::Outcome
EventOutcome Outcome() const
Definition
AtlasG4SyncEventUserInfo.cxx:34
G4EventSynchronizationInterface::EventOutcome
EventOutcome
Definition
AtlasG4SyncEventUserInfo.h:35
G4EventSynchronizationInterface::EventOutcome::Success
@ Success
Definition
AtlasG4SyncEventUserInfo.h:36
G4EventSynchronizationInterface::EventOutcome::Aborted
@ Aborted
Definition
AtlasG4SyncEventUserInfo.h:37
G4EventSynchronizationInterface::EventOutcome::RunTerminated
@ RunTerminated
Definition
AtlasG4SyncEventUserInfo.h:39
G4EventSynchronizationInterface::EventOutcome::PreparationFailed
@ PreparationFailed
Definition
AtlasG4SyncEventUserInfo.h:38
G4EventSynchronizationInterface::Complete
void Complete(EventOutcome outcome) noexcept
Record the first completion outcome and wake Athena.
Definition
AtlasG4SyncEventUserInfo.cxx:40
G4EventSynchronizationInterface::m_status
EventStatus m_status
Definition
AtlasG4SyncEventUserInfo.h:52
CLHEP
STD'S.
Definition
CaloNoiseCompCondAlg.h:57
Generated on
for ATLAS Offline Software by
1.17.0