Skip to content

Commit 356097f

Browse files
martenoleshahor02
authored andcommitted
TRD: Introduce strict matching mode
1 parent ae290cc commit 356097f

5 files changed

Lines changed: 38 additions & 20 deletions

File tree

Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ void TRDGlobalTracking::init(InitContext& ic)
8585

8686
mTracker = new GPUTRDTracker();
8787
mTracker->SetNCandidates(mRec->GetProcessingSettings().trdNCandidates); // must be set before initialization
88+
if (mStrict && mRec->GetProcessingSettings().trdNCandidates == 1) {
89+
LOG(ERROR) << "Strict matching mode requested, but tracks with another close hypothesis will not be rejected. Please set trdNCandidates to at least 3.";
90+
}
8891
mTracker->SetProcessPerTimeFrame(true);
8992
mTracker->SetGenerateSpacePoints(false); // set to true to force space point calculation by the TRD tracker itself
9093

@@ -228,6 +231,10 @@ void TRDGlobalTracking::run(ProcessingContext& pc)
228231
// skip tracks without TRD tracklets (the collision ID for the TRD tracks is initialized to -1 and only changed if a tracklet is attached to the track)
229232
continue;
230233
}
234+
if (mStrict && (trdTrack.getIsAmbiguous() || trdTrack.getReducedChi2() > mTracker->Param().rec.trd.chi2StrictCut)) {
235+
// skip tracks which have another hypothesis close to the best one or which do are above strict chi2 threshold
236+
continue;
237+
}
231238
nTrackletsAttached += trdTrack.getNtracklets();
232239
auto trackGID = trdTrack.getRefGlobalTrackId();
233240
if (trackGID.includesDet(GTrackID::Source::ITS)) {

GPU/GPUTracking/DataTypes/GPUTRDTrack.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ GPUd() void GPUTRDTrack_t<T>::initialize()
3333
mChi2 = 0.f;
3434
mRefGlobalTrackId = 0;
3535
mCollisionId = -1;
36-
mIsFindable = 0;
36+
mFlags = 0;
3737
for (int i = 0; i < kNLayers; ++i) {
3838
mAttachedTracklets[i] = -1;
3939
}
@@ -80,7 +80,7 @@ GPUd() void GPUTRDTrack_t<T>::ConvertFrom(const GPUTRDTrackDataRecord& t)
8080
T::set(t.fX, t.mAlpha, &(t.fY), t.fC);
8181
setRefGlobalTrackIdRaw(t.fTPCTrackID);
8282
mChi2 = 0.f;
83-
mIsFindable = 0;
83+
mFlags = 0;
8484
mCollisionId = -1;
8585
for (int iLayer = 0; iLayer < kNLayers; iLayer++) {
8686
mAttachedTracklets[iLayer] = t.fAttachedTracklets[iLayer];
@@ -109,7 +109,7 @@ GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t(const o2::tpc::TrackTPC& t) : T(t)
109109

110110
template <typename T>
111111
GPUd() GPUTRDTrack_t<T>::GPUTRDTrack_t(const GPUTRDTrack_t<T>& t)
112-
: T(t), mChi2(t.mChi2), mRefGlobalTrackId(t.mRefGlobalTrackId), mCollisionId(t.mCollisionId), mIsFindable(t.mIsFindable)
112+
: T(t), mChi2(t.mChi2), mRefGlobalTrackId(t.mRefGlobalTrackId), mCollisionId(t.mCollisionId), mFlags(t.mFlags)
113113
{
114114
// copy constructor
115115
for (int i = 0; i < kNLayers; ++i) {
@@ -135,7 +135,7 @@ GPUd() GPUTRDTrack_t<T>& GPUTRDTrack_t<T>::operator=(const GPUTRDTrack_t<T>& t)
135135
mChi2 = t.mChi2;
136136
mRefGlobalTrackId = t.mRefGlobalTrackId;
137137
mCollisionId = t.mCollisionId;
138-
mIsFindable = t.mIsFindable;
138+
mFlags = t.mFlags;
139139
for (int i = 0; i < kNLayers; ++i) {
140140
mAttachedTracklets[i] = t.mAttachedTracklets[i];
141141
}
@@ -148,7 +148,7 @@ GPUd() int GPUTRDTrack_t<T>::getNlayersFindable() const
148148
// returns number of layers in which the track is in active area of TRD
149149
int retVal = 0;
150150
for (int iLy = 0; iLy < kNLayers; iLy++) {
151-
if ((mIsFindable >> iLy) & 0x1) {
151+
if ((mFlags >> iLy) & 0x1) {
152152
++retVal;
153153
}
154154
}

GPU/GPUTracking/DataTypes/GPUTRDTrack.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class GPUTRDTrack_t : public T
6262
public:
6363
enum EGPUTRDTrack {
6464
kNLayers = 6,
65+
kAmbiguousFlag = 6,
6566
kStopFlag = 7
6667
};
6768

@@ -76,7 +77,7 @@ class GPUTRDTrack_t : public T
7677
GPUd() GPUTRDTrack_t(const T& t);
7778
GPUd() GPUTRDTrack_t& operator=(const GPUTRDTrack_t& t);
7879

79-
// attach a tracklet to this track; this overwrites the mIsFindable flag to true for this layer
80+
// attach a tracklet to this track; this overwrites the mFlags flag to true for this layer
8081
GPUd() void addTracklet(int iLayer, int idx) { mAttachedTracklets[iLayer] = idx; }
8182

8283
// getters
@@ -89,8 +90,9 @@ class GPUTRDTrack_t : public T
8990
GPUd() int getNtracklets() const;
9091
GPUd() float getChi2() const { return mChi2; }
9192
GPUd() float getReducedChi2() const { return getNlayersFindable() == 0 ? mChi2 : mChi2 / getNlayersFindable(); }
92-
GPUd() bool getIsStopped() const { return (mIsFindable >> kStopFlag) & 0x1; }
93-
GPUd() bool getIsFindable(int iLayer) const { return (mIsFindable >> iLayer) & 0x1; }
93+
GPUd() bool getIsStopped() const { return (mFlags >> kStopFlag) & 0x1; }
94+
GPUd() bool getIsAmbiguous() const { return (mFlags >> kAmbiguousFlag) & 0x1; }
95+
GPUd() bool getIsFindable(int iLayer) const { return (mFlags >> iLayer) & 0x1; }
9496
GPUd() int getNmissingConsecLayers(int iLayer) const;
9597
// for AliRoot compatibility. To be removed once HLT/global/AliHLTGlobalEsdConverterComponent.cxx does not require them anymore
9698
GPUd() int GetTPCtrackId() const { return mRefGlobalTrackId; }
@@ -102,8 +104,9 @@ class GPUTRDTrack_t : public T
102104
// This method is only defined in TrackTRD.h and is intended to be used only with that TRD track type
103105
GPUd() void setRefGlobalTrackId(o2::dataformats::GlobalTrackID id);
104106
GPUd() void setCollisionId(short id) { mCollisionId = id; }
105-
GPUd() void setIsFindable(int iLayer) { mIsFindable |= (1U << iLayer); }
106-
GPUd() void setIsStopped() { mIsFindable |= (1U << kStopFlag); }
107+
GPUd() void setIsFindable(int iLayer) { mFlags |= (1U << iLayer); }
108+
GPUd() void setIsStopped() { mFlags |= (1U << kStopFlag); }
109+
GPUd() void setIsAmbiguous() { mFlags |= (1U << kAmbiguousFlag); }
107110
GPUd() void setChi2(float chi2) { mChi2 = chi2; }
108111

109112
// conversion to / from HLT track structure (only for AliRoot)
@@ -115,12 +118,12 @@ class GPUTRDTrack_t : public T
115118
unsigned int mRefGlobalTrackId; // raw GlobalTrackID of the seeding track (either ITS-TPC or TPC)
116119
int mAttachedTracklets[kNLayers]; // indices of the tracklets attached to this track; -1 means no tracklet in that layer
117120
short mCollisionId; // the collision ID of the tracklets attached to this track; is used to retrieve the BC information for this track after the tracking is done
118-
unsigned char mIsFindable; // bitfield; LSB indicates whether track is findable in layer 0; MSB flags whether the track is stopped in the TRD; one bit is currently not used
121+
unsigned char mFlags; // bits 0 to 5 indicate whether track is findable in layer 0 to 5, bit 6 indicates an ambiguous track and bit 8 flags if the track is stopped in the TRD
119122

120123
private:
121124
GPUd() void initialize();
122125
#if !defined(GPUCA_STANDALONE) && !defined(GPUCA_ALIROOT_LIB)
123-
ClassDefNV(GPUTRDTrack_t, 1);
126+
ClassDefNV(GPUTRDTrack_t, 2);
124127
#endif
125128
};
126129

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ BeginSubConfig(GPUSettingsRecTRD, trd, configStandalone.rec, "RECTRD", 0, "Recon
8383
AddOptionRTC(minTrackPt, float, .5f, "", 0, "Min Pt for tracks to be propagated through the TRD")
8484
AddOptionRTC(maxChi2, float, 15.f, "", 0, "Max chi2 for TRD tracklets to be matched to a track")
8585
AddOptionRTC(penaltyChi2, float, 12.f, "", 0, "Chi2 penalty for no available TRD tracklet (effective chi2 cut value)")
86+
AddOptionRTC(chi2StrictCut, float, 10.f, "", 0, "Chi2 cut for strict matching mode")
87+
AddOptionRTC(chi2SeparationCut, float, 3.f, "", 0, "Minimum difference between chi2 of winner match and chi2 of second best match")
8688
AddOptionRTC(nSigmaTerrITSTPC, float, 4.f, "", 0, "Number of sigmas for ITS-TPC track time error estimate")
8789
AddOptionRTC(stopTrkAfterNMissLy, unsigned char, 6, "", 0, "Abandon track following after N layers without a TRD match")
8890
AddHelp("help", 'h')

GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,10 @@ GPUd() void GPUTRDTracker_t<TRDTRK, PROP>::DoTrackingThread(int iTrk, int thread
454454
auto trkCopy = trkStart;
455455
prop.setTrack(&trkCopy);
456456
prop.setFitInProjections(true);
457-
FollowProlongation(&prop, &trkCopy, iTrk, threadId, collisionIds[iColl]);
457+
if (!FollowProlongation(&prop, &trkCopy, iTrk, threadId, collisionIds[iColl])) {
458+
// track following failed
459+
continue;
460+
}
458461
if (trkCopy.getReducedChi2() < mTracks[iTrk].getReducedChi2()) {
459462
mTracks[iTrk] = trkCopy; // copy back the resulting track
460463
}
@@ -585,7 +588,8 @@ GPUd() bool GPUTRDTracker_t<TRDTRK, PROP>::FollowProlongation(PROP* prop, TRDTRK
585588
mCandidates[candidateIdxOffset] = *t;
586589
}
587590

588-
int nCandidates = 1;
591+
int nCandidates = 1; // we always start with one candidate
592+
int nCurrHypothesis = 0; // the number of track hypothesis in given iLayer
589593

590594
// search window
591595
float roadY = 0.f;
@@ -595,7 +599,7 @@ GPUd() bool GPUTRDTracker_t<TRDTRK, PROP>::FollowProlongation(PROP* prop, TRDTRK
595599
mDebug->SetGeneralInfo(mNEvents, mNTracks, iTrk, t->getPt());
596600

597601
for (int iLayer = 0; iLayer < kNLayers; ++iLayer) {
598-
int nCurrHypothesis = 0;
602+
nCurrHypothesis = 0;
599603
bool isOK = false; // if at least one candidate could be propagated or the track was stopped this becomes true
600604
int currIdx = candidateIdxOffset + iLayer % 2;
601605
int nextIdx = candidateIdxOffset + (iLayer + 1) % 2;
@@ -745,12 +749,9 @@ GPUd() bool GPUTRDTracker_t<TRDTRK, PROP>::FollowProlongation(PROP* prop, TRDTRK
745749
if (mHypothesis[iUpdate + hypothesisIdxOffset].mCandidateId == -1) {
746750
// no more candidates
747751
if (iUpdate == 0) {
748-
if (ENABLE_WARNING) {
749-
GPUWarning("No valid candidates for track %i in layer %i", iTrk, iLayer);
750-
}
751-
nCandidates = 0;
752+
return false; // no valid candidates for this track (probably propagation failed)
752753
}
753-
break;
754+
break; // go to next layer
754755
}
755756
nCandidates = iUpdate + 1;
756757
if (mNCandidates > 1) {
@@ -876,6 +877,11 @@ GPUd() bool GPUTRDTracker_t<TRDTRK, PROP>::FollowProlongation(PROP* prop, TRDTRK
876877
if (ENABLE_INFO) {
877878
GPUInfo("Ended track following for track %i at x=%f with pt=%f. Attached %i tracklets", t->getRefGlobalTrackIdRaw(), t->getX(), t->getPt(), t->getNtracklets());
878879
}
880+
if (nCurrHypothesis > 1) {
881+
if (CAMath::Abs(mHypothesis[hypothesisIdxOffset + 1].GetReducedChi2() - mHypothesis[hypothesisIdxOffset].GetReducedChi2()) < Param().rec.trd.chi2SeparationCut) {
882+
t->setIsAmbiguous();
883+
}
884+
}
879885
return true;
880886
}
881887

0 commit comments

Comments
 (0)