ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexAndTracksWriterExample.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexAndTracksWriterExample.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 
10 #include <boost/program_options.hpp>
11 #include <memory>
12 
25 
26 using namespace FW;
27 using namespace Acts::UnitLiterals;
28 
33 int main(int argc, char* argv[]) {
34  // setup and parse options
40  auto vm = Options::parse(desc, argc, argv);
41  if (vm.empty()) {
42  return EXIT_FAILURE;
43  }
44 
45  // basic setup
46  auto logLevel = Options::readLogLevel(vm);
47  auto rnd =
48  std::make_shared<RandomNumbers>(Options::readRandomNumbersConfig(vm));
50 
51  // Set up event generator
53  evgen.output = "event";
54  evgen.randomNumbers = rnd;
55  sequencer.addReader(std::make_shared<EventGenerator>(evgen, logLevel));
56 
57  ParticleSelector::Config selectParticles;
58  selectParticles.inputEvent = evgen.output;
59  selectParticles.outputEvent = "event_selected";
60  selectParticles.absEtaMax = 2.5;
61  selectParticles.rhoMax = 4_mm;
62  selectParticles.ptMin = 400_MeV;
63  selectParticles.removeNeutral = true;
64  sequencer.addAlgorithm(
65  std::make_shared<ParticleSelector>(selectParticles, logLevel));
66 
68  trkConvConfig.input = selectParticles.outputEvent;
69  trkConvConfig.output = "tracks";
70  trkConvConfig.doSmearing = true;
71  trkConvConfig.randomNumberSvc = rnd;
72  trkConvConfig.bField = {0_T, 0_T, 1_T};
73  sequencer.addAlgorithm(std::make_shared<TruthVerticesToTracksAlgorithm>(
74  trkConvConfig, logLevel));
75 
76  // Set up track selector
77  TrackSelector::Config selectorConfig;
78  selectorConfig.input = trkConvConfig.output;
79  selectorConfig.output = "tracks_selected";
80  selectorConfig.absEtaMax = 2.5;
81  selectorConfig.rhoMax = 4_mm;
82  selectorConfig.ptMin = 400_MeV;
83  selectorConfig.keepNeutral = false;
84  sequencer.addAlgorithm(
85  std::make_shared<TrackSelector>(selectorConfig, logLevel));
86 
87  auto outputDir = ensureWritableDirectory(vm["output-dir"].as<std::string>());
88 
90  writerCfg.collection = selectorConfig.output;
91  writerCfg.filePath = joinPaths(outputDir, selectorConfig.output + ".root");
92  sequencer.addWriter(
93  std::make_shared<RootVertexAndTracksWriter>(writerCfg, logLevel));
94 
95  return sequencer.run();
96 }