EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiTrajectoryHelpers.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MultiTrajectoryHelpers.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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
12 #include "Acts/Geometry/Layer.hpp"
15 
16 #include <functional>
17 #include <unordered_map>
18 
19 namespace Acts {
20 
21 namespace MultiTrajectoryHelpers {
22 
27  size_t nStates = 0;
28  size_t nMeasurements = 0;
29  size_t nOutliers = 0;
30  size_t nHoles = 0;
31  double chi2Sum = 0;
32  size_t NDF = 0;
33 };
34 
35 // Container for trajectory summary info at a specific volume
37  std::unordered_map<GeometryIdentifier::Value, TrajectoryState>;
38 
47 template <typename source_link_t>
49  const Acts::MultiTrajectory<source_link_t>& multiTraj,
50  const size_t& entryIndex) {
51  TrajectoryState trajState;
52  multiTraj.visitBackwards(entryIndex, [&](const auto& state) {
53  trajState.nStates++;
54  trajState.chi2Sum += state.chi2();
55  trajState.NDF += state.calibratedSize();
56  auto typeFlags = state.typeFlags();
57  if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
58  trajState.nMeasurements++;
59  } else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
60  trajState.nOutliers++;
61  } else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
62  trajState.nHoles++;
63  }
64  });
65  return trajState;
66 }
67 
79 template <typename source_link_t>
81  const Acts::MultiTrajectory<source_link_t>& multiTraj,
82  const size_t& entryIndex,
83  const std::vector<GeometryIdentifier::Value>& volumeIds) {
84  VolumeTrajectoryStateContainer trajStateContainer;
85  multiTraj.visitBackwards(entryIndex, [&](const auto& state) {
86  // Get the volume Id of this surface
87  const auto& geoID = state.referenceSurface().geometryId();
88  const auto& volume = geoID.volume();
89  // Check if the track info for this sub-detector is requested
90  auto it = std::find(volumeIds.begin(), volumeIds.end(), volume);
91  if (it == volumeIds.end()) {
92  return true;
93  }
94  // The trajectory state for this volume
95  auto& trajState = trajStateContainer[volume];
96  trajState.nStates++;
97  trajState.chi2Sum += state.chi2();
98  trajState.NDF += state.calibratedSize();
99  auto typeFlags = state.typeFlags();
100  if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
101  trajState.nMeasurements++;
102  } else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
103  trajState.nOutliers++;
104  } else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
105  trajState.nHoles++;
106  }
107  return true;
108  });
109  return trajStateContainer;
110 }
111 
120 template <typename track_state_proxy_t>
122  const track_state_proxy_t& trackStateProxy) {
124  trackStateProxy.referenceSurface(), gctx, trackStateProxy.filtered());
125 }
126 
135 template <typename track_state_proxy_t>
137  const track_state_proxy_t& trackStateProxy) {
139  trackStateProxy.referenceSurface(), gctx, trackStateProxy.smoothed());
140 }
141 } // namespace MultiTrajectoryHelpers
142 
143 } // namespace Acts