Skip to content

Commit 7dca125

Browse files
shahor02alcaliva
authored andcommitted
Possibility to globally bias MeanVertex objects via env.var
Following ITS realignment the mean vertex position may change. To avoid recalibration of the huge amount of MeanVertex objects in the CCDB, one can globally bias them via env.var O2_DPL_MVBIAS providing the --configKeyValues-like string for the MeanVertexBiasParam ConfigurableParam ("mvbias"). E.g. export O2_DPL_MVBIAS="mvbias.xyz[0]=0.002;mvbias.xyz[1]=-0.12;mvbias.slopeY=0.0005" will shift all loaded positions by 0.002 cm in X and -0.12 cm in y and increase the y slope by 0.5mrad. At the very first call of MeanVertex constructor the bias will be reported as: root [0] o2::dataformats::MeanVertexObject mv; [INFO] Mean vertex is biased by: XYZ: 0.0020,-0.1200,0.0000 SlopeXY: 0.000e+00,5.000e-04
1 parent 805f723 commit 7dca125

6 files changed

Lines changed: 124 additions & 16 deletions

File tree

DataFormats/Calibration/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111

1212
o2_add_library(DataFormatsCalibration
1313
SOURCES src/MeanVertexObject.cxx
14+
SOURCES src/MeanVertexBiasParam.cxx
1415
PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
15-
O2::Framework)
16+
O2::Framework
17+
O2::CommonUtils)
1618

1719
o2_target_root_dictionary(DataFormatsCalibration
18-
HEADERS include/DataFormatsCalibration/MeanVertexObject.h)
20+
HEADERS include/DataFormatsCalibration/MeanVertexObject.h
21+
include/DataFormatsCalibration/MeanVertexBiasParam.h)
1922

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \author ruben.shahoyan@cern.ch
13+
14+
/// parameters to bias precalibrated mean vertex, e.g after the alignment shift
15+
16+
#ifndef ALICEO2_MEANVERTEX_BIAS_PARAM_H
17+
#define ALICEO2_MEANVERTEX_BIAS_PARAM_H
18+
19+
#include "CommonUtils/ConfigurableParam.h"
20+
#include "CommonUtils/ConfigurableParamHelper.h"
21+
22+
namespace o2
23+
{
24+
namespace dataformats
25+
{
26+
27+
struct MeanVertexBiasParam : public o2::conf::ConfigurableParamHelper<MeanVertexBiasParam> {
28+
float xyz[3] = {}; // position bias
29+
float slopeX = 0.f; // x slope bias
30+
float slopeY = 0.f; // y slope bias
31+
32+
O2ParamDef(MeanVertexBiasParam, "mvbias");
33+
};
34+
35+
} // namespace dataformats
36+
} // end namespace o2
37+
38+
#endif

DataFormats/Calibration/include/DataFormatsCalibration/MeanVertexObject.h

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,45 @@
1515
#include <array>
1616
#include "Framework/Logger.h"
1717
#include "ReconstructionDataFormats/Vertex.h"
18+
#include "DataFormatsCalibration/MeanVertexBiasParam.h"
1819

1920
namespace o2
2021
{
2122
namespace dataformats
2223
{
2324
class 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

DataFormats/Calibration/src/DataFormatsCalibrationLinkDef.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#pragma link off all classes;
1616
#pragma link off all functions;
1717

18-
#pragma link C++ struct o2::dataformats::MeanVertexObject + ;
18+
#pragma link C++ class o2::dataformats::MeanVertexObject + ;
19+
#pragma link C++ class o2::dataformats::MeanVertexBiasParam + ;
20+
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::dataformats::MeanVertexBiasParam> + ;
1921

2022
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \author ruben.shahoyan@cern.ch
13+
14+
/// parameters to bias precalibrated mean vertex, e.g after the alignment shift
15+
16+
#include "DataFormatsCalibration/MeanVertexBiasParam.h"
17+
18+
O2ParamImpl(o2::dataformats::MeanVertexBiasParam);

DataFormats/Calibration/src/MeanVertexObject.cxx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
#include "DataFormatsCalibration/MeanVertexObject.h"
1313
#include "TRandom.h"
1414

15+
#include <cstdlib>
16+
1517
namespace o2
1618
{
1719
namespace dataformats
1820
{
21+
const MeanVertexBiasParam* MeanVertexObject::gMVBias = nullptr;
1922

2023
void MeanVertexObject::set(int icoord, float val)
2124
{
@@ -45,7 +48,9 @@ void MeanVertexObject::setSigma(int icoord, float val)
4548

4649
std::string MeanVertexObject::asString() const
4750
{
48-
return VertexBase::asString() + fmt::format(" Slopes {{{:+.4e},{:+.4e}}}", mSlopeX, mSlopeY);
51+
return fmt::format("Vtx {{{:+.4e},{:+.4e},{:+.4e}}} Cov.:{{{{{:.3e}..}},{{{:.3e},{:.3e}..}},{{{:.3e},{:.3e},{:.3e}}}}} | bias: XYZ: {:.4f},{:.4f},{:.4f} SlopeXY: {:.3e},{:.3e}",
52+
getX(), getY(), getZ(), mCov[0], mCov[1], mCov[2], mCov[3], mCov[4], mCov[5],
53+
gMVBias->xyz[0], gMVBias->xyz[1], gMVBias->xyz[2], gMVBias->slopeX, gMVBias->slopeY);
4954
}
5055

5156
std::ostream& operator<<(std::ostream& os, const o2::dataformats::MeanVertexObject& o)
@@ -70,5 +75,16 @@ math_utils::Point3D<float> MeanVertexObject::sample() const
7075
return math_utils::Point3D<float>(x, y, z);
7176
}
7277

78+
void MeanVertexObject::checkExternalBias()
79+
{
80+
// posibility to globally bias all data members with the proper env.var
81+
if (const auto* biasString = std::getenv("O2_DPL_MVBIAS"); biasString && *biasString) {
82+
o2::conf::ConfigurableParam::updateFromString(biasString);
83+
}
84+
gMVBias = &MeanVertexBiasParam::Instance();
85+
LOGP(info, "Mean vertex is biased by: XYZ: {:.4f},{:.4f},{:.4f} SlopeXY: {:.3e},{:.3e}",
86+
gMVBias->xyz[0], gMVBias->xyz[1], gMVBias->xyz[2], gMVBias->slopeX, gMVBias->slopeY);
87+
}
88+
7389
} // namespace dataformats
7490
} // namespace o2

0 commit comments

Comments
 (0)