2020#ifndef GPUCA_GPUCODE_DEVICE
2121#include < type_traits>
2222#include < array>
23+ #include < cstring>
2324#ifndef GPUCA_NO_FMT
2425#include < sstream>
2526#include < string>
@@ -45,9 +46,14 @@ class VertexBase
4546 static constexpr int kNCov = 6 ;
4647 GPUhdDefault () VertexBase() = default ;
4748 GPUhdDefault () ~VertexBase () = default ;
48- GPUhd () VertexBase(const math_utils::Point3D< float >& pos, const std::array< float , kNCov >& cov) : mPos (pos), mCov ( cov)
49+ GPUh () VertexBase(const float * pos, const float * cov)
4950 {
51+ mPos .SetX (pos[0 ]);
52+ mPos .SetY (pos[1 ]);
53+ mPos .SetZ (pos[2 ]);
54+ std::memcpy (mCov .data (), cov, sizeof (float ) * kNCov );
5055 }
56+ GPUhd () VertexBase(const math_utils::Point3D<float >& pos, const std::array<float , kNCov >& cov) : mPos (pos), mCov (cov) {}
5157
5258#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE_DEVICE)
5359 void print () const ;
@@ -58,6 +64,7 @@ class VertexBase
5864 GPUhd () float getX () const { return mPos .X (); }
5965 GPUhd () float getY () const { return mPos .Y (); }
6066 GPUhd () float getZ () const { return mPos .Z (); }
67+ GPUhd () float getR () const { return gpu::CAMath::Hypot (mPos .X (), mPos .Y ()); }
6168 GPUd () float getSigmaX2 () const { return mCov [kCovXX ]; }
6269 GPUd () float getSigmaY2 () const { return mCov [kCovYY ]; }
6370 GPUd () float getSigmaZ2 () const { return mCov [kCovZZ ]; }
@@ -69,6 +76,7 @@ class VertexBase
6976 GPUd () float getSigmaZ () const { return gpu::CAMath::Sqrt (getSigmaZ2 ()); }
7077
7178 GPUd () const std::array<float , kNCov >& getCov () const { return mCov ; }
79+ GPUd () float getCov (int e) const { return mCov [e]; }
7280
7381 GPUd () math_utils::Point3D<float > getXYZ () const { return mPos ; }
7482 GPUd () math_utils::Point3D<float >& getXYZ () { return mPos ; }
@@ -105,6 +113,7 @@ class VertexBase
105113 setSigmaYZ (syz);
106114 }
107115 GPUd () void setCov (const std::array<float , kNCov >& cov) { mCov = cov; }
116+ GPUd () void setCov (float c, int e) { mCov [e] = c; }
108117
109118 bool operator ==(const VertexBase& other) const ;
110119 bool operator !=(const VertexBase& other) const { return !(*this == other); }
@@ -133,10 +142,8 @@ class Vertex : public VertexBase
133142
134143 GPUhdDefault () Vertex() = default ;
135144 GPUhdDefault () ~Vertex () = default ;
136- GPUhd () Vertex(const math_utils::Point3D<float >& pos, const std::array<float , kNCov >& cov, ushort nCont, float chi2)
137- : VertexBase(pos, cov), mChi2 (chi2), mNContributors (nCont)
138- {
139- }
145+ GPUhd () Vertex(const float * pos, const float * cov, ushort nCont, float chi2) : VertexBase(pos, cov), mChi2 (chi2), mNContributors (nCont) {}
146+ GPUhd () Vertex(const math_utils::Point3D<float >& pos, const std::array<float , kNCov >& cov, ushort nCont, float chi2) : VertexBase(pos, cov), mChi2 (chi2), mNContributors (nCont) {}
140147
141148#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE_DEVICE)
142149 void print () const ;
0 commit comments