Analysis Software
Documentation for sPHENIX simulation 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 
21 
22 #include <memory>
23 
24 using namespace Acts::UnitLiterals;
25 using namespace ActsExamples;
26 
27 int main(int argc, char* argv[]) {
28  // setup and parse options
29  auto desc = Options::makeDefaultOptions();
36  Options::addOutputOptions(desc, OutputFormat::DirectoryOnly);
38  auto vars = Options::parse(desc, argc, argv);
39  if (vars.empty()) {
40  return EXIT_FAILURE;
41  }
42 
43  // basic setup
44  auto logLevel = Options::readLogLevel(vars);
45  auto rnd =
46  std::make_shared<RandomNumbers>(Options::readRandomNumbersConfig(vars));
47  Sequencer sequencer(Options::readSequencerConfig(vars));
48 
49  // Setup the magnetic field
51 
52  // setup event generator
54  evgen.outputParticles = "particles_generated";
55  evgen.randomNumbers = rnd;
56  sequencer.addReader(std::make_shared<EventGenerator>(evgen, logLevel));
57 
58  // pre-select particles
59  ParticleSelector::Config selectParticles =
61  selectParticles.inputParticles = evgen.outputParticles;
62  selectParticles.outputParticles = "particles_selected";
63  // smearing only works with charge particles for now
64  selectParticles.removeNeutral = true;
65  selectParticles.absEtaMax = vars["vertexing-eta-max"].as<double>();
66  selectParticles.rhoMax = vars["vertexing-rho-max"].as<double>() * 1_mm;
67  selectParticles.ptMin = vars["vertexing-pt-min"].as<double>() * 1_MeV;
68  sequencer.addAlgorithm(
69  std::make_shared<ParticleSelector>(selectParticles, logLevel));
70 
71  // Run the particle smearing
72  auto particleSmearingCfg = setupParticleSmearing(
73  vars, sequencer, rnd, selectParticles.outputParticles);
74 
75  // find true primary vertices w/o secondary particles
76  TruthVertexFinder::Config findVertices;
77  findVertices.inputParticles = selectParticles.outputParticles;
78  findVertices.outputProtoVertices = "protovertices";
79  findVertices.excludeSecondaries = true;
80  sequencer.addAlgorithm(
81  std::make_shared<TruthVertexFinder>(findVertices, logLevel));
82 
83  // fit vertices using the Billoir fitter
85  fitVertices.bField = magneticField;
86  fitVertices.inputTrackParameters = particleSmearingCfg.outputTrackParameters;
87  fitVertices.inputProtoVertices = findVertices.outputProtoVertices;
88  sequencer.addAlgorithm(
89  std::make_shared<VertexFitterAlgorithm>(fitVertices, logLevel));
90 
91  return sequencer.run();
92 }