forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeanVertexObject.h
More file actions
139 lines (116 loc) · 3.73 KB
/
Copy pathMeanVertexObject.h
File metadata and controls
139 lines (116 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef MEAN_VERTEX_OBJECT_H_
#define MEAN_VERTEX_OBJECT_H_
#include <array>
#include "Framework/Logger.h"
#include "ReconstructionDataFormats/Vertex.h"
#include "DataFormatsCalibration/MeanVertexBiasParam.h"
namespace o2
{
namespace dataformats
{
class MeanVertexObject : public VertexBase
{
public:
MeanVertexObject(float x, float y, float z, float sigmax, float sigmay, float sigmaz, float slopeX, float slopeY)
{
if (!gMVBias) {
checkExternalBias();
}
setXYZ(x, y, z);
setSigma({sigmax, sigmay, sigmaz});
mSlopeX = slopeX;
mSlopeY = slopeY;
}
MeanVertexObject(std::array<float, 3> pos, std::array<float, 3> sigma, float slopeX, float slopeY)
{
if (!gMVBias) {
checkExternalBias();
}
math_utils::Point3D<float> p(pos[0], pos[1], pos[2]);
setPos(p);
setSigma(sigma);
mSlopeX = slopeX;
mSlopeY = slopeY;
}
MeanVertexObject()
{
if (!gMVBias) {
checkExternalBias();
}
}
~MeanVertexObject() = default;
MeanVertexObject(const MeanVertexObject& other) = default;
MeanVertexObject(MeanVertexObject&& other) = default;
MeanVertexObject& operator=(const MeanVertexObject& other) = default;
MeanVertexObject& operator=(MeanVertexObject&& other) = default;
void set(int icoord, float val);
void setSigma(int icoord, float val);
void setSigma(std::array<float, 3> val)
{
setSigmaX(val[0]);
setSigmaY(val[1]);
setSigmaZ(val[2]);
}
void setSlopeX(float val) { mSlopeX = val; }
void setSlopeY(float val) { mSlopeY = val; }
// getting the cartesian coordinates and errors
float getX() const { return VertexBase::getX() + gMVBias->xyz[0]; }
float getY() const
{
return VertexBase::getY() + gMVBias->xyz[1];
;
}
float getZ() const
{
return VertexBase::getZ() + gMVBias->xyz[2];
;
}
float getR() const { return gpu::CAMath::Hypot(getX(), getY()); }
math_utils::Point3D<float> getXYZ() const { return {getX(), getY(), getZ()}; }
math_utils::Point3D<float> getPos() const { return getXYZ(); }
float getSlopeX() const { return mSlopeX + gMVBias->slopeX; }
float getSlopeY() const { return mSlopeY + gMVBias->slopeY; }
float getXAtZ(float z) const { return getX() + getSlopeX() * (z - getZ()); }
float getYAtZ(float z) const { return getY() + getSlopeY() * (z - getZ()); }
void print() const;
std::string asString() const;
/// sample a vertex from the MeanVertex parameters
math_utils::Point3D<float> sample() const;
VertexBase getMeanVertex(float z) const
{
// set z-dependent x,z, assuming that the cov.matrix is already set
VertexBase v = *this;
v.setXYZ(getXAtZ(z), getYAtZ(z), z);
return v;
}
void setMeanXYVertexAtZ(VertexBase& v, float z) const
{
v.setX(getXAtZ(z));
v.setY(getYAtZ(z));
v.setZ(z);
}
const VertexBase getMeanVertex() const
{
return getMeanVertex(getZ());
}
static void checkExternalBias();
private:
float mSlopeX{0.f}; // slope of x = f(z)
float mSlopeY{0.f}; // slope of y = f(z)
static const MeanVertexBiasParam* gMVBias;
ClassDefNV(MeanVertexObject, 2);
};
std::ostream& operator<<(std::ostream& os, const o2::dataformats::MeanVertexObject& o);
} // namespace dataformats
} // namespace o2
#endif