Project
Loading...
Searching...
No Matches
Vertex.h
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
12#ifndef ALICEO2_VERTEX_H
13#define ALICEO2_VERTEX_H
14
15#include "GPUCommonDef.h"
16#include "GPUCommonMath.h"
17#include "GPUCommonArray.h"
18#include <MathUtils/Cartesian.h>
19
21#ifndef GPUCA_GPUCODE_DEVICE
22#include <iosfwd>
23#include <string>
24#include <type_traits>
25#endif
26
27namespace o2
28{
29namespace dataformats
30{
31
32// Base primary vertex class, with position, error
34{
35 public:
42 static constexpr int kNCov = 6;
43 GPUhdDefault() VertexBase() = default;
44 GPUhdDefault() ~VertexBase() = default;
45 GPUhd() VertexBase(const math_utils::Point3D<float>& pos, const gpu::gpustd::array<float, kNCov>& cov) : mPos(pos), mCov(cov)
46 {
47 }
48
49#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE_DEVICE)
50 void print() const;
51 std::string asString() const;
52#endif
53
54 // getting the cartesian coordinates and errors
55 GPUhd() float getX() const { return mPos.X(); }
56 GPUhd() float getY() const { return mPos.Y(); }
57 GPUhd() float getZ() const { return mPos.Z(); }
58 GPUd() float getSigmaX2() const { return mCov[kCovXX]; }
59 GPUd() float getSigmaY2() const { return mCov[kCovYY]; }
60 GPUd() float getSigmaZ2() const { return mCov[kCovZZ]; }
61 GPUd() float getSigmaXY() const { return mCov[kCovXY]; }
62 GPUd() float getSigmaXZ() const { return mCov[kCovXZ]; }
63 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
68 GPUd() const gpu::gpustd::array<float, kNCov>& getCov() const { return mCov; }
69
70 GPUd() math_utils::Point3D<float> getXYZ() const { return mPos; }
71 GPUd() math_utils::Point3D<float>& getXYZ() { return mPos; }
72
73 GPUd() void setX(float x) { mPos.SetX(x); }
74 GPUd() void setY(float y) { mPos.SetY(y); }
75 GPUd() void setZ(float z) { mPos.SetZ(z); }
76
77 GPUd() void setXYZ(float x, float y, float z)
78 {
79 setX(x);
82 }
83 GPUd() void setPos(const math_utils::Point3D<float>& p) { mPos = p; }
84
85 GPUd() void setSigmaX2(float v) { mCov[kCovXX] = v; }
86 GPUd() void setSigmaY2(float v) { mCov[kCovYY] = v; }
87 GPUd() void setSigmaZ2(float v) { mCov[kCovZZ] = v; }
88 GPUd() void setSigmaXY(float v) { mCov[kCovXY] = v; }
89 GPUd() void setSigmaXZ(float v) { mCov[kCovXZ] = v; }
90 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
95 GPUd() void setCov(float sxx, float sxy, float syy, float sxz, float syz, float szz)
96 {
97 setSigmaX2(sxx);
103 }
104 GPUd() void setCov(const gpu::gpustd::array<float, kNCov>& cov) { mCov = cov; }
105
106 bool operator==(const VertexBase& other) const;
107 bool operator!=(const VertexBase& other) const { return !(*this == other); }
108
109 protected:
112
114};
115
116// Base primary vertex class, with position, error, N candidates and flags field
117// The Stamp template parameter allows to define vertex (time)stamp in different
118// formats (ITS ROFrame ID, real time + error etc)
119
120template <typename Stamp>
121class Vertex : public VertexBase
122{
123 public:
124 using ushort = unsigned short;
125 enum Flags : ushort {
126 TimeValidated = 0x1 << 0, // Flag that the vertex was validated by external time measurement (e.g. FIT)
127 UPCMode = 0x1 << 1, // vertex is found in the UPC mode ITS ROF
128 FlagsMask = 0xffff
129 };
130
131 GPUhdDefault() Vertex() = default;
132 GPUhdDefault() ~Vertex() = default;
133 GPUhd() Vertex(const math_utils::Point3D<float>& pos, const gpu::gpustd::array<float, kNCov>& cov, ushort nCont, float chi2)
134 : VertexBase(pos, cov), mChi2(chi2), mNContributors(nCont)
135 {
136 }
137
138 GPUd() ushort getNContributors() const { return mNContributors; }
139 GPUd() void setNContributors(ushort v) { mNContributors = v; }
140 GPUd() void addContributor() { mNContributors++; }
141
142 GPUd() ushort getFlags() const { return mBits; }
143 GPUd() bool isFlagSet(uint f) const { return mBits & (FlagsMask & f); }
144 GPUd() void setFlags(ushort f) { mBits |= FlagsMask & f; }
145 GPUd() void resetFlags(ushort f = FlagsMask) { mBits &= ~(FlagsMask & f); }
146
147 GPUd() void setChi2(float v) { mChi2 = v; }
148 GPUd() float getChi2() const { return mChi2; }
149
150 GPUhd() const Stamp& getTimeStamp() const { return mTimeStamp; }
151 GPUhd() Stamp& getTimeStamp() { return mTimeStamp; }
152 GPUd() void setTimeStamp(const Stamp& v) { mTimeStamp = v; }
153
154 protected:
155 float mChi2 = 0;
159
161};
162
163#if !defined(GPUCA_GPUCODE_DEVICE) && !defined(GPUCA_NO_FMT)
164std::ostream& operator<<(std::ostream& os, const o2::dataformats::VertexBase& v);
165#endif
166
167} // namespace dataformats
168
169#ifndef GPUCA_GPUCODE_DEVICE
171namespace framework
172{
173template <typename T>
174struct is_messageable;
175template <>
176struct is_messageable<o2::dataformats::VertexBase> : std::true_type {
177};
178template <>
179struct is_messageable<o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>> : std::true_type {
180};
181template <>
182struct is_messageable<o2::dataformats::Vertex<o2::dataformats::TimeStampWithError<float, float>>> : std::true_type {
183};
184} // namespace framework
185#endif
186
187} // namespace o2
188#endif
uint16_t pos
Definition RawData.h:3
GPUd() void setSigmaX2(float v)
Definition Vertex.h:85
float float float sxz
Definition Vertex.h:95
bool operator!=(const VertexBase &other) const
Definition Vertex.h:107
GPUhd() float getY() const
Definition Vertex.h:56
GPUd() float getSigmaZ() const
Definition Vertex.h:66
static constexpr int kNCov
Definition Vertex.h:42
GPUd() void setCov(const gpu
Definition Vertex.h:104
GPUd() void setCov(float sxx
GPUd() void setSigmaZ2(float v)
Definition Vertex.h:87
GPUd() void setSigmaZ(float val)
Definition Vertex.h:93
GPUd() void setSigmaY(float val)
Definition Vertex.h:92
GPUd() float getSigmaY() const
Definition Vertex.h:65
GPUd() void setSigmaX(float val)
Definition Vertex.h:91
GPUd() float getSigmaY2() const
Definition Vertex.h:59
float float float float syz
Definition Vertex.h:95
GPUd() void setZ(float z)
Definition Vertex.h:75
GPUd() void setSigmaY2(float v)
Definition Vertex.h:86
float float float float float szz
Definition Vertex.h:96
GPUd() float getSigmaX() const
Definition Vertex.h:64
std::string asString() const
Definition Vertex.cxx:25
GPUd() float getSigmaX2() const
Definition Vertex.h:58
GPUd() void setSigmaXZ(float v)
Definition Vertex.h:89
GPUd() void setXYZ(float x
GPUd() float getSigmaZ2() const
Definition Vertex.h:60
GPUd() void setX(float x)
Definition Vertex.h:73
GPUd() void setSigmaXY(float v)
Definition Vertex.h:88
bool operator==(const VertexBase &other) const
Definition Vertex.cxx:44
GPUhd() float getZ() const
Definition Vertex.h:57
math_utils::Point3D< float > mPos
cartesian position
Definition Vertex.h:110
GPUhdDefault() VertexBase()=default
gpu::gpustd::array< float, kNCov > mCov
errors, see CovElems enum
Definition Vertex.h:111
GPUd() float getSigmaYZ() const
Definition Vertex.h:63
GPUd() float getSigmaXZ() const
Definition Vertex.h:62
GPUd() float getSigmaXY() const
Definition Vertex.h:61
GPUd() void setSigmaYZ(float v)
Definition Vertex.h:90
GPUd() void setPos(const math_utils
Definition Vertex.h:83
GPUhd() float getX() const
Definition Vertex.h:55
GPUhd() VertexBase(const math_utils
Definition Vertex.h:45
GPUd() void setY(float y)
Definition Vertex.h:74
GPUd() ushort getNContributors() const
Definition Vertex.h:138
GPUhd() Vertex(const math_utils
Definition Vertex.h:133
ushort mNContributors
N contributors.
Definition Vertex.h:156
GPUhdDefault() Vertex()=default
GPUd() void resetFlags(ushort f
chi2 or quality of tracks to vertex attachment
GPUd() bool isFlagSet(uint f) const
Definition Vertex.h:143
ushort mBits
bit field for flags
Definition Vertex.h:157
GPUd() void addContributor()
Definition Vertex.h:140
GPUd() ushort getFlags() const
Definition Vertex.h:142
GPUd() void setFlags(ushort f)
Definition Vertex.h:144
Stamp mTimeStamp
vertex time-stamp
Definition Vertex.h:158
unsigned short ushort
Definition Vertex.h:124
GPUd() void setNContributors(ushort v)
Definition Vertex.h:139
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLenum array
Definition glcorearb.h:4274
GLdouble f
Definition glcorearb.h:310
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
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)
std::array< T, N > array
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other