EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FittingAlgorithmFitterFunction.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FittingAlgorithmFitterFunction.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 
23 
24 #include <iostream>
25 #include <map>
26 #include <random>
27 #include <stdexcept>
28 
29 #include <boost/program_options.hpp>
30 
31 namespace {
32 template <typename Fitter>
33 struct FitterFunctionImpl {
34  Fitter fitter;
35 
36  FitterFunctionImpl(Fitter&& f) : fitter(std::move(f)) {}
37 
39  const std::vector<ActsExamples::SimSourceLink>& sourceLinks,
40  const ActsExamples::TrackParameters& initialParameters,
42  return fitter.fit(sourceLinks, initialParameters, options);
43  };
44 };
45 } // namespace
46 
49  std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
51  using Updater = Acts::GainMatrixUpdater;
52  using Smoother = Acts::GainMatrixSmoother;
53 
54  // unpack the magnetic field variant and instantiate the corresponding fitter.
55  return std::visit(
56  [trackingGeometry](auto&& inputField) -> FitterFunction {
57  // each entry in the variant is already a shared_ptr
58  // need ::element_type to get the real magnetic field type
59  using InputMagneticField =
60  typename std::decay_t<decltype(inputField)>::element_type;
61  using MagneticField = Acts::SharedBField<InputMagneticField>;
63  using Navigator = Acts::Navigator;
66 
67  // construct all components for the fitter
68  MagneticField field(std::move(inputField));
69  Stepper stepper(std::move(field));
70  Navigator navigator(trackingGeometry);
71  navigator.resolvePassive = false;
72  navigator.resolveMaterial = true;
73  navigator.resolveSensitive = true;
74  Propagator propagator(std::move(stepper), std::move(navigator));
75  Fitter fitter(std::move(propagator));
76 
77  // build the fitter functions. owns the fitter object.
78  return FitterFunctionImpl<Fitter>(std::move(fitter));
79  },
80  std::move(magneticField));
81 }