File indexing completed on 2025-01-18 09:28:00
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/TrackParameters.hpp"
0012 #include "Acts/Utilities/Delegate.hpp"
0013 #include "Acts/Vertexing/LinearizedTrack.hpp"
0014
0015 #include <any>
0016 #include <functional>
0017 #include <typeindex>
0018
0019 namespace Acts {
0020
0021 struct InputTrack {
0022 template <typename input_track_t>
0023 explicit InputTrack(const input_track_t* inputTrack)
0024 : m_type{typeid(inputTrack)}, m_ptr{inputTrack} {}
0025
0026 InputTrack() = delete;
0027 InputTrack(const InputTrack&) = default;
0028 InputTrack(InputTrack&&) = default;
0029 InputTrack& operator=(const InputTrack&) = default;
0030 InputTrack& operator=(InputTrack&&) = default;
0031
0032 bool operator==(const InputTrack& other) const {
0033 return m_ptr == other.m_ptr;
0034 }
0035
0036 template <typename input_track_t>
0037 bool operator==(const input_track_t* other) const {
0038 return m_ptr == other;
0039 }
0040
0041 template <typename T>
0042 const T* as() const {
0043 using ptr_t = const T*;
0044 if (m_type != typeid(ptr_t)) {
0045 throw std::bad_any_cast();
0046 }
0047 return static_cast<ptr_t>(m_ptr);
0048 }
0049
0050 friend std::ostream& operator<<(std::ostream& os, const InputTrack& track) {
0051 os << track.m_ptr;
0052 return os;
0053 }
0054
0055 friend bool operator<(const InputTrack& lhs, const InputTrack& rhs) {
0056 return lhs.m_ptr < rhs.m_ptr;
0057 }
0058
0059 friend struct std::hash<Acts::InputTrack>;
0060
0061 static BoundTrackParameters extractParameters(const InputTrack& track) {
0062 return *track.as<BoundTrackParameters>();
0063 }
0064
0065 using Extractor = Acts::Delegate<BoundTrackParameters(const InputTrack&)>;
0066
0067 private:
0068 std::type_index m_type;
0069 const void* m_ptr;
0070 };
0071
0072
0073
0074
0075 struct TrackAtVertex {
0076
0077 TrackAtVertex() = delete;
0078
0079
0080
0081
0082
0083
0084 TrackAtVertex(double chi2perTrack, const BoundTrackParameters& paramsAtVertex,
0085 InputTrack originalTrack)
0086 : fittedParams(paramsAtVertex),
0087 originalParams(originalTrack),
0088 chi2Track(chi2perTrack) {}
0089
0090
0091
0092
0093
0094 TrackAtVertex(const BoundTrackParameters& paramsAtVertex,
0095 InputTrack originalTrack)
0096 : fittedParams(paramsAtVertex), originalParams(originalTrack) {}
0097
0098
0099 BoundTrackParameters fittedParams;
0100
0101
0102 InputTrack originalParams;
0103
0104
0105 double chi2Track = 0;
0106
0107
0108
0109
0110
0111 double ndf = 0;
0112
0113
0114
0115 double vertexCompatibility = 0;
0116
0117
0118 double trackWeight = 1;
0119
0120
0121 LinearizedTrack linearizedState;
0122
0123
0124 bool isLinearized = false;
0125 };
0126
0127 }
0128
0129 template <>
0130 struct std::hash<Acts::InputTrack> {
0131 std::size_t operator()(const Acts::InputTrack& track) const noexcept {
0132 return std::hash<const void*>{}(track.m_ptr);
0133 }
0134 };