File indexing completed on 2024-04-06 12:31:43
0001 #ifndef RKCurvilinearDistance_H
0002 #define RKCurvilinearDistance_H
0003
0004 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
0005 #include "FWCore/Utilities/interface/Visibility.h"
0006 #include "RKDistance.h"
0007 #include "RKSmallVector.h"
0008
0009 template <typename T, int N>
0010 class dso_internal RKCurvilinearDistance : public RKDistance<T, N> {
0011 public:
0012 typedef T Scalar;
0013 typedef RKSmallVector<T, N> Vector;
0014
0015 ~RKCurvilinearDistance() override {}
0016
0017 Scalar operator()(const Vector& a, const Vector& b, const Scalar& s) const override {
0018 Basic3DVector<Scalar> amom = momentum(a);
0019 Basic3DVector<Scalar> bmom = momentum(b);
0020
0021 return sqrt(sqr(a(0) - b(0)) + sqr(a(1) - b(1))) + (amom - bmom).mag() / bmom.mag();
0022 }
0023
0024 Basic3DVector<Scalar> momentum(const Vector& v) const {
0025 Scalar k = sqrt(1 + sqr(v(2)) + sqr(v(3)));
0026 Scalar p = std::abs(1 / v(4));
0027 Scalar pz = p / k;
0028 return Basic3DVector<Scalar>(v(2) * pz, v(3) * pz, pz);
0029 }
0030
0031 T sqr(const T& t) const { return t * t; }
0032 };
0033
0034 #endif