EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrClusterFittingAlgorithmFitterFunction.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrClusterFittingAlgorithmFitterFunction.cpp
2 
3 #include <iostream>
4 #include <map>
5 #include <random>
6 #include <stdexcept>
7 
20 #include "boost/program_options.hpp"
21 
23 
24 
28 namespace {
29 template <typename Fitter>
30 struct TrkrFitterFunctionImpl
31 {
32  Fitter fitter;
33 
34  TrkrFitterFunctionImpl(Fitter&& f) : fitter(std::move(f)) {}
35 
37  const std::vector<ActsExamples::TrkrClusterSourceLink>& sourceLinks,
38  const ActsExamples::TrackParameters& initialParameters,
40  {
41  return fitter.fit(sourceLinks, initialParameters, options);
42  };
43 };
44 
45 template <typename Fitter>
46 struct DirectedTrkrFitterFunctionImpl
47 {
48  Fitter fitter;
49 
50  DirectedTrkrFitterFunctionImpl(Fitter&& f) : fitter(std::move(f)) {}
51 
53  const std::vector<ActsExamples::TrkrClusterSourceLink>& sourceLinks,
54  const ActsExamples::TrackParameters& initialParameters,
56  const std::vector<const Acts::Surface*>& sSequence) const
57  {
58  return fitter.fit(sourceLinks, initialParameters, options, sSequence);
59  };
60 };
61 
62 } // namespace
63 
69  std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
71 {
72  using Updater = Acts::GainMatrixUpdater;
73  using Smoother = Acts::GainMatrixSmoother;
74 
76  return std::visit(
77  [trackingGeometry](auto&& inputField) -> FitterFunction {
79  using InputMagneticField = typename std::decay_t<decltype(inputField)>::element_type;
80  using MagneticField = Acts::SharedBField<InputMagneticField>;
82  using Navigator = Acts::Navigator;
85 
87  MagneticField field(std::move(inputField));
88  Stepper stepper(std::move(field));
89  Navigator navigator(trackingGeometry);
90  navigator.resolvePassive = false;
91  navigator.resolveMaterial = true;
92  navigator.resolveSensitive = true;
93  Propagator propagator(std::move(stepper), std::move(navigator));
94  Fitter fitter(std::move(propagator));
95 
97  return TrkrFitterFunctionImpl<Fitter>(std::move(fitter));
98  },
99  std::move(magneticField));
100 }
101 
102 
106 {
107  using Updater = Acts::GainMatrixUpdater;
108  using Smoother = Acts::GainMatrixSmoother;
109 
111  return std::visit(
112  [](auto&& inputField) -> DirectedFitterFunction {
114  using InputMagneticField = typename std::decay_t<decltype(inputField)>::element_type;
115  using MagneticField = Acts::SharedBField<InputMagneticField>;
117  using Navigator = Acts::DirectNavigator;
120 
122  MagneticField field(std::move(inputField));
123  Stepper stepper(std::move(field));
124  Navigator navigator;
125  Propagator propagator(std::move(stepper), std::move(navigator));
126  Fitter fitter(std::move(propagator));
127 
129  return DirectedTrkrFitterFunctionImpl<Fitter>(std::move(fitter));
130  },
131  std::move(magneticField));
132 }