ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexAndTracksReaderAndFinderExample.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexAndTracksReaderAndFinderExample.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 
18 
19 using namespace FW;
20 
25 int main(int argc, char* argv[]) {
26  using namespace boost::program_options;
27  // setup and parse options
31  desc.add_options()("input", value<std::string>()->default_value(""),
32  "Input root file to read.");
33  auto vm = Options::parse(desc, argc, argv);
34 
35  if (vm.empty()) {
36  return EXIT_FAILURE;
37  }
38 
39  auto logLevel = Options::readLogLevel(vm);
40 
41  // Set file to read data from
42  std::string fileString = vm["input"].template as<std::string>();
43 
44  if (fileString.empty()) {
45  std::cout << "Error: Input file not set." << std::endl;
46  return EXIT_FAILURE;
47  }
48 
49  RootVertexAndTracksReader::Config vtxAndTracksReaderCfg;
50  vtxAndTracksReaderCfg.fileList.push_back(fileString);
51 
52  // Set magnetic field
54 
55  // Add the finding algorithm
56  FWE::VertexFindingAlgorithm::Config vertexFindingCfg;
57  vertexFindingCfg.trackCollection = vtxAndTracksReaderCfg.outputCollection;
58  vertexFindingCfg.bField = bField;
59 
61  Sequencer sequencer(sequencerCfg);
62 
63  sequencer.addReader(std::make_shared<RootVertexAndTracksReader>(
64  vtxAndTracksReaderCfg, logLevel));
65 
66  sequencer.addAlgorithm(std::make_shared<FWE::VertexFindingAlgorithm>(
67  vertexFindingCfg, logLevel));
68 
69  return sequencer.run();
70 }