Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParticleReaderVertexingExample.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ParticleReaderVertexingExample.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020-2021 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 
14 
28 
29 #include <memory>
30 
31 using namespace Acts::UnitLiterals;
32 using namespace ActsExamples;
33 
34 int main(int argc, char* argv[]) {
35  // setup and parse options
36  auto desc = Options::makeDefaultOptions();
43  Options::addOutputOptions(desc, OutputFormat::DirectoryOnly);
45  auto vars = Options::parse(desc, argc, argv);
46  if (vars.empty()) {
47  return EXIT_FAILURE;
48  }
49 
50  // basic setup
51  auto logLevel = Options::readLogLevel(vars);
52  auto rnd =
53  std::make_shared<RandomNumbers>(Options::readRandomNumbersConfig(vars));
54  Sequencer sequencer(Options::readSequencerConfig(vars));
55 
56  // Setup the magnetic field
58 
59  // setup particle reader generator
60  CsvParticleReader::Config readParticles =
62  readParticles.inputStem = "particles";
63  readParticles.outputParticles = "particles";
64  sequencer.addReader(
65  std::make_shared<CsvParticleReader>(readParticles, logLevel));
66 
67  // pre-select particles
68  ParticleSelector::Config selectParticles =
70  selectParticles.inputParticles = readParticles.outputParticles;
71  selectParticles.outputParticles = "particles_selected";
72  // smearing only works with charge particles for now
73  selectParticles.removeNeutral = true;
74  selectParticles.absEtaMax = vars["vertexing-eta-max"].as<double>();
75  selectParticles.rhoMax = vars["vertexing-rho-max"].as<double>() * 1_mm;
76  selectParticles.ptMin = vars["vertexing-pt-min"].as<double>() * 1_MeV;
77  sequencer.addAlgorithm(
78  std::make_shared<ParticleSelector>(selectParticles, logLevel));
79 
80  // Run the particle smearing
81  auto particleSmearingCfg = setupParticleSmearing(
82  vars, sequencer, rnd, selectParticles.outputParticles);
83 
84  // print input track parameters
86  printTracks.inputTrackParameters = particleSmearingCfg.outputTrackParameters;
87  sequencer.addAlgorithm(
88  std::make_shared<TrackParametersPrinter>(printTracks, logLevel));
89 
90  // find vertices
92  findVertices.bField = magneticField;
93  findVertices.inputTrackParameters = particleSmearingCfg.outputTrackParameters;
94  findVertices.outputProtoVertices = "protovertices";
95  sequencer.addAlgorithm(
96  std::make_shared<IterativeVertexFinderAlgorithm>(findVertices, logLevel));
97 
98  return sequencer.run();
99 }