Skip to content

Commit 5651740

Browse files
martenoledavidrohr
authored andcommitted
Bugfix in tracklet index array
- forgot to add offset based on collision ID to the tracklet index - noticed only now, because the tracklets were dummy before - for one collision (Run2 format) it was OK, but not for multiple collision within one time frame - added more comments in the code to make it clearer and avoid confusion in the future
1 parent 7aba54d commit 5651740

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ void GPUTRDTracker_t<TRDTRK, PROP>::DoTracking(GPUChainTracking* chainTracking)
208208
for (int iColl = 0; iColl < mNCollisions; ++iColl) {
209209
int nTrklts = 0;
210210
if (mProcessPerTimeFrame) {
211-
// FIXME maybe two nested if statements are not so good in terms of performance?
212211
nTrklts = (iColl < mNCollisions - 1) ? mTriggerRecordIndices[iColl + 1] - mTriggerRecordIndices[iColl] : mNTracklets - mTriggerRecordIndices[iColl];
213212
} else {
214213
nTrklts = mNTracklets;
@@ -498,7 +497,7 @@ GPUd() void GPUTRDTracker_t<TRDTRK, PROP>::DumpTracks()
498497
GPUInfo("There are %i tracks loaded. mNMaxTracks(%i)\n", mNTracks, mNMaxTracks);
499498
for (int i = 0; i < mNTracks; ++i) {
500499
auto* trk = &(mTracks[i]);
501-
GPUInfo("track %i: x=%f, alpha=%f, nTracklets=%i, pt=%f", i, trk->getX(), trk->getAlpha(), trk->GetNtracklets(), trk->getPt());
500+
GPUInfo("track %i: x=%f, alpha=%f, nTracklets=%i, pt=%f, time=%f", i, trk->getX(), trk->getAlpha(), trk->GetNtracklets(), trk->getPt(), trk->getTime());
502501
}
503502
}
504503

@@ -573,7 +572,8 @@ GPUd() bool GPUTRDTracker_t<TRDTRK, PROP>::CalculateSpacePoints(int iCollision)
573572
float c2 = 1.f / (1.f + t2); // cos^2 (tilt)
574573
float sy2 = 0.1f * 0.1f; // sigma_rphi^2, currently assume sigma_rphi = 1 mm
575574

576-
for (int trkltIdx = mTrackletIndexArray[idxOffset + iDet]; trkltIdx < mTrackletIndexArray[idxOffset + iDet + 1]; ++trkltIdx) {
575+
int trkltIdxOffset = mTriggerRecordIndices[iCollision];
576+
for (int trkltIdx = trkltIdxOffset + mTrackletIndexArray[idxOffset + iDet]; trkltIdx < trkltIdxOffset + mTrackletIndexArray[idxOffset + iDet + 1]; ++trkltIdx) {
577577
int trkltZbin = mTracklets[trkltIdx].GetZbin();
578578
float sz2 = pp->GetRowSize(trkltZbin) * pp->GetRowSize(trkltZbin) / 12.f; // sigma_z = l_pad/sqrt(12) TODO try a larger z error
579579
My_Float xTrkltDet[3] = {0.f}; // trklt position in chamber coordinates
@@ -639,6 +639,7 @@ GPUd() bool GPUTRDTracker_t<TRDTRK, PROP>::FollowProlongation(PROP* prop, TRDTRK
639639
int candidateIdxOffset = threadId * 2 * mNCandidates;
640640
int hypothesisIdxOffset = threadId * mNCandidates;
641641
int trkltIdxOffset = collisionId * (kNChambers + 1);
642+
int glbTrkltIdxOffset = mTriggerRecordIndices[collisionId];
642643

643644
auto trkWork = t;
644645
if (mNCandidates > 1) {
@@ -750,7 +751,7 @@ GPUd() bool GPUTRDTracker_t<TRDTRK, PROP>::FollowProlongation(PROP* prop, TRDTRK
750751
}
751752
}
752753
// first propagate track to x of tracklet
753-
for (int trkltIdx = mTrackletIndexArray[trkltIdxOffset + currDet]; trkltIdx < mTrackletIndexArray[trkltIdxOffset + currDet + 1]; ++trkltIdx) {
754+
for (int trkltIdx = glbTrkltIdxOffset + mTrackletIndexArray[trkltIdxOffset + currDet]; trkltIdx < glbTrkltIdxOffset + mTrackletIndexArray[trkltIdxOffset + currDet + 1]; ++trkltIdx) {
754755
if (CAMath::Abs(trkWork->getY() - mSpacePoints[trkltIdx].mX[0]) > roadY || CAMath::Abs(trkWork->getZ() - mSpacePoints[trkltIdx].mX[1]) > roadZ) {
755756
// skip tracklets which are too far away
756757
// although the radii of space points and tracks may differ by ~ few mm the roads are large enough to allow no efficiency loss by this cut

GPU/GPUTracking/TRDTracking/GPUTRDTracker.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class GPUTRDTracker_t : public GPUProcessor
169169
protected:
170170
float* mR; // radial position of each TRD chamber, alignment taken into account, radial spread within chambers < 7mm
171171
bool mIsInitialized; // flag is set upon initialization
172-
bool mProcessPerTimeFrame; // if true, tracking is done per time frame instead of on a single events basis //FIXME is this needed??
172+
bool mProcessPerTimeFrame; // if true, tracking is done per time frame instead of on a single events basis
173173
short mMemoryPermanent; // size of permanent memory for the tracker
174174
short mMemoryTracklets; // size of memory for TRD tracklets
175175
short mMemoryTracks; // size of memory for tracks (used for i/o)
@@ -181,12 +181,15 @@ class GPUTRDTracker_t : public GPUProcessor
181181
int mNCollisions; // number of collisions with TRD tracklet data
182182
int mNTracks; // number of TPC tracks to be matched
183183
int mNEvents; // number of processed events
184-
int* mTriggerRecordIndices; // index of first tracklet for each collision
184+
int* mTriggerRecordIndices; // index of first tracklet for each collision within mTracklets array
185185
float* mTriggerRecordTimes; // time in us for each collision
186-
GPUTRDTrackletWord* mTracklets; // array of all tracklets, later sorted by HCId
186+
GPUTRDTrackletWord* mTracklets; // array of all tracklets (later sorted by HCId for each collision individually)
187187
int mMaxThreads; // maximum number of supported threads
188188
int mNTracklets; // total number of tracklets in event
189-
int* mTrackletIndexArray; // index of first tracklet for each chamber, last entry is the total amount of tracklets
189+
// index of first tracklet for each chamber within mTracklets array, last entry is total number of tracklets for given collision
190+
// the array has (kNChambers + 1) * mNCollisions entries
191+
// note, that for collision iColl one has to add an offset of mTriggerRecordIndices[iColl] to the index stored in mTrackletIndexArray
192+
int* mTrackletIndexArray;
190193
Hypothesis* mHypothesis; // array with multiple track hypothesis
191194
TRDTRK* mCandidates; // array of tracks for multiple hypothesis tracking
192195
GPUTRDSpacePointInternal* mSpacePoints; // array with tracklet coordinates in global tracking frame

0 commit comments

Comments
 (0)