Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowParticles.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ShowParticles.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 
12 
21 
22 #include <memory>
23 
24 #include <boost/program_options.hpp>
25 
26 using namespace ActsExamples;
28 
29 int main(int argc, char* argv[]) {
30  // setup and parse options
31  auto desc = Options::makeDefaultOptions("Read and print particles CSVs");
32  auto opts = desc.add_options();
34  opts("input-dir", value<std::string>()->default_value(""), "");
35  opts("input-stem", value<std::string>()->default_value("particles"), "");
37  auto vars = Options::parse(desc, argc, argv);
38  if (vars.empty()) {
39  return EXIT_FAILURE;
40  }
41 
42  Sequencer sequencer(Options::readSequencerConfig(vars));
43 
44  // read options
45  auto logLevel = Options::readLogLevel(vars);
46  auto inputDir = vars["input-dir"].as<std::string>();
47  auto inputStem = vars["input-stem"].as<std::string>();
48 
49  // read particles
50  CsvParticleReader::Config readParticlesCfg;
51  readParticlesCfg.inputDir = inputDir;
52  readParticlesCfg.inputStem = inputStem;
53  readParticlesCfg.outputParticles = "particles";
54  sequencer.addReader(
55  std::make_shared<CsvParticleReader>(readParticlesCfg, logLevel));
56 
57  // pre-select particles
58  auto selectParticlesCfg =
60  selectParticlesCfg.inputParticles = readParticlesCfg.outputParticles;
61  selectParticlesCfg.outputParticles = "particles_selected";
62  sequencer.addAlgorithm(
63  std::make_shared<ParticleSelector>(selectParticlesCfg, logLevel));
64 
65  // print selected particles
66  ParticlesPrinter::Config printParticlesCfg;
67  printParticlesCfg.inputParticles = selectParticlesCfg.outputParticles;
68  sequencer.addAlgorithm(
69  std::make_shared<ParticlesPrinter>(printParticlesCfg, logLevel));
70 
71  return sequencer.run();
72 }