Analysis Software
Documentation for sPHENIX simulation 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>
68 
72  struct this_result {
73  std::vector<SurfaceHit> collected;
74  };
75 
77 
92  template <typename propagator_state_t, typename stepper_t,
93  typename navigator_t>
94  void operator()(propagator_state_t& state, const stepper_t& stepper,
95  const navigator_t& navigator, result_type& result,
96  const Logger& logger) const {
97  auto currentSurface = navigator.currentSurface(state.navigation);
98 
99  // The current surface has been assigned by the navigator
100  if (currentSurface && selector(*currentSurface)) {
101  // Create for recording
102  SurfaceHit surface_hit;
103  surface_hit.surface = currentSurface;
104  surface_hit.position = stepper.position(state.stepping);
105  surface_hit.direction = stepper.direction(state.stepping);
106  // Save if in the result
107  result.collected.push_back(surface_hit);
108  // Screen output
109  ACTS_VERBOSE("Collect surface " << currentSurface->geometryId());
110  }
111  }
112 };
113 
114 } // namespace Acts