1515#include < array>
1616#include " Framework/Logger.h"
1717#include " ReconstructionDataFormats/Vertex.h"
18+ #include " DataFormatsCalibration/MeanVertexBiasParam.h"
1819
1920namespace o2
2021{
2122namespace dataformats
2223{
2324class MeanVertexObject : public VertexBase
2425{
25-
2626 public:
2727 MeanVertexObject (float x, float y, float z, float sigmax, float sigmay, float sigmaz, float slopeX, float slopeY)
2828 {
29+ if (!gMVBias ) {
30+ checkExternalBias ();
31+ }
2932 setXYZ (x, y, z);
3033 setSigma ({sigmax, sigmay, sigmaz});
3134 mSlopeX = slopeX;
3235 mSlopeY = slopeY;
3336 }
37+
3438 MeanVertexObject (std::array<float , 3 > pos, std::array<float , 3 > sigma, float slopeX, float slopeY)
3539 {
40+ if (!gMVBias ) {
41+ checkExternalBias ();
42+ }
3643 math_utils::Point3D<float > p (pos[0 ], pos[1 ], pos[2 ]);
3744 setPos (p);
3845 setSigma (sigma);
3946 mSlopeX = slopeX;
4047 mSlopeY = slopeY;
4148 }
42- MeanVertexObject () = default ;
49+
50+ MeanVertexObject ()
51+ {
52+ if (!gMVBias ) {
53+ checkExternalBias ();
54+ }
55+ }
56+
4357 ~MeanVertexObject () = default ;
4458 MeanVertexObject (const MeanVertexObject& other) = default ;
4559 MeanVertexObject (MeanVertexObject&& other) = default ;
@@ -57,14 +71,28 @@ class MeanVertexObject : public VertexBase
5771 void setSlopeX (float val) { mSlopeX = val; }
5872 void setSlopeY (float val) { mSlopeY = val; }
5973
60- math_utils::Point3D<float >& getPos () { return getXYZ (); }
74+ // getting the cartesian coordinates and errors
75+ float getX () const { return VertexBase::getX () + gMVBias ->xyz [0 ]; }
76+ float getY () const
77+ {
78+ return VertexBase::getY () + gMVBias ->xyz [1 ];
79+ ;
80+ }
81+ float getZ () const
82+ {
83+ return VertexBase::getZ () + gMVBias ->xyz [2 ];
84+ ;
85+ }
86+ float getR () const { return gpu::CAMath::Hypot (getX (), getY ()); }
87+
88+ math_utils::Point3D<float > getXYZ () const { return {getX (), getY (), getZ ()}; }
6189 math_utils::Point3D<float > getPos () const { return getXYZ (); }
6290
63- float getSlopeX () const { return mSlopeX ; }
64- float getSlopeY () const { return mSlopeY ; }
91+ float getSlopeX () const { return mSlopeX + gMVBias -> slopeX ; }
92+ float getSlopeY () const { return mSlopeY + gMVBias -> slopeY ; }
6593
66- float getXAtZ (float z) const { return getX () + mSlopeX * (z - getZ ()); }
67- float getYAtZ (float z) const { return getY () + mSlopeY * (z - getZ ()); }
94+ float getXAtZ (float z) const { return getX () + getSlopeX () * (z - getZ ()); }
95+ float getYAtZ (float z) const { return getY () + getSlopeY () * (z - getZ ()); }
6896
6997 void print () const ;
7098 std::string asString () const ;
@@ -82,21 +110,24 @@ class MeanVertexObject : public VertexBase
82110
83111 void setMeanXYVertexAtZ (VertexBase& v, float z) const
84112 {
85- float dz = z - getZ ();
86- v.setX (getX () + mSlopeX * dz);
87- v.setY (getY () + mSlopeY * dz);
113+ v.setX (getXAtZ (z));
114+ v.setY (getYAtZ (z));
88115 v.setZ (z);
89116 }
90117
91- const VertexBase& getMeanVertex () const
118+ const VertexBase getMeanVertex () const
92119 {
93- return ( const VertexBase&)(* this );
120+ return getMeanVertex ( getZ () );
94121 }
95122
123+ static void checkExternalBias ();
124+
96125 private:
97126 float mSlopeX {0 .f }; // slope of x = f(z)
98127 float mSlopeY {0 .f }; // slope of y = f(z)
99128
129+ static const MeanVertexBiasParam* gMVBias ;
130+
100131 ClassDefNV (MeanVertexObject, 2 );
101132};
102133
0 commit comments