Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:49

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/Definitions/TrackParametrization.hpp"
0012 #include "Acts/Utilities/detail/periodic.hpp"
0013 
0014 #include <limits>
0015 
0016 namespace Acts {
0017 
0018 /// Check if a bound vector is valid. This checks the following:
0019 /// - All values are finite
0020 /// - (optionally) The phi value is in the range [-pi, pi)
0021 /// - (optionally) The theta value is in the range [0, pi]
0022 ///
0023 /// @param v The bound vector to check
0024 /// @param validateAngleRange If true, the phi and theta values are range checked
0025 /// @param epsilon The epsilon to use for the checks
0026 /// @param maxAbsEta The maximum allowed eta value
0027 ///
0028 /// @return True if the bound vector is valid
0029 bool isBoundVectorValid(
0030     const BoundVector& v, bool validateAngleRange, double epsilon = 1e-6,
0031     double maxAbsEta = std::numeric_limits<double>::infinity());
0032 
0033 /// Check if a free vector is valid. This checks the following:
0034 /// - All values are finite
0035 /// - Direction is normalized
0036 ///
0037 /// @param v The free vector to check
0038 /// @param epsilon The epsilon to use for the checks
0039 /// @param maxAbsEta The maximum allowed eta value
0040 ///
0041 /// @return True if the free vector is valid
0042 bool isFreeVectorValid(
0043     const FreeVector& v, double epsilon = 1e-6,
0044     double maxAbsEta = std::numeric_limits<double>::infinity());
0045 
0046 /// Normalize the bound parameter angles
0047 ///
0048 /// @param boundParams The bound parameters to normalize
0049 ///
0050 /// @return The normalized bound parameters
0051 inline BoundVector normalizeBoundParameters(const BoundVector& boundParams) {
0052   BoundVector result = boundParams;
0053   std::tie(result[eBoundPhi], result[eBoundTheta]) =
0054       detail::normalizePhiTheta(result[eBoundPhi], result[eBoundTheta]);
0055   return result;
0056 }
0057 
0058 /// Add bound parameters and take care of angle periodicity for phi and theta.
0059 /// This is intended for small differences only i.e. KF updates.
0060 ///
0061 /// @param lhs The left hand side bound parameters
0062 /// @param rhs The right hand side bound parameters
0063 ///
0064 /// @return The sum of the bound parameters
0065 inline BoundVector addBoundParameters(const BoundVector& lhs,
0066                                       const BoundVector& rhs) {
0067   return normalizeBoundParameters(lhs + rhs);
0068 }
0069 
0070 /// Subtract bound parameters and take care of angle periodicity for phi and
0071 /// theta. This is intended for small differences only i.e. KF updates.
0072 ///
0073 /// @param lhs The left hand side bound parameters
0074 /// @param rhs The right hand side bound parameters
0075 ///
0076 /// @return The difference of the bound parameters
0077 inline BoundVector subtractBoundParameters(const BoundVector& lhs,
0078                                            const BoundVector& rhs) {
0079   BoundVector result = lhs - rhs;
0080   result[eBoundPhi] = detail::radian_sym(result[eBoundPhi]);
0081   result[eBoundTheta] = detail::radian_sym(result[eBoundTheta]);
0082   return result;
0083 }
0084 
0085 }  // namespace Acts