Skip to content

Commit a52a3a7

Browse files
committed
Fixes for MeanVertexObject class
1 parent c54bce0 commit a52a3a7

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

DataFormats/Calibration/include/DataFormatsCalibration/MeanVertexObject.h

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#define MEAN_VERTEX_OBJECT_H_
1414

1515
#include <array>
16-
#include "Rtypes.h"
17-
1816
#include "Framework/Logger.h"
1917
#include "ReconstructionDataFormats/Vertex.h"
2018

@@ -28,71 +26,65 @@ class MeanVertexObject : public VertexBase
2826
public:
2927
MeanVertexObject(float x, float y, float z, float sigmax, float sigmay, float sigmaz, float slopeX, float slopeY)
3028
{
31-
gpu::gpustd::array<float, kNCov> cov;
32-
cov[CovElems::kCovXX] = sigmax;
33-
cov[CovElems::kCovYY] = sigmay;
34-
cov[CovElems::kCovZZ] = sigmaz;
3529
setXYZ(x, y, z);
36-
setCov(cov);
30+
setSigma({sigmax, sigmay, sigmaz});
3731
mSlopeX = slopeX;
3832
mSlopeY = slopeY;
3933
}
4034
MeanVertexObject(std::array<float, 3> pos, std::array<float, 3> sigma, float slopeX, float slopeY)
4135
{
4236
math_utils::Point3D<float> p(pos[0], pos[1], pos[2]);
43-
gpu::gpustd::array<float, kNCov> cov;
44-
cov[CovElems::kCovXX] = sigma[0];
45-
cov[CovElems::kCovYY] = sigma[1];
46-
cov[CovElems::kCovZZ] = sigma[2];
4737
setPos(p);
48-
setCov(cov);
38+
setSigma(sigma);
4939
mSlopeX = slopeX;
5040
mSlopeY = slopeY;
5141
}
5242
MeanVertexObject() = default;
5343
~MeanVertexObject() = default;
5444
MeanVertexObject(const MeanVertexObject& other) = default;
5545
MeanVertexObject(MeanVertexObject&& other) = default;
56-
MeanVertexObject& operator=(MeanVertexObject& other) = default;
46+
MeanVertexObject& operator=(const MeanVertexObject& other) = default;
5747
MeanVertexObject& operator=(MeanVertexObject&& other) = default;
5848

5949
void set(int icoord, float val);
6050
void setSigma(int icoord, float val);
61-
void setSigmaX(float val) { setSigmaX2(val); }
62-
void setSigmaY(float val) { setSigmaY2(val); }
63-
void setSigmaZ(float val) { setSigmaZ2(val); }
6451
void setSigma(std::array<float, 3> val)
6552
{
66-
setSigmaX2(val[0]);
67-
setSigmaY2(val[1]);
68-
setSigmaZ2(val[2]);
53+
setSigmaX(val[0]);
54+
setSigmaY(val[1]);
55+
setSigmaZ(val[2]);
6956
}
7057
void setSlopeX(float val) { mSlopeX = val; }
7158
void setSlopeY(float val) { mSlopeY = val; }
7259

7360
math_utils::Point3D<float>& getPos() { return getXYZ(); }
7461
math_utils::Point3D<float> getPos() const { return getXYZ(); }
75-
float getSigmaX() const { return getSigmaX2(); }
76-
float getSigmaY() const { return getSigmaY2(); }
77-
float getSigmaZ() const { return getSigmaZ2(); }
78-
const gpu::gpustd::array<float, kNCov>& getSigma() const { return getCov(); }
7962

8063
float getSlopeX() const { return mSlopeX; }
8164
float getSlopeY() const { return mSlopeY; }
8265

83-
float getXAtZ(float z) { return getX() + mSlopeX * (z - getZ()); }
84-
float getYAtZ(float z) { return getY() + mSlopeY * (z - getZ()); }
66+
float getXAtZ(float z) const { return getX() + mSlopeX * (z - getZ()); }
67+
float getYAtZ(float z) const { return getY() + mSlopeY * (z - getZ()); }
8568

8669
void print() const;
8770
std::string asString() const;
8871

89-
VertexBase getMeanVertex(float z)
72+
VertexBase getMeanVertex(float z) const
9073
{
74+
// set z-dependent x,z, assuming that the cov.matrix is already set
9175
VertexBase v = *this;
9276
v.setXYZ(getXAtZ(z), getYAtZ(z), z);
9377
return v;
9478
}
9579

80+
void setMeanXYVertexAtZ(VertexBase& v, float z) const
81+
{
82+
float dz = z - getZ();
83+
v.setX(getX() + mSlopeX * dz);
84+
v.setY(getY() + mSlopeY * dz);
85+
v.setZ(z);
86+
}
87+
9688
const VertexBase& getMeanVertex() const
9789
{
9890
return (const VertexBase&)(*this);

DataFormats/Reconstruction/include/ReconstructionDataFormats/Vertex.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class VertexBase
6161
GPUd() float getSigmaXY() const { return mCov[kCovXY]; }
6262
GPUd() float getSigmaXZ() const { return mCov[kCovXZ]; }
6363
GPUd() float getSigmaYZ() const { return mCov[kCovYZ]; }
64+
GPUd() float getSigmaX() const { return gpu::CAMath::Sqrt(getSigmaX2()); }
65+
GPUd() float getSigmaY() const { return gpu::CAMath::Sqrt(getSigmaY2()); }
66+
GPUd() float getSigmaZ() const { return gpu::CAMath::Sqrt(getSigmaZ2()); }
67+
6468
GPUd() const gpu::gpustd::array<float, kNCov>& getCov() const { return mCov; }
6569

6670
GPUd() math_utils::Point3D<float> getXYZ() const { return mPos; }
@@ -84,6 +88,10 @@ class VertexBase
8488
GPUd() void setSigmaXY(float v) { mCov[kCovXY] = v; }
8589
GPUd() void setSigmaXZ(float v) { mCov[kCovXZ] = v; }
8690
GPUd() void setSigmaYZ(float v) { mCov[kCovYZ] = v; }
91+
GPUd() void setSigmaX(float val) { setSigmaX2(val * val); }
92+
GPUd() void setSigmaY(float val) { setSigmaY2(val * val); }
93+
GPUd() void setSigmaZ(float val) { setSigmaZ2(val * val); }
94+
8795
GPUd() void setCov(float sxx, float sxy, float syy, float sxz, float syz, float szz)
8896
{
8997
setSigmaX2(sxx);

0 commit comments

Comments
 (0)