EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexFitterExample.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexFitterExample.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-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 
17 
18 #include <memory>
19 
20 using namespace Acts::UnitLiterals;
21 using namespace ActsExamples;
22 
23 int main(int argc, char* argv[]) {
24  // setup and parse options
25  auto desc = Options::makeDefaultOptions();
29  ParticleSelector::addOptions(desc);
31  auto vars = Options::parse(desc, argc, argv);
32  if (vars.empty()) {
33  return EXIT_FAILURE;
34  }
35 
36  // basic setup
37  auto logLevel = Options::readLogLevel(vars);
38  auto rnd =
39  std::make_shared<RandomNumbers>(Options::readRandomNumbersConfig(vars));
40  Sequencer sequencer(Options::readSequencerConfig(vars));
41 
42  // setup event generator
44  evgen.outputParticles = "particles_generated";
45  evgen.randomNumbers = rnd;
46  sequencer.addReader(std::make_shared<EventGenerator>(evgen, logLevel));
47 
48  // pre-select particles
49  ParticleSelector::Config selectParticles = ParticleSelector::readConfig(vars);
50  selectParticles.inputParticles = evgen.outputParticles;
51  selectParticles.outputParticles = "particles_selected";
52  // smearing only works with charge particles for now
53  selectParticles.removeNeutral = true;
54  sequencer.addAlgorithm(
55  std::make_shared<ParticleSelector>(selectParticles, logLevel));
56 
57  // simulate track reconstruction by smearing truth track parameters
58  ParticleSmearing::Config smearParticles;
59  smearParticles.inputParticles = selectParticles.outputParticles;
60  smearParticles.outputTrackParameters = "trackparameters";
61  smearParticles.randomNumbers = rnd;
62  sequencer.addAlgorithm(
63  std::make_shared<ParticleSmearing>(smearParticles, logLevel));
64 
65  // find true primary vertices w/o secondary particles
66  TruthVertexFinder::Config findVertices;
67  findVertices.inputParticles = selectParticles.outputParticles;
68  findVertices.outputProtoVertices = "protovertices";
69  findVertices.excludeSecondaries = true;
70  sequencer.addAlgorithm(
71  std::make_shared<TruthVertexFinder>(findVertices, logLevel));
72 
73  // fit vertices using the Billoir fitter
75  fitVertices.inputTrackParameters = smearParticles.outputTrackParameters;
76  fitVertices.inputProtoVertices = findVertices.outputProtoVertices;
77  fitVertices.bField = Acts::Vector3D(0_T, 0_T, 2_T);
78  sequencer.addAlgorithm(
79  std::make_shared<VertexFitterAlgorithm>(fitVertices, logLevel));
80 
81  return sequencer.run();
82 }