Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pythia8.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Pythia8.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 
19 
20 #include <cstdlib>
21 #include <memory>
22 
23 using namespace Acts::UnitLiterals;
24 using namespace ActsExamples;
25 
26 int main(int argc, char* argv[]) {
27  // setup and parse options
28  auto desc = Options::makeDefaultOptions();
32  Options::addOutputOptions(desc, OutputFormat::Csv | OutputFormat::Root);
33  auto vm = Options::parse(desc, argc, argv);
34  if (vm.empty()) {
35  return EXIT_FAILURE;
36  }
37 
40  Sequencer sequencer(sequencerCfg);
41 
42  // basic services
43  auto rnd =
44  std::make_shared<RandomNumbers>(Options::readRandomNumbersConfig(vm));
45 
46  // event generation w/ internal pythia8 instance
48  evgen.outputParticles = "particles";
49  evgen.randomNumbers = rnd;
50  sequencer.addReader(std::make_shared<EventGenerator>(evgen, logLevel));
51 
52  // print generated particles
56  print.inputParticles = evgen.outputParticles;
57  sequencer.addAlgorithm(std::make_shared<ParticlesPrinter>(print, logLevel));
58  }
59 
60  // different output modes
61  auto outputDir = ensureWritableDirectory(vm["output-dir"].as<std::string>());
62  if (vm["output-csv"].as<bool>()) {
63  CsvParticleWriter::Config csvWriter;
64  csvWriter.inputParticles = evgen.outputParticles;
65  csvWriter.outputDir = outputDir;
66  csvWriter.outputStem = "particles";
67  sequencer.addWriter(
68  std::make_shared<CsvParticleWriter>(csvWriter, logLevel));
69  }
70  if (vm["output-root"].as<bool>()) {
71  RootParticleWriter::Config rootWriter;
72  rootWriter.inputParticles = evgen.outputParticles;
73  rootWriter.filePath = joinPaths(outputDir, "particles.root");
74  sequencer.addWriter(
75  std::make_shared<RootParticleWriter>(rootWriter, logLevel));
76  }
77 
78  return sequencer.run();
79 }