EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeantinoRecordingBase.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GeantinoRecordingBase.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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 #pragma once
10 
11 #include <boost/program_options.hpp>
12 
21 #include "G4VUserDetectorConstruction.hh"
22 
23 using namespace ActsExamples;
24 
28  const boost::program_options::variables_map& vm,
29  std::unique_ptr<G4VUserDetectorConstruction> g4detector) {
31  auto logLevel = Options::readLogLevel(vm);
32  auto outputDir = ensureWritableDirectory(vm["output-dir"].as<std::string>());
33 
34  // Setup the Geant4 algorithm
35  auto g4Config = Options::readGeantinoRecordingConfig(vm);
36  auto outputMaterialTracks = g4Config.outputMaterialTracks;
37  g4Config.detectorConstruction = std::move(g4detector);
38  sequencer.addAlgorithm(
39  std::make_shared<GeantinoRecording>(std::move(g4Config), logLevel));
40 
41  // setup the output writing
42  if (vm["output-root"].template as<bool>()) {
43  // Write the propagation steps as ROOT TTree
44  RootMaterialTrackWriter::Config materialTrackWriter;
45  materialTrackWriter.prePostStep = true;
46  materialTrackWriter.recalculateTotals = true;
47  materialTrackWriter.collection = outputMaterialTracks;
48  materialTrackWriter.filePath =
49  joinPaths(outputDir, outputMaterialTracks + ".root");
50  sequencer.addWriter(std::make_shared<RootMaterialTrackWriter>(
51  materialTrackWriter, logLevel));
52  }
53  return sequencer.run();
54 }