Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PropagatorInterface.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PropagatorInterface.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 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 #pragma once
10 
13 
14 namespace ActsExamples {
15 
23  public:
24  virtual ~PropagatorInterface() = default;
25 
33  virtual PropagationOutput execute(
34  const AlgorithmContext& context, const PropagationAlgorithm::Config& cfg,
35  const Acts::Logger& logger,
36  const Acts::BoundTrackParameters& startParameters) const = 0;
37 };
38 
50 template <typename propagator_t>
52  public:
54  : m_propagator{std::move(propagator)} {}
55 
57  const AlgorithmContext& context, const PropagationAlgorithm::Config& cfg,
58  const Acts::Logger& logger,
59  const Acts::BoundTrackParameters& startParameters) const override {
60  return executeTest(context, cfg, logger, startParameters);
61  }
62 
63  private:
69  template <typename parameters_t>
70  PropagationOutput executeTest(
71  const AlgorithmContext& context, const PropagationAlgorithm::Config& cfg,
72  const Acts::Logger& logger, const parameters_t& startParameters,
73  double pathLength = std::numeric_limits<double>::max()) const {
74  ACTS_DEBUG("Test propagation/extrapolation starts");
75 
76  PropagationOutput pOutput;
77 
78  // This is the outside in mode
79  if (cfg.mode == 0) {
80  // The step length logger for testing & end of world aborter
81  using MaterialInteractor = Acts::MaterialInteractor;
82  using SteppingLogger = Acts::detail::SteppingLogger;
83  using EndOfWorld = Acts::EndOfWorldReached;
84 
85  // Action list and abort list
86  using ActionList = Acts::ActionList<SteppingLogger, MaterialInteractor>;
87  using AbortList = Acts::AbortList<EndOfWorld>;
88  using PropagatorOptions =
90 
91  PropagatorOptions options(context.geoContext, context.magFieldContext);
92  options.pathLimit = pathLength;
93 
94  // Activate loop protection at some pt value
95  options.loopProtection =
96  startParameters.transverseMomentum() < cfg.ptLoopers;
97 
98  // Switch the material interaction on/off & eventually into logging mode
99  auto& mInteractor = options.actionList.get<MaterialInteractor>();
100  mInteractor.multipleScattering = cfg.multipleScattering;
101  mInteractor.energyLoss = cfg.energyLoss;
102  mInteractor.recordInteractions = cfg.recordMaterialInteractions;
103 
104  // Switch the logger to sterile, e.g. for timing checks
105  auto& sLogger = options.actionList.get<SteppingLogger>();
106  sLogger.sterile = cfg.sterileLogger;
107  // Set a maximum step size
108  options.maxStepSize = cfg.maxStepSize;
109 
110  // Propagate using the propagator
111  auto result = m_propagator.propagate(startParameters, options);
112  if (result.ok()) {
113  const auto& resultValue = result.value();
114  auto steppingResults =
115  resultValue.template get<SteppingLogger::result_type>();
116 
117  // Set the stepping result
118  pOutput.first = std::move(steppingResults.steps);
119  // Also set the material recording result - if configured
120  if (cfg.recordMaterialInteractions) {
121  auto materialResult =
122  resultValue.template get<MaterialInteractor::result_type>();
123  pOutput.second = std::move(materialResult);
124  }
125  }
126  }
127  return pOutput;
128  }
129 
130  private:
131  propagator_t m_propagator;
132 };
133 
134 } // namespace ActsExamples