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 <MathUtils/Cartesian.h>
18
20#ifndef GPUCA_GPUCODE_DEVICE
21#include <type_traits>
22#include <array>
23#ifndef GPUCA_NO_FMT
24#include <sstream>
25#include <string>
26#include <fmt/format.h>
27#endif
28#endif
29
30namespace o2
31{
32namespace dataformats
33{
34
35// Base primary vertex class, with position, error
37{
38 public:
45 static GPUglobalconstexpr() int kNCov = 6;
46 GPUhdDefault() VertexBase() = default;
47 GPUhdDefault() ~VertexBase() = default;
48 GPUhd() VertexBase(const float* pos, const float* cov)
49 {
50 mPos = math_utils::Point3D<float>(pos[0], pos[1], pos[2]);
57 }
58 GPUhd() VertexBase(const math_utils::Point3D<float>& pos, const std::array<float, kNCov>& cov) : mPos(pos), mCov(cov) {}
59
60#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE_DEVICE)
61 void print() const;
62 std::string asString() const;
63#endif
64
65 // getting the cartesian coordinates and errors
66 GPUhd() float getX() const { return mPos.X(); }
67 GPUhd() float getY() const { return mPos.Y(); }
68 GPUhd() float getZ() const { return mPos.Z(); }
69 GPUhd() float getR() const { return gpu::CAMath::Hypot(mPos.X(), mPos.Y()); }
70 GPUd() float getSigmaX2() const { return mCov[kCovXX]; }
71 GPUd() float getSigmaY2() const { return mCov[kCovYY]; }
72 GPUd() float getSigmaZ2() const { return mCov[kCovZZ]; }
73 GPUd() float getSigmaXY() const { return mCov[kCovXY]; }
74 GPUd() float getSigmaXZ() const { return mCov[kCovXZ]; }
75 GPUd() float getSigmaYZ() const { return mCov[kCovYZ]; }
76 GPUd() float getSigmaX() const { return gpu::CAMath::Sqrt(getSigmaX2()); }
77 GPUd() float getSigmaY() const { return gpu::CAMath::Sqrt(getSigmaY2()); }
78 GPUd() float getSigmaZ() const { return gpu::CAMath::Sqrt(getSigmaZ2()); }
79
80 GPUd() const std::array<float, kNCov>& getCov() const { return mCov; }
81 GPUd() float getCov(int e) const { return mCov[e]; }
82
83 GPUd() math_utils::Point3D<float> getXYZ() const { return mPos; }
84 GPUd() math_utils::Point3D<float>& getXYZ() { return mPos; }
85
86 GPUd() void setX(float x) { mPos.SetX(x); }
87 GPUd() void setY(float y) { mPos.SetY(y); }
88 GPUd() void setZ(float z) { mPos.SetZ(z); }
89
90 GPUd() void setXYZ(float x, float y, float z)
91 {
92 setX(x);
95 }
96 GPUd() void setPos(const math_utils::Point3D<float>& p) { mPos = p; }
97
98 GPUd() void setSigmaX2(float v) { mCov[kCovXX] = v; }
99 GPUd() void setSigmaY2(float v) { mCov[kCovYY] = v; }
100 GPUd() void setSigmaZ2(float v) { mCov[kCovZZ] = v; }
101 GPUd() void setSigmaXY(float v) { mCov[kCovXY] = v; }
102 GPUd() void setSigmaXZ(float v) { mCov[kCovXZ] = v; }
103 GPUd() void setSigmaYZ(float v) { mCov[kCovYZ] = v; }
104 GPUd() void setSigmaX(float val) { setSigmaX2(val * val); }
105 GPUd() void setSigmaY(float val) { setSigmaY2(val * val); }
106 GPUd() void setSigmaZ(float val) { setSigmaZ2(val * val); }
107
108 GPUd() void setCov(float sxx, float sxy, float syy, float sxz, float syz, float szz)
109 {
110 setSigmaX2(sxx);
116 }
117 GPUd() void setCov(const std::array<float, kNCov>& cov) { mCov = cov; }
118 GPUd() void setCov(float c, int e) { mCov[e] = c; }
119
120 bool operator==(const VertexBase& other) const;
121 bool operator!=(const VertexBase& other) const { return !(*this == other); }
122
123 protected:
124 math_utils::Point3D<float> mPos{0., 0., 0.};
125 std::array<float, kNCov> mCov{};
126
128};
129
130// Base primary vertex class, with position, error, N candidates and flags field
131// The Stamp template parameter allows to define vertex (time)stamp in different
132// formats (ITS ROFrame ID, real time + error etc)
133
134template <typename Stamp>
135class Vertex : public VertexBase
136{
137 public:
138 using ushort = unsigned short;
139 enum Flags : ushort {
140 TimeValidated = 0x1 << 0, // Flag that the vertex was validated by external time measurement (e.g. FIT)
141 UPCMode = 0x1 << 1, // vertex is found in the UPC mode ITS ROF
142 FlagsMask = 0xffff
143 };
144
145 GPUhdDefault() Vertex() = default;
146 GPUhdDefault() ~Vertex() = default;
147 GPUhd() Vertex(const float* pos, const float* cov, ushort nCont, float chi2) : VertexBase(pos, cov), mChi2(chi2), mNContributors(nCont) {}
148 GPUhd() Vertex(const math_utils::Point3D<float>& pos, const std::array<float, kNCov>& cov, ushort nCont, float chi2) : VertexBase(pos, cov), mChi2(chi2), mNContributors(nCont) {}
149
150#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE_DEVICE)
151 void print() const;
152 std::string asString() const;
153#endif
154
155 GPUd() ushort getNContributors() const
156 {
157 return mNContributors;
158 }
159 GPUd() void setNContributors(ushort v) { mNContributors = v; }
160 GPUd() void addContributor() { mNContributors++; }
161
162 GPUd() ushort getFlags() const { return mBits; }
163 GPUd() bool isFlagSet(uint f) const { return mBits & (FlagsMask & f); }
164 GPUd() void setFlags(ushort f) { mBits |= FlagsMask & f; }
165 GPUd() void resetFlags(ushort f = FlagsMask) { mBits &= ~(FlagsMask & f); }
166
167 GPUd() void setChi2(float v) { mChi2 = v; }
168 GPUd() float getChi2() const { return mChi2; }
169
170 GPUhd() const Stamp& getTimeStamp() const { return mTimeStamp; }
171 GPUhd() Stamp& getTimeStamp() { return mTimeStamp; }
172 GPUd() void setTimeStamp(const Stamp& v) { mTimeStamp = v; }
173
174 protected:
175 float mChi2 = 0;
179
181};
182
183#if !defined(GPUCA_GPUCODE_DEVICE) && !defined(GPUCA_NO_FMT)
184std::ostream& operator<<(std::ostream& os, const o2::dataformats::VertexBase& v);
185
186namespace detail
187{
188template <typename T>
189concept Streamable = requires(std::ostream& os, const T& a) {
190 {
191 os << a
192 }
193 -> std::same_as<std::ostream&>;
194};
195
196template <typename T>
197concept HasFormattableTimeStamp = requires(const T& t) {
198 {
199 fmt::format("{}", t.getTimeStamp())
200 }
201 -> std::convertible_to<std::string>;
202};
203
204template <typename T>
205concept HasFormattableTimeStampWithError = requires(const T& t) {
206 {
207 fmt::format("{}+-{}", t.getTimeStamp(), t.getTimeStampError())
208 }
209 -> std::convertible_to<std::string>;
210};
211} // namespace detail
212
213template <typename Stamp>
214inline std::string Vertex<Stamp>::asString() const
215{
216 const std::string stamp = [&]() -> std::string {
217 if constexpr (detail::Streamable<Stamp>) {
218 std::ostringstream oss;
219 oss << mTimeStamp;
220 return oss.str();
222 return fmt::format("{}+-{}", mTimeStamp.getTimeStamp(), mTimeStamp.getTimeStampError());
223 } else if constexpr (detail::HasFormattableTimeStamp<Stamp>) {
224 return fmt::format("{}", mTimeStamp.getTimeStamp());
225 } else {
226 return "X";
227 }
228 }();
229 return fmt::format("{} NContrib:{} Chi2:{:.2f} Flags:{:b} Stamp:{}", VertexBase::asString(), mNContributors, mChi2, mBits, stamp);
230}
231
232template <typename Stamp>
233inline std::ostream& operator<<(std::ostream& os, const o2::dataformats::Vertex<Stamp>& v)
234{
235 os << v.asString();
236 return os;
237}
238
239template <typename Stamp>
240inline void Vertex<Stamp>::print() const
241{
242 std::cout << *this << '\n';
243}
244#endif
245
246} // namespace dataformats
247
248#ifndef GPUCA_GPUCODE_DEVICE
250namespace framework
251{
252template <typename T>
253struct is_messageable;
254template <>
255struct is_messageable<o2::dataformats::VertexBase> : std::true_type {
256};
257template <>
258struct is_messageable<o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>> : std::true_type {
259};
260template <>
261struct is_messageable<o2::dataformats::Vertex<o2::dataformats::TimeStampWithError<float, float>>> : std::true_type {
262};
263} // namespace framework
264#endif
265
266} // namespace o2
267#endif
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc bool
configStandalone Reconstruction rec_tpc float
uint16_t pos
Definition RawData.h:3
uint32_t c
Definition RawData.h:2
GPUd() void setSigmaX2(float v)
Definition Vertex.h:98
float float float sxz
Definition Vertex.h:108
bool operator!=(const VertexBase &other) const
Definition Vertex.h:121
GPUhd() float getY() const
Definition Vertex.h:67
GPUd() float getSigmaZ() const
Definition Vertex.h:78
GPUd() void setCov(float sxx
GPUd() void setSigmaZ2(float v)
Definition Vertex.h:100
GPUd() void setSigmaZ(float val)
Definition Vertex.h:106
GPUd() void setSigmaY(float val)
Definition Vertex.h:105
GPUd() float getSigmaY() const
Definition Vertex.h:77
GPUd() void setSigmaX(float val)
Definition Vertex.h:104
static GPUglobalconstexpr() int kNCov
GPUd() float getSigmaY2() const
Definition Vertex.h:71
float float float float syz
Definition Vertex.h:108
GPUhd() VertexBase(const float *pos
GPUd() void setZ(float z)
Definition Vertex.h:88
GPUd() void setSigmaY2(float v)
Definition Vertex.h:99
float float float float float szz
Definition Vertex.h:109
GPUd() float getSigmaX() const
Definition Vertex.h:76
std::string asString() const
Definition Vertex.cxx:24
GPUd() float getSigmaX2() const
Definition Vertex.h:70
GPUhd() float getR() const
Definition Vertex.h:69
GPUd() void setSigmaXZ(float v)
Definition Vertex.h:102
GPUd() void setXYZ(float x
GPUd() float getSigmaZ2() const
Definition Vertex.h:72
GPUd() void setX(float x)
Definition Vertex.h:86
GPUd() void setSigmaXY(float v)
Definition Vertex.h:101
bool operator==(const VertexBase &other) const
Definition Vertex.cxx:43
GPUhd() float getZ() const
Definition Vertex.h:68
math_utils::Point3D< float > mPos
cartesian position
Definition Vertex.h:124
GPUhdDefault() VertexBase()=default
GPUd() float getSigmaYZ() const
Definition Vertex.h:75
GPUd() float getSigmaXZ() const
Definition Vertex.h:74
GPUd() void setCov(const std
Definition Vertex.h:117
GPUd() float getSigmaXY() const
Definition Vertex.h:73
GPUd() void setSigmaYZ(float v)
Definition Vertex.h:103
GPUd() void setPos(const math_utils
Definition Vertex.h:96
GPUhd() float getX() const
Definition Vertex.h:66
GPUhd() VertexBase(const math_utils
Definition Vertex.h:58
GPUd() void setY(float y)
Definition Vertex.h:87
GPUd() ushort getNContributors() const
Definition Vertex.h:155
GPUhd() Vertex(const math_utils
Definition Vertex.h:148
ushort mNContributors
N contributors.
Definition Vertex.h:176
GPUhdDefault() Vertex()=default
const float ushort nCont
Definition Vertex.h:147
GPUd() void resetFlags(ushort f
chi2 or quality of tracks to vertex attachment
std::string asString() const
Definition Vertex.h:214
GPUd() bool isFlagSet(uint f) const
Definition Vertex.h:163
const float ushort float mChi2(chi2)
ushort mBits
bit field for flags
Definition Vertex.h:177
GPUd() void addContributor()
Definition Vertex.h:160
const float ushort float chi2
Definition Vertex.h:147
GPUd() ushort getFlags() const
Definition Vertex.h:162
GPUd() void setFlags(ushort f)
Definition Vertex.h:164
Stamp mTimeStamp
vertex time-stamp
Definition Vertex.h:178
const float * cov
Definition Vertex.h:147
void print() const
Definition Vertex.h:240
unsigned short ushort
Definition Vertex.h:138
GPUhd() Vertex(const float *pos
GPUd() void setNContributors(ushort v)
Definition Vertex.h:159
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLdouble f
Definition glcorearb.h:310
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat * val
Definition glcorearb.h:1582
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
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 ...
VectorOfTObjectPtrs other