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
75 kNPads = 1244160 };
76
78 // additional TRD track attributes which are transient
79 float mTime; // time estimate for seeding track in us
80 float mTimeAddMax; // max. time that can be added to this track seed in us
81 float mTimeSubMax; // max. time that can be subtracted to this track seed in us
82 int16_t mSide; // -1 : A-side, +1 : C-side (relevant only for TPC-only tracks)
83 GPUd() float GetTimeMin() const { return mTime - mTimeSubMax; }
84 GPUd() float GetTimeMax() const { return mTime + mTimeAddMax; }
86 };
87
88 struct Hypothesis {
89 int32_t mLayers; // number of layers with TRD space point
90 int32_t mCandidateId; // to which track candidate the hypothesis belongs
91 int32_t mTrackletId; // tracklet index to be used for update (global index within tracklet array)
92 float mChi2; // predicted chi2 for given space point
93
94 GPUd() float GetReducedChi2() { return mLayers > 0 ? mChi2 / mLayers : mChi2; }
95 GPUd() Hypothesis() : mLayers(0), mCandidateId(-1), mTrackletId(-1), mChi2(9999.f) {}
96 GPUd() Hypothesis(int32_t layers, int32_t candidateId, int32_t trackletId, float chi2) : mLayers(layers), mCandidateId(candidateId), mTrackletId(trackletId), mChi2(chi2) {}
97 };
98
99 int16_t MemoryPermanent() const { return mMemoryPermanent; }
100
101 GPUhd() void OverrideGPUGeometry(const GPUTRDGeometry* geo) { mGeo = geo; }
102 void Reset();
103 template <class T>
104 GPUd() bool PreCheckTrackTRDCandidate(const T& trk) const
105 {
106 return true;
107 }
108 GPUd() bool PreCheckTrackTRDCandidate(const GPUTPCGMMergedTrack& trk) const { return trk.OK() && !trk.MergedLooper(); }
109 GPUd() bool CheckTrackTRDCandidate(const TRDTRK& trk) const;
110 GPUd() int32_t LoadTrack(const TRDTRK& trk, uint32_t tpcTrackId, bool checkTrack = true, HelperTrackAttributes* attribs = nullptr);
111
112 GPUd() int32_t GetCollisionIDs(int32_t iTrk, int32_t* collisionIds) const;
113 GPUd() void DoTrackingThread(int32_t iTrk, int32_t threadId = 0);
114 static GPUd() bool ConvertTrkltToSpacePoint(const GPUTRDGeometry& geo, GPUTRDTrackletWord& trklt, GPUTRDSpacePoint& sp);
115 GPUd() bool CalculateSpacePoints(int32_t iCollision = 0);
116 GPUd() bool FollowProlongation(PROP* prop, TRDTRK* t, int32_t iTrk, int32_t threadId, int32_t collisionId);
117 GPUd() int32_t GetDetectorNumber(const float zPos, const float alpha, const int32_t layer) const;
118 GPUd() bool AdjustSector(PROP* prop, TRDTRK* t) const;
119 GPUd() int32_t GetSector(float alpha) const;
120 GPUd() float GetAlphaOfSector(const int32_t sec) const;
121 GPUd() float GetAngularPull(float dYtracklet, float snp, int occupancy) const;
122 GPUd() void RecalcTrkltCov(const float tilt, const float snp, const float rowSize, const float pull, const int occupancy, float (&cov)[3]);
123 GPUd() void RecalcTrkltCovDy(const float tilt, const float snp, const float pull, const int occupancy, float (&cov)[6]);
124 GPUd() bool InvertCov(float (&cov)[6]);
125 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;
126 GPUd() bool IsGeoFindable(const TRDTRK* t, const int32_t layer, const float alpha, const float zShiftTrk) const;
127 GPUd() void InsertHypothesis(Hypothesis hypo, int32_t& nCurrHypothesis, int32_t idxOffset);
128 GPUd() int GetNtrackletsChamber(int32_t collisionId, int32_t detector) const;
129
130 // settings
131 GPUd() void SetGenerateSpacePoints(bool flag) { mGenerateSpacePoints = flag; }
132 GPUd() bool GenerateSpacepoints() const { return mGenerateSpacePoints; }
133 GPUd() void SetProcessPerTimeFrame(bool flag) { mProcessPerTimeFrame = flag; }
134 GPUd() void EnableDebugOutput() { mDebugOutput = true; }
135 GPUd() void SetMaxEta(float maxEta) { mMaxEta = maxEta; }
136 GPUd() void SetRoadZ(float roadZ) { mRoadZ = roadZ; }
137 GPUd() void SetTPCVdrift(float vDrift) { mTPCVdrift = vDrift; }
138 GPUd() void SetTPCTDriftOffset(float t) { mTPCTDriftOffset = t; }
139 GPUd() void SetFT0TriggeredBC(int32_t* t, int32_t n)
140 {
143 }
144 GPUd() void SetChamberStatus(int iDet, bool status) { mChamberStatus[iDet] = status; }
145 // GPUd() void SetPadStatus(int iPad, bool status) { mPadStatus[iPad] = status; }
146
147 GPUd() bool GetIsDebugOutputOn() const { return mDebugOutput; }
148 GPUd() float GetMaxEta() const { return mMaxEta; }
149 GPUd() int32_t GetNCandidates() const { return mNCandidates; }
150 GPUd() float GetRoadZ() const { return mRoadZ; }
151
152 // output
153 GPUd() int32_t NTracks() const { return mNTracks; }
154 GPUd() GPUTRDSpacePoint* SpacePoints() const { return mSpacePoints; }
155 GPUd() TRDTRK* Tracks() const { return mTracks; }
156 GPUd() void DumpTracks();
157
158 // utility
159 GPUd() const typename PROP::propagatorParam* getPropagatorParam();
160
161 protected:
162 float* mR; // radial position of each TRD chamber, alignment taken into account, radial spread within chambers < 7mm
163 bool mIsInitialized; // flag is set upon initialization
164 bool mGenerateSpacePoints; // if true, only tracklets are provided as input and they will be converted into space points by the tracker
165 bool mProcessPerTimeFrame; // if true, tracking is done per time frame instead of on a single events basis
166 int16_t mNAngleHistogramBins; // number of bins per chamber for the angular difference histograms
167 float mAngleHistogramRange; // range of impact angles covered by each histogram
168 int16_t mMemoryPermanent; // memory id of permanent memory for the tracker
169 int16_t mMemoryTracklets; // memory id of memory for TRD tracklets
170 int16_t mMemoryTracks; // memory id of memory for tracks (used for i/o)
171 int32_t mNMaxCollisions; // max number of collisions to process (per time frame)
172 int32_t mNMaxTracks; // max number of tracks the tracker can handle (per event)
173 int32_t mNMaxSpacePoints; // max number of space points hold by the tracker (per event)
174 TRDTRK* mTracks; // array of trd-updated tracks
175 HelperTrackAttributes* mTrackAttribs; // array with additional (transient) track attributes
176 int32_t mNCandidates; // max. track hypothesis per layer
177 int32_t mNTracks; // number of TPC tracks to be matched
178 int32_t mNEvents; // number of processed events
179 int32_t mMaxBackendThreads; // maximum number of supported threads
180 // index of first tracklet for each chamber within tracklets array, last entry is total number of tracklets for given collision
181 // the array has (kNChambers + 1) * numberOfCollisions entries
182 // 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
184 int32_t* mFT0TriggeredBC; // arrays with the FT0 triggered BCs, in number of BCs since the beginning of the TF
185 int32_t mNFT0BC; // number of FT0 BCs
186 Hypothesis* mHypothesis; // array with multiple track hypothesis
187 TRDTRK* mCandidates; // array of tracks for multiple hypothesis tracking
188 GPUTRDSpacePoint* mSpacePoints; // array with tracklet coordinates in global tracking frame
189 const GPUTRDGeometry* mGeo; // TRD geometry
191 bool mDebugOutput; // store debug output
192 static GPUglobalconstexpr() const float sRadialOffset = -0.1f; // due to (possible) mis-calibration of t0 -> will become obsolete when tracklet conversion is done outside of the tracker
193 float mMaxEta; // TPC tracks with higher eta are ignored
194 float mRoadZ; // in z, a constant search road is used
195 float mTPCVdrift; // TPC drift velocity used for shifting TPC tracks along Z
196 float mTPCTDriftOffset; // TPC drift time additive offset
197 GPUTRDTrackerDebug<TRDTRK>* mDebug; // debug output
198 bool mChamberStatus[kNChambers] = {}; // good (0) or bad (1) chamber from the CCDB, used for determining whether a track is findable
199 // bool mPadStatus[kNPads] = {}; // whether pad is masked or not in hardware, from the CCDB, used for determining if a track is findable
200};
201} // namespace o2::gpu
202
203#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
const float const float const float pull
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)
GPUTRDTrackerDebug< TRDTRK > * mDebug
GPUd() void SetTPCVdrift(float vDrift)
GPUd() bool GetIsDebugOutputOn() const
GPUd() void SetFT0TriggeredBC(int32_t *t
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)
bool mChamberStatus[kNChambers]
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 GPUglobalconstexpr() const float sRadialOffset
static GPUTRDTrackletWord & trklt
void SetMaxData(const GPUTrackingInOutPointers &io)
const float const float const float const int float(& cov)[3]
const float const float roadZ
void PrepareTracking(GPUChainTracking *chainTracking)
GPUd() GPUTRDSpacePoint *SpacePoints() const
HelperTrackAttributes * mTrackAttribs
int16_t MemoryPermanent() const
GPUd() void SetChamberStatus(int iDet
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
const float const float const float const int occupancy
void * SetPointersTracklets(void *base)
GPUd() bool PreCheckTrackTRDCandidate(const T &trk) const
GPUd() void EnableDebugOutput()
const float const float rowSize
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()