Project
Loading...
Searching...
No Matches
GPUTRDTracker.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
14
16
17#ifndef GPUTRDTRACKER_H
18#define GPUTRDTRACKER_H
19
20#include "GPUCommonDef.h"
21#include "GPUProcessor.h"
22#include "GPUTRDDef.h"
23#include "GPUDef.h"
24#include "GPUTRDTrack.h"
25#include "GPUTRDSpacePoint.h"
26#include "GPULogging.h"
27#include "GPUTRDInterfaces.h"
28
29#ifndef GPUCA_GPUCODE_DEVICE
30#include <vector>
31#endif
32
33namespace o2::gpu
34{
35
36class GPUTRDTrackletWord;
37class GPUTRDGeometry;
38class GPUChainTracking;
39template <class T>
40class GPUTRDTrackerDebug;
41class GPUTRDRecoParam;
42
43//-------------------------------------------------------------------------
44template <class TRDTRK, class PROP>
46{
47 public:
48#ifndef GPUCA_GPUCODE
50 GPUTRDTracker_t(const GPUTRDTracker_t& tracker) = delete;
51 GPUTRDTracker_t& operator=(const GPUTRDTracker_t& tracker) = delete;
53
57 void UpdateGeometry();
58 void* SetPointersBase(void* base);
59 void* SetPointersTracklets(void* base);
60 void* SetPointersTracks(void* base);
61
63 void SetNCandidates(int32_t n);
64 void PrintSettings() const;
65 bool IsInitialized() const { return mIsInitialized; }
66 void StartDebugging();
67#endif
68
73
75 // additional TRD track attributes which are transient
76 float mTime; // time estimate for seeding track in us
77 float mTimeAddMax; // max. time that can be added to this track seed in us
78 float mTimeSubMax; // max. time that can be subtracted to this track seed in us
79 int16_t mSide; // -1 : A-side, +1 : C-side (relevant only for TPC-only tracks)
80 GPUd() float GetTimeMin() const { return mTime - mTimeSubMax; }
81 GPUd() float GetTimeMax() const { return mTime + mTimeAddMax; }
83 };
84
85 struct Hypothesis {
86 int32_t mLayers; // number of layers with TRD space point
87 int32_t mCandidateId; // to which track candidate the hypothesis belongs
88 int32_t mTrackletId; // tracklet index to be used for update (global index within tracklet array)
89 float mChi2; // predicted chi2 for given space point
90
91 GPUd() float GetReducedChi2() { return mLayers > 0 ? mChi2 / mLayers : mChi2; }
92 GPUd() Hypothesis() : mLayers(0), mCandidateId(-1), mTrackletId(-1), mChi2(9999.f) {}
93 GPUd() Hypothesis(int32_t layers, int32_t candidateId, int32_t trackletId, float chi2) : mLayers(layers), mCandidateId(candidateId), mTrackletId(trackletId), mChi2(chi2) {}
94 };
95
96 int16_t MemoryPermanent() const { return mMemoryPermanent; }
97
98 GPUhd() void OverrideGPUGeometry(const GPUTRDGeometry* geo) { mGeo = geo; }
99 void Reset();
100 template <class T>
101 GPUd() bool PreCheckTrackTRDCandidate(const T& trk) const
102 {
103 return true;
104 }
105 GPUd() bool PreCheckTrackTRDCandidate(const GPUTPCGMMergedTrack& trk) const { return trk.OK() && !trk.MergedLooper(); }
106 GPUd() bool CheckTrackTRDCandidate(const TRDTRK& trk) const;
107 GPUd() int32_t LoadTrack(const TRDTRK& trk, uint32_t tpcTrackId, bool checkTrack = true, HelperTrackAttributes* attribs = nullptr);
108
109 GPUd() int32_t GetCollisionIDs(int32_t iTrk, int32_t* collisionIds) const;
110 GPUd() void DoTrackingThread(int32_t iTrk, int32_t threadId = 0);
111 static GPUd() bool ConvertTrkltToSpacePoint(const GPUTRDGeometry& geo, GPUTRDTrackletWord& trklt, GPUTRDSpacePoint& sp);
112 GPUd() bool CalculateSpacePoints(int32_t iCollision = 0);
113 GPUd() bool FollowProlongation(PROP* prop, TRDTRK* t, int32_t iTrk, int32_t threadId, int32_t collisionId);
114 GPUd() int32_t GetDetectorNumber(const float zPos, const float alpha, const int32_t layer) const;
115 GPUd() bool AdjustSector(PROP* prop, TRDTRK* t) const;
116 GPUd() int32_t GetSector(float alpha) const;
117 GPUd() float GetAlphaOfSector(const int32_t sec) const;
118 GPUd() float GetAngularPull(float dYtracklet, float snp) const;
119 GPUd() void RecalcTrkltCov(const float tilt, const float snp, const float rowSize, float (&cov)[3]);
120 GPUd() void FindChambersInRoad(const TRDTRK* t, const float roadY, const float roadZ, const int32_t iLayer, int32_t* det, const float zMax, const float alpha, const float zShiftTrk) const;
121 GPUd() bool IsGeoFindable(const TRDTRK* t, const int32_t layer, const float alpha, const float zShiftTrk) const;
122 GPUd() void InsertHypothesis(Hypothesis hypo, int32_t& nCurrHypothesis, int32_t idxOffset);
123
124 // settings
125 GPUd() void SetGenerateSpacePoints(bool flag) { mGenerateSpacePoints = flag; }
126 GPUd() bool GenerateSpacepoints() const { return mGenerateSpacePoints; }
127 GPUd() void SetProcessPerTimeFrame(bool flag) { mProcessPerTimeFrame = flag; }
128 GPUd() void EnableDebugOutput() { mDebugOutput = true; }
129 GPUd() void SetMaxEta(float maxEta) { mMaxEta = maxEta; }
130 GPUd() void SetRoadZ(float roadZ) { mRoadZ = roadZ; }
131 GPUd() void SetTPCVdrift(float vDrift) { mTPCVdrift = vDrift; }
132 GPUd() void SetTPCTDriftOffset(float t) { mTPCTDriftOffset = t; }
133
134 GPUd() bool GetIsDebugOutputOn() const { return mDebugOutput; }
135 GPUd() float GetMaxEta() const { return mMaxEta; }
136 GPUd() int32_t GetNCandidates() const { return mNCandidates; }
137 GPUd() float GetRoadZ() const { return mRoadZ; }
138
139 // output
140 GPUd() int32_t NTracks() const { return mNTracks; }
141 GPUd() GPUTRDSpacePoint* SpacePoints() const { return mSpacePoints; }
142 GPUd() TRDTRK* Tracks() const { return mTracks; }
143 GPUd() void DumpTracks();
144
145 // utility
146 GPUd() const typename PROP::propagatorParam* getPropagatorParam();
147
148 protected:
149 float* mR; // radial position of each TRD chamber, alignment taken into account, radial spread within chambers < 7mm
150 bool mIsInitialized; // flag is set upon initialization
151 bool mGenerateSpacePoints; // if true, only tracklets are provided as input and they will be converted into space points by the tracker
152 bool mProcessPerTimeFrame; // if true, tracking is done per time frame instead of on a single events basis
153 int16_t mNAngleHistogramBins; // number of bins per chamber for the angular difference histograms
154 float mAngleHistogramRange; // range of impact angles covered by each histogram
155 int16_t mMemoryPermanent; // memory id of permanent memory for the tracker
156 int16_t mMemoryTracklets; // memory id of memory for TRD tracklets
157 int16_t mMemoryTracks; // memory id of memory for tracks (used for i/o)
158 int32_t mNMaxCollisions; // max number of collisions to process (per time frame)
159 int32_t mNMaxTracks; // max number of tracks the tracker can handle (per event)
160 int32_t mNMaxSpacePoints; // max number of space points hold by the tracker (per event)
161 TRDTRK* mTracks; // array of trd-updated tracks
162 HelperTrackAttributes* mTrackAttribs; // array with additional (transient) track attributes
163 int32_t mNCandidates; // max. track hypothesis per layer
164 int32_t mNTracks; // number of TPC tracks to be matched
165 int32_t mNEvents; // number of processed events
166 int32_t mMaxBackendThreads; // maximum number of supported threads
167 // index of first tracklet for each chamber within tracklets array, last entry is total number of tracklets for given collision
168 // the array has (kNChambers + 1) * numberOfCollisions entries
169 // note, that for collision iColl one has to add an offset corresponding to the index of the first tracklet of iColl to the index stored in mTrackletIndexArray
171 Hypothesis* mHypothesis; // array with multiple track hypothesis
172 TRDTRK* mCandidates; // array of tracks for multiple hypothesis tracking
173 GPUTRDSpacePoint* mSpacePoints; // array with tracklet coordinates in global tracking frame
174 const GPUTRDGeometry* mGeo; // TRD geometry
177 bool mDebugOutput; // store debug output
178 static constexpr const float sRadialOffset = -0.1f; // due to (possible) mis-calibration of t0 -> will become obsolete when tracklet conversion is done outside of the tracker
179 float mMaxEta; // TPC tracks with higher eta are ignored
180 float mRoadZ; // in z, a constant search road is used
181 float mZCorrCoefNRC; // tracklet z-position depends linearly on track dip angle
182 float mTPCVdrift; // TPC drift velocity used for shifting TPC tracks along Z
183 float mTPCTDriftOffset; // TPC drift time additive offset
184 GPUTRDTrackerDebug<TRDTRK>* mDebug; // debug output
185};
186} // namespace o2::gpu
187
188#endif // GPUTRDTRACKER_H
Struct to hold the position/direction information of the tracklets transformed in sector coordinates.
#define protected
GPUd() bool PreCheckTrackTRDCandidate(const GPUTPCGMMergedTrack &trk) const
GPUd() float GetRoadZ() const
GPUTRDTracker_t(const GPUTRDTracker_t &tracker)=delete
void * SetPointersTracks(void *base)
GPUd() void DumpTracks()
GPUd() int32_t GetCollisionIDs(int32_t iTrk
void * SetPointersBase(void *base)
uint32_t bool HelperTrackAttributes * attribs
GPUd() void SetMaxEta(float maxEta)
GPUd() void SetProcessPerTimeFrame(bool flag)
const float const float float(& cov)[3]
GPUTRDTrackerDebug< TRDTRK > * mDebug
GPUd() void SetTPCVdrift(float vDrift)
GPUd() bool GetIsDebugOutputOn() const
GPUd() TRDTRK *Tracks() const
GPUd() int32_t NTracks() const
GPUTRDTracker_t & operator=(const GPUTRDTracker_t &tracker)=delete
void SetNCandidates(int32_t n)
GPUd() void SetRoadZ(float roadZ)
GPUd() bool GenerateSpacepoints() const
GPUhd() void OverrideGPUGeometry(const GPUTRDGeometry *geo)
GPUd() void SetTPCTDriftOffset(float t)
static GPUTRDTrackletWord GPUTRDSpacePoint & sp
const GPUTRDRecoParam * mRecoParam
GPUd() bool CheckTrackTRDCandidate(const TRDTRK &trk) const
const float const float const int32_t iLayer
GPUd() int32_t GetNCandidates() const
int32_t *collisionIds const
static constexpr const float sRadialOffset
static GPUTRDTrackletWord & trklt
void SetMaxData(const GPUTrackingInOutPointers &io)
const float const float roadZ
void PrepareTracking(GPUChainTracking *chainTracking)
GPUd() GPUTRDSpacePoint *SpacePoints() const
HelperTrackAttributes * mTrackAttribs
int16_t MemoryPermanent() const
int32_t int32_t idxOffset
TRDTRK int32_t int32_t int32_t collisionId
const float const float const int32_t int32_t const float zMax
const float const float const int32_t int32_t * det
const GPUTRDGeometry * mGeo
void * SetPointersTracklets(void *base)
GPUd() bool PreCheckTrackTRDCandidate(const T &trk) const
GPUd() void EnableDebugOutput()
const float const float rowSize
bool mDebugOutput
-— end error parametrization -—
GPUd() float GetMaxEta() const
GPUTRDSpacePoint * mSpacePoints
GLdouble n
Definition glcorearb.h:1982
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLdouble f
Definition glcorearb.h:310
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GPUChainTracking * chainTracking
GPUd() float GetReducedChi2()