Analysis Software
Documentation for sPHENIX simulation 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 
18 
19 #include <memory>
20 #include <vector>
21 
22 namespace Acts {
23 
24 class Surface;
25 
26 namespace detail {
27 
33 struct Step {
36  Vector3 position = Vector3(0., 0., 0.);
37  Vector3 momentum = Vector3(0., 0., 0.);
38  std::shared_ptr<const Surface> surface = nullptr;
40 };
41 
47  struct this_result {
48  std::vector<Step> steps;
49  };
50 
52 
54  bool sterile = false;
55 
66  template <typename propagator_state_t, typename stepper_t,
67  typename navigator_t>
68  void operator()(propagator_state_t& state, const stepper_t& stepper,
69  const navigator_t& navigator, result_type& result,
70  const Logger& /*logger*/) const {
71  // Don't log if you have reached the target or are sterile
72  if (sterile or navigator.targetReached(state.navigation)) {
73  return;
74  }
75  // Record the propagation state
76  Step step;
77  step.stepSize = state.stepping.stepSize;
78  step.navDir = state.options.direction;
79  step.position = stepper.position(state.stepping);
80  step.momentum = stepper.momentum(state.stepping);
81 
82  // Record the information about the surface
83  if (navigator.currentSurface(state.navigation) != nullptr) {
84  step.surface = navigator.currentSurface(state.navigation)->getSharedPtr();
85  step.geoID = step.surface->geometryId();
86  } else if (navigator.currentVolume(state.navigation) != nullptr) {
87  // If there's no surface but a volume, this sets the geoID
88  step.geoID = navigator.currentVolume(state.navigation)->geometryId();
89  }
90  result.steps.push_back(std::move(step));
91  }
92 };
93 
94 } // namespace detail
95 } // namespace Acts