Project
Loading...
Searching...
No Matches
MeanVertexObject.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 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
13#include "TRandom.h"
14
15#include <cstdlib>
16
17namespace o2
18{
19namespace dataformats
20{
21const MeanVertexBiasParam* MeanVertexObject::gMVBias = nullptr;
22
23void MeanVertexObject::set(int icoord, float val)
24{
25 if (icoord == 0) {
26 setX(val);
27 } else if (icoord == 1) {
28 setY(val);
29 } else if (icoord == 2) {
30 setZ(val);
31 } else {
32 LOG(fatal) << "Coordinate out of bound to set vtx " << icoord << ", should be in [0, 2]";
33 }
34}
35
36void MeanVertexObject::setSigma(int icoord, float val)
37{
38 if (icoord == 0) {
39 setSigmaX2(val);
40 } else if (icoord == 1) {
42 } else if (icoord == 2) {
44 } else {
45 LOG(fatal) << "Coordinate out of bound to set sigma via MeanVtx " << icoord << ", should be in [0, 2]";
46 }
47}
48
49std::string MeanVertexObject::asString() const
50{
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);
54}
55
56std::ostream& operator<<(std::ostream& os, const o2::dataformats::MeanVertexObject& o)
57{
58 // stream itself
59 os << o.asString();
60 return os;
61}
62
64{
65 std::cout << *this << std::endl;
66}
67
69{
70 // this assumes gaussian sampling
71 // first determine z; then x and y
72 const auto z = gRandom->Gaus(getZ(), getSigmaZ());
73 const auto x = gRandom->Gaus(getXAtZ(z), getSigmaX());
74 const auto y = gRandom->Gaus(getYAtZ(z), getSigmaY());
76}
77
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) {
83 }
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
89} // namespace dataformats
90} // namespace o2
static void updateFromString(std::string const &)
void set(int icoord, float val)
void setSigma(int icoord, float val)
math_utils::Point3D< float > sample() const
sample a vertex from the MeanVertex parameters
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint GLfloat * val
Definition glcorearb.h:1582
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
std::ostream & operator<<(std::ostream &os, const o2::dataformats::MeanVertexObject &o)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"