ECCE @ 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 
9 #include <boost/program_options.hpp>
10 #include <iostream>
11 #include <map>
12 #include <random>
13 #include <stdexcept>
14 
29 
30 namespace {
31 template <typename Fitter>
32 struct FitterFunctionImpl {
33  Fitter fitter;
34 
35  FitterFunctionImpl(Fitter&& f) : fitter(std::move(f)) {}
36 
38  const std::vector<FW::SimSourceLink>& sourceLinks,
39  const FW::TrackParameters& initialParameters,
41  return fitter.fit(sourceLinks, initialParameters, options);
42  };
43 };
44 } // namespace
45 
47  std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
48  Options::BFieldVariant magneticField, Acts::Logging::Level lvl) {
51 
52  // unpack the magnetic field variant and instantiate the corresponding fitter.
53  return std::visit(
54  [trackingGeometry, lvl](auto&& inputField) -> FitterFunction {
55  // each entry in the variant is already a shared_ptr
56  // need ::element_type to get the real magnetic field type
57  using InputMagneticField =
58  typename std::decay_t<decltype(inputField)>::element_type;
59  using MagneticField = Acts::SharedBField<InputMagneticField>;
61  using Navigator = Acts::Navigator;
64 
65  // construct all components for the fitter
66  MagneticField field(std::move(inputField));
67  Stepper stepper(std::move(field));
68  Navigator navigator(trackingGeometry);
69  navigator.resolvePassive = false;
70  navigator.resolveMaterial = true;
71  navigator.resolveSensitive = true;
72  Propagator propagator(std::move(stepper), std::move(navigator));
73  Fitter fitter(std::move(propagator),
74  Acts::getDefaultLogger("KalmanFitter", lvl));
75 
76  // build the fitter functions. owns the fitter object.
77  return FitterFunctionImpl<Fitter>(std::move(fitter));
78  },
79  std::move(magneticField));
80 }