Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:14

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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 /// @class TrackAtVertex
0071 ///
0072 /// @brief Defines a track at vertex object
0073 struct TrackAtVertex {
0074   /// Deleted default constructor
0075   TrackAtVertex() = delete;
0076 
0077   /// @brief Parameterized constructor
0078   ///
0079   /// @param chi2perTrack Chi2 of track
0080   /// @param paramsAtVertex Fitted perigee parameter
0081   /// @param originalTrack Original perigee parameter
0082   TrackAtVertex(double chi2perTrack, const BoundTrackParameters& paramsAtVertex,
0083                 InputTrack originalTrack)
0084       : fittedParams(paramsAtVertex),
0085         originalParams(originalTrack),
0086         chi2Track(chi2perTrack) {}
0087 
0088   /// @brief Constructor with default chi2
0089   ///
0090   /// @param paramsAtVertex Fitted perigee parameter
0091   /// @param originalTrack Original perigee parameter
0092   TrackAtVertex(const BoundTrackParameters& paramsAtVertex,
0093                 InputTrack originalTrack)
0094       : fittedParams(paramsAtVertex), originalParams(originalTrack) {}
0095 
0096   /// Fitted perigee
0097   BoundTrackParameters fittedParams;
0098 
0099   /// Original input parameters
0100   InputTrack originalParams;
0101 
0102   /// Chi2 of track
0103   double chi2Track = 0;
0104 
0105   /// Number degrees of freedom
0106   /// Note: Can be different from integer value
0107   /// since annealing can result in effective
0108   /// non-interger values
0109   double ndf = 0;
0110 
0111   /// Value of the compatibility of the track to the actual vertex, based
0112   /// on the estimation of the 3d distance between the track and the vertex
0113   double vertexCompatibility = 0;
0114 
0115   /// Weight of track in fit
0116   double trackWeight = 1;
0117 
0118   /// The linearized state of the track at vertex
0119   LinearizedTrack linearizedState;
0120 
0121   /// Is already linearized
0122   bool isLinearized = false;
0123 };
0124 
0125 }  // namespace Acts
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 };