forked from sPHENIX-Collaboration/acts
/
GeantinoRecordingBase.hpp
54 lines (47 loc) · 2.11 KB
/
GeantinoRecordingBase.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include <boost/program_options.hpp>
#include "ActsExamples/Framework/RandomNumbers.hpp"
#include "ActsExamples/Framework/Sequencer.hpp"
#include "ActsExamples/Geant4/Geant4Options.hpp"
#include "ActsExamples/Geant4/GeantinoRecording.hpp"
#include "ActsExamples/Io/Root/RootMaterialTrackWriter.hpp"
#include "ActsExamples/Io/Root/RootSimHitWriter.hpp"
#include "ActsExamples/Options/CommonOptions.hpp"
#include "ActsExamples/Utilities/Paths.hpp"
#include "G4VUserDetectorConstruction.hh"
using namespace ActsExamples;
/// @brief method to process a geometry
/// @param detector The detector descriptor instance
inline int runGeantinoRecording(
const boost::program_options::variables_map& vm,
std::unique_ptr<G4VUserDetectorConstruction> g4detector) {
Sequencer sequencer(Options::readSequencerConfig(vm));
auto logLevel = Options::readLogLevel(vm);
auto outputDir = ensureWritableDirectory(vm["output-dir"].as<std::string>());
// Setup the Geant4 algorithm
auto g4Config = Options::readGeantinoRecordingConfig(vm);
auto outputMaterialTracks = g4Config.outputMaterialTracks;
g4Config.detectorConstruction = std::move(g4detector);
sequencer.addAlgorithm(
std::make_shared<GeantinoRecording>(std::move(g4Config), logLevel));
// setup the output writing
if (vm["output-root"].template as<bool>()) {
// Write the propagation steps as ROOT TTree
RootMaterialTrackWriter::Config materialTrackWriter;
materialTrackWriter.prePostStep = true;
materialTrackWriter.recalculateTotals = true;
materialTrackWriter.collection = outputMaterialTracks;
materialTrackWriter.filePath =
joinPaths(outputDir, outputMaterialTracks + ".root");
sequencer.addWriter(std::make_shared<RootMaterialTrackWriter>(
materialTrackWriter, logLevel));
}
return sequencer.run();
}