EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingLogger.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SteppingLogger.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 
14 
15 #include <memory>
16 #include <vector>
17 
18 namespace Acts {
19 
20 class Surface;
21 class Layer;
22 class TrackingVolume;
23 
24 namespace detail {
25 
27 struct Step {
29  Vector3D position = Vector3D(0., 0., 0.);
30  Vector3D momentum = Vector3D(0., 0., 0.);
31  std::shared_ptr<const Surface> surface = nullptr;
32  const TrackingVolume* volume = nullptr;
33 };
34 
40  struct this_result {
41  std::vector<Step> steps;
42  };
43 
45 
47  bool sterile = false;
48 
56  template <typename propagator_state_t, typename stepper_t>
57  void operator()(propagator_state_t& state, const stepper_t& stepper,
58  result_type& result) const {
59  // don't log if you have reached the target
60  if (sterile or state.navigation.targetReached) {
61  return;
62  }
63  // record the propagation state
64  Step step;
65  step.stepSize = state.stepping.stepSize;
66  step.position = stepper.position(state.stepping);
67  step.momentum =
68  stepper.momentum(state.stepping) * stepper.direction(state.stepping);
69 
70  if (state.navigation.currentSurface != nullptr) {
71  // hang on to surface
72  step.surface = state.navigation.currentSurface->getSharedPtr();
73  }
74 
75  step.volume = state.navigation.currentVolume;
76  result.steps.push_back(std::move(step));
77  }
78 
81  template <typename propagator_state_t, typename stepper_t>
82  void operator()(propagator_state_t& /*unused*/,
83  const stepper_t& /*unused*/) const {}
84 };
85 
86 } // namespace detail
87 } // namespace Acts