File indexing completed on 2025-01-18 09:11:14
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 bool operator<(const InputTrack& other) const { return m_ptr < other.m_ptr; }
0042
0043 template <typename T>
0044 const T* as() const {
0045 using ptr_t = const T*;
0046 if (m_type != typeid(ptr_t)) {
0047 throw std::bad_any_cast();
0048 }
0049 return static_cast<ptr_t>(m_ptr);
0050 }
0051
0052 friend std::ostream& operator<<(std::ostream& os, const InputTrack& track) {
0053 os << track.m_ptr;
0054 return os;
0055 }
0056
0057 friend struct std::hash<Acts::InputTrack>;
0058
0059 static BoundTrackParameters extractParameters(const InputTrack& track) {
0060 return *track.as<BoundTrackParameters>();
0061 }
0062
0063 using Extractor = Acts::Delegate<BoundTrackParameters(const InputTrack&)>;
0064
0065 private:
0066 std::type_index m_type;
0067 const void* m_ptr;
0068 };
0069
0070
0071
0072
0073 struct TrackAtVertex {
0074
0075 TrackAtVertex() = delete;
0076
0077
0078
0079
0080
0081
0082 TrackAtVertex(double chi2perTrack, const BoundTrackParameters& paramsAtVertex,
0083 InputTrack originalTrack)
0084 : fittedParams(paramsAtVertex),
0085 originalParams(originalTrack),
0086 chi2Track(chi2perTrack) {}
0087
0088
0089
0090
0091
0092 TrackAtVertex(const BoundTrackParameters& paramsAtVertex,
0093 InputTrack originalTrack)
0094 : fittedParams(paramsAtVertex), originalParams(originalTrack) {}
0095
0096
0097 BoundTrackParameters fittedParams;
0098
0099
0100 InputTrack originalParams;
0101
0102
0103 double chi2Track = 0;
0104
0105
0106
0107
0108
0109 double ndf = 0;
0110
0111
0112
0113 double vertexCompatibility = 0;
0114
0115
0116 double trackWeight = 1;
0117
0118
0119 LinearizedTrack linearizedState;
0120
0121
0122 bool isLinearized = false;
0123 };
0124
0125 }
0126
0127 template <>
0128 struct std::hash<Acts::InputTrack> {
0129 std::size_t operator()(const Acts::InputTrack& track) const noexcept {
0130 return std::hash<const void*>{}(track.m_ptr);
0131 }
0132 };