Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventRecordingExample.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventRecordingExample.cpp
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 
24 
25 #include <fstream>
26 #include <string>
27 
28 #include <boost/program_options.hpp>
29 
30 int main(int argc, char* argv[]) {
31  // Declare the supported program options.
32  // Setup and parse options
36  desc, ActsExamples::OutputFormat::DirectoryOnly);
41 
42  auto vm = ActsExamples::Options::parse(desc, argc, argv);
43  if (vm.empty()) {
44  return EXIT_FAILURE;
45  }
46 
48 
49  ActsExamples::Sequencer sequencer(
51 
52  // Read particles (initial states) and clusters from CSV files
54  particleReader.inputStem = "particles";
55  particleReader.outputParticles = "particles";
56  sequencer.addReader(std::make_shared<ActsExamples::CsvParticleReader>(
57  particleReader, logLevel));
58 
59  // Prepare the detector
60  auto dd4hepCfg = ActsExamples::Options::readDD4hepConfig(vm);
61  auto geometrySvc =
62  std::make_shared<ActsExamples::DD4hep::DD4hepGeometryService>(dd4hepCfg);
63  auto detector =
64  std::make_shared<ActsExamples::DD4hep::DD4hepDetector>(geometrySvc);
65 
66  // Prepare the recording
68  erConfig.inputParticles = particleReader.outputParticles;
69  erConfig.outputHepMcTracks = "geant-event";
70  erConfig.detectorConstructionFactory =
71  std::make_unique<ActsExamples::DDG4DetectorConstructionFactory>(detector);
72  erConfig.seed1 = vm["g4-rnd-seed1"].as<unsigned int>();
73  erConfig.seed2 = vm["g4-rnd-seed2"].as<unsigned int>();
74 
75  // Create the writer
76  auto hepMC3WriterConfig = ActsExamples::Options::readHepMC3WriterOptions(vm);
77  hepMC3WriterConfig.inputEvents = erConfig.outputHepMcTracks;
78 
79  // Add to the sequencer
80  sequencer.addAlgorithm(std::make_shared<ActsExamples::EventRecording>(
81  std::move(erConfig), logLevel));
82  sequencer.addWriter(std::make_shared<ActsExamples::HepMC3AsciiWriter>(
83  std::move(hepMC3WriterConfig), logLevel));
84 
85  // Run
86  return sequencer.run();
87 }