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
;
36
void
SetStatusDone
() {
SetStatus
(
EventStatus::Done
);};
37
void
WaitStatusDone
() {
WaitStatus
(
EventStatus::Done
);};
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
};
46
EventStatus
m_status
{
EventStatus::Ready
};
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
52
class
AtlasG4SyncEventUserInfo
:
public
AtlasG4EventUserInfo
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
60
event_number_t
AthenaEventID
()
const
{
61
return
GetEventContext
().eventID().event_number();
62
}
63
64
CLHEP::HepRandomEngine*
HepRandomEngine
() {
65
return
m_rng_engine
;
66
}
67
68
EventFactoryFunction
EventFactory
()
const
{
69
return
m_event_factory
;
70
}
71
72
SPSyncInterface
SyncInterface
()
const
{
73
return
m_sync_interface
;
74
}
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
80
EventFactoryFunction
m_event_factory
;
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
83
SPSyncInterface
m_sync_interface
;
84
};
85
86
#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:55
AtlasG4SyncEventUserInfo::AtlasG4SyncEventUserInfo
AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine *, EventFactoryFunction &&, const EventContext &)
Definition
AtlasG4SyncEventUserInfo.cxx:14
AtlasG4SyncEventUserInfo::SyncInterface
SPSyncInterface SyncInterface() const
Definition
AtlasG4SyncEventUserInfo.h:72
AtlasG4SyncEventUserInfo::AthenaEventID
event_number_t AthenaEventID() const
Definition
AtlasG4SyncEventUserInfo.h:60
AtlasG4SyncEventUserInfo::SPSyncInterface
std::shared_ptr< G4EventSynchronizationInterface > SPSyncInterface
Definition
AtlasG4SyncEventUserInfo.h:56
AtlasG4SyncEventUserInfo::EventFactory
EventFactoryFunction EventFactory() const
Definition
AtlasG4SyncEventUserInfo.h:68
AtlasG4SyncEventUserInfo::m_event_factory
EventFactoryFunction m_event_factory
Definition
AtlasG4SyncEventUserInfo.h:80
AtlasG4SyncEventUserInfo::m_rng_engine
CLHEP::HepRandomEngine * m_rng_engine
Definition
AtlasG4SyncEventUserInfo.h:78
AtlasG4SyncEventUserInfo::HepRandomEngine
CLHEP::HepRandomEngine * HepRandomEngine()
Definition
AtlasG4SyncEventUserInfo.h:64
AtlasG4SyncEventUserInfo::m_sync_interface
SPSyncInterface m_sync_interface
Definition
AtlasG4SyncEventUserInfo.h:83
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:48
G4EventSynchronizationInterface::EventAborted
bool EventAborted() const
Definition
AtlasG4SyncEventUserInfo.h:38
G4EventSynchronizationInterface::EventAborted
void EventAborted(bool aborted)
Definition
AtlasG4SyncEventUserInfo.h:39
G4EventSynchronizationInterface::Status
EventStatus Status() const
Definition
AtlasG4SyncEventUserInfo.cxx:28
G4EventSynchronizationInterface::m_mutex
std::mutex m_mutex
Definition
AtlasG4SyncEventUserInfo.h:47
G4EventSynchronizationInterface::WaitStatusDone
void WaitStatusDone()
Definition
AtlasG4SyncEventUserInfo.h:37
G4EventSynchronizationInterface::SetStatus
void SetStatus(const EventStatus &)
Definition
AtlasG4SyncEventUserInfo.cxx:34
G4EventSynchronizationInterface::WaitStatus
void WaitStatus(const EventStatus &)
Definition
AtlasG4SyncEventUserInfo.cxx:43
G4EventSynchronizationInterface::m_status
EventStatus m_status
Definition
AtlasG4SyncEventUserInfo.h:46
G4EventSynchronizationInterface::SetStatusDone
void SetStatusDone()
Definition
AtlasG4SyncEventUserInfo.h:36
G4EventSynchronizationInterface::m_event_aborted
bool m_event_aborted
Definition
AtlasG4SyncEventUserInfo.h:45
CLHEP
STD'S.
Definition
CaloNoiseCompCondAlg.h:57
Generated on
for ATLAS Offline Software by
1.17.0