EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
GeantinoRecording.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file GeantinoRecording.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2017-2020 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#include "
ActsExamples/Geant4/GeantinoRecording.hpp
"
10
11
#include "
ActsExamples/Framework/WhiteBoard.hpp
"
12
13
#include <iostream>
14
#include <stdexcept>
15
16
#include <FTFP_BERT.hh>
17
#include <G4RunManager.hh>
18
#include <G4VUserDetectorConstruction.hh>
19
20
#include "
EventAction.hpp
"
21
#include "
RunAction.hpp
"
22
#include "
SteppingAction.hpp
"
23
24
using namespace
ActsExamples;
25
26
GeantinoRecording::GeantinoRecording
(
GeantinoRecording::Config
&& cfg,
27
Acts::Logging::Level
lvl)
28
:
BareAlgorithm
(
"GeantinoRecording"
, lvl),
29
m_cfg(std::move(cfg)),
30
m_runManager(std::make_unique<G4RunManager>()) {
31
if
(
m_cfg
.
outputMaterialTracks
.empty()) {
32
throw
std::invalid_argument(
"Missing output material tracks collection"
);
33
}
34
if
(not
m_cfg
.
detectorConstruction
) {
35
throw
std::invalid_argument(
"Missing detector construction object"
);
36
}
37
38
m_cfg
.
generationConfig
.
particleName
=
"geantino"
;
39
m_cfg
.
generationConfig
.
energy
= 1000.;
40
41
m_runManager
->SetUserInitialization(
m_cfg
.
detectorConstruction
.release());
42
m_runManager
->SetUserInitialization(
new
FTFP_BERT);
43
m_runManager
->SetUserAction(
new
RunAction
());
44
m_runManager
->SetUserAction(
new
EventAction
());
45
m_runManager
->SetUserAction(
46
new
PrimaryGeneratorAction
(
m_cfg
.
generationConfig
));
47
m_runManager
->SetUserAction(
new
SteppingAction
());
48
m_runManager
->Initialize();
49
}
50
51
// needed to allow std::unique_ptr<G4RunManager> with forward-declared class.
52
GeantinoRecording::~GeantinoRecording
() {}
53
54
ActsExamples::ProcessCode
GeantinoRecording::execute
(
55
const
ActsExamples::AlgorithmContext
& ctx)
const
{
56
// ensure exclusive access to the geant run manager
57
std::lock_guard<std::mutex> guard(
m_runManagerLock
);
58
59
// TODO use framework random numbers directly or at least context seed
60
// TODO take particles collection as input instead of generating them
61
62
// start simulation. each track is simulated as a separate Geant4 event.
63
m_runManager
->BeamOn(
m_cfg
.
tracksPerEvent
);
64
65
auto
materialTracks =
EventAction::instance
()->
materialTracks
();
66
// Write the recorded material to the event store
67
ctx.
eventStore
.
add
(
m_cfg
.
outputMaterialTracks
, move(materialTracks));
68
69
return
ActsExamples::ProcessCode::SUCCESS
;
70
}
acts
blob
sPHENIX
Examples
Algorithms
Geant4
src
GeantinoRecording.cpp
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:24
using
1.8.2 with
EIC GitHub integration