EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceCollector.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SurfaceCollector.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 
12 
13 #include <sstream>
14 
15 namespace Acts {
16 
19  bool selectSensitive = true;
20  bool selectMaterial = false;
21  bool selectPassive = false;
22 
28  SurfaceSelector(bool sSensitive = true, bool sMaterial = false,
29  bool sPassive = false)
30  : selectSensitive(sSensitive),
31  selectMaterial(sMaterial),
32  selectPassive(sPassive) {}
33 
37  bool operator()(const Acts::Surface& surface) const {
38  if (selectSensitive && surface.associatedDetectorElement() != nullptr) {
39  return true;
40  }
41  if (selectMaterial && surface.surfaceMaterial() != nullptr) {
42  return true;
43  }
44  if (selectPassive) {
45  return true;
46  }
47  return false;
48  }
49 };
50 
52 struct SurfaceHit {
53  const Surface* surface = nullptr;
56 };
57 
64 template <typename Selector = SurfaceSelector>
67  Selector selector;
68 
72  struct this_result {
73  std::vector<SurfaceHit> collected;
74  };
75 
77 
89  template <typename propagator_state_t, typename stepper_t>
90  void operator()(propagator_state_t& state, const stepper_t& stepper,
91  result_type& result) const {
92  const auto& logger = state.options.logger;
93  // The current surface has been assigned by the navigator
94  if (state.navigation.currentSurface &&
95  selector(*state.navigation.currentSurface)) {
96  // Create for recording
97  SurfaceHit surface_hit;
98  surface_hit.surface = state.navigation.currentSurface;
99  surface_hit.position = stepper.position(state.stepping);
100  surface_hit.direction = stepper.direction(state.stepping);
101  // Save if in the result
102  result.collected.push_back(surface_hit);
103  // Screen output
104  ACTS_VERBOSE("Collect surface "
105  << state.navigation.currentSurface->geometryId());
106  }
107  }
108 
111  template <typename propagator_state_t, typename stepper_t>
112  void operator()(propagator_state_t& /*state*/,
113  const stepper_t& /*unused*/) const {}
114 };
115 
116 } // namespace Acts