ATLAS Offline Software
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4RunManagement
src
SyncPrimaryGeneratorAction.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
SyncPrimaryGeneratorAction.h
"
6
#include "GaudiKernel/StatusCode.h"
7
8
#include "
G4RunManagement/AtlasG4SyncEventUserInfo.h
"
9
10
#include "G4RunManager.hh"
11
#include "G4Event.hh"
12
#include "G4SystemOfUnits.hh"
13
#include "Randomize.hh"
14
15
namespace
G4UA
16
{
17
18
SyncPrimaryGeneratorAction::SyncPrimaryGeneratorAction
(
IG4RunTool
* g4RunTool)
19
: G4VUserPrimaryGeneratorAction(),
m_g4RunTool
(g4RunTool)
20
{
21
}
22
23
void
SyncPrimaryGeneratorAction::GeneratePrimaries
(G4Event* anEvent)
24
{
25
// get an event from the shared queue
26
if
(
auto
inputEventInfo =
m_g4RunTool
->GetEvent()) {
27
// setup rng engine seeded by Athena
28
G4Random::setTheEngine(inputEventInfo->HepRandomEngine());
29
// convert Genevent to G4Event
30
if
(inputEventInfo->EventFactory()(*anEvent, std::move(inputEventInfo)).isFailure()) {
31
G4cout <<
"Failed to prepare G4Event from Athena event"
<< G4endl;
32
}
33
}
34
// if get_Event returns nullptr, this means that no more events are available and the run should be aborted.
35
// Because Geant4 will still go through and finish the current event after calling AbortRun,
36
// and it reset the G4Event::Aborted flag after GeneratePrimaries, abortRun must be called in the BeginOfEventAction
37
}
38
39
}
// namespace G4UA
AtlasG4SyncEventUserInfo.h
SyncPrimaryGeneratorAction.h
G4UA::SyncPrimaryGeneratorAction::GeneratePrimaries
virtual void GeneratePrimaries(G4Event *) override
Definition
SyncPrimaryGeneratorAction.cxx:23
G4UA::SyncPrimaryGeneratorAction::SyncPrimaryGeneratorAction
SyncPrimaryGeneratorAction(IG4RunTool *)
Definition
SyncPrimaryGeneratorAction.cxx:18
G4UA::SyncPrimaryGeneratorAction::m_g4RunTool
IG4RunTool * m_g4RunTool
Definition
SyncPrimaryGeneratorAction.h:26
IG4RunTool
Provides an interface to interact with the Geant4 run.
Definition
IG4RunTool.h:22
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
Generated on
for ATLAS Offline Software by
1.14.0