Skip to content

Commit 6b1dd66

Browse files
committed
Use DBSCAN for Time-Z clustering in PVertexing + debris reduction
1 parent 716307c commit 6b1dd66

File tree

4 files changed

+166
-131
lines changed

4 files changed

+166
-131
lines changed

Detectors/Vertexing/include/DetectorsVertexing/PVertexer.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class PVertexer
8080
bool getValidateWithFT0() const { return mValidateWithFT0; }
8181

8282
auto& getTracksPool() const { return mTracksPool; }
83-
auto& getTimeClusters() const { return mTimesClusters; }
83+
auto& getTimeZClusters() const { return mTimeZClusters; }
8484
auto& getSortedTrackIndices() const { return mSortedTrackID; }
8585

8686
auto& getMeanVertex() const { return mMeanVertex; }
@@ -92,7 +92,6 @@ class PVertexer
9292

9393
float estimateScale2()
9494
{
95-
float minrange = std::min(mPVParams->zHistoBinSize, mPVParams->minZSeedRange);
9695
auto sc = mPVParams->zHistoBinSize * mPVParams->zHistoBinSize * mTukey2I / (mStatZErr.getMean() * mStatZErr.getMean());
9796
return sc;
9897
}
@@ -108,11 +107,12 @@ class PVertexer
108107
void applyConstraint(VertexSeed& vtxSeed) const;
109108
bool upscaleSigma(VertexSeed& vtxSeed) const;
110109
void createTracksPool(gsl::span<const o2d::TrackTPCITS> tracksITSTPC);
111-
void clusterizeTimeBruteForce(float margin = 0.1, float cut = 25);
112-
void clusterizeTime(float binSize = 0.1, float maxTDist = 0.6);
113110
int findVertices(const VertexingInput& input, std::vector<PVertex>& vertices, std::vector<int>& vertexTrackIDs, std::vector<V2TRef>& v2tRefs);
114111
std::pair<int, int> getBestFT0Trigger(const PVertex& vtx, gsl::span<const o2::ft0::RecPoints> ft0Data, int& currEntry) const;
115112

113+
int dbscan_RangeQuery(int idxs, std::vector<int>& cand, const std::vector<int>& status);
114+
void dbscan_clusterize();
115+
116116
o2::BunchFilling mBunchFilling;
117117
std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchAbove; // closest filled bunch from above
118118
std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchBelow; // closest filled bunch from below
@@ -123,7 +123,9 @@ class PVertexer
123123
o2::math_utils::StatAccumulator mStatTErr;
124124
std::vector<TrackVF> mTracksPool; ///< tracks in internal representation used for vertexing
125125
std::vector<int> mSortedTrackID; ///< indices of tracks sorted in time
126-
std::vector<TimeCluster> mTimesClusters; ///< set of time clusters
126+
std::vector<TimeZCluster> mTimeZClusters; ///< set of time clusters
127+
std::vector<int> mClusterTrackIDs; ///< IDs of tracks making the clusters
128+
127129
float mBz = 0.; ///< mag.field at beam line
128130
bool mValidateWithFT0 = false; ///< require vertex validation with FT0 (if available)
129131

Detectors/Vertexing/include/DetectorsVertexing/PVertexerHelpers.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ struct TrackVF {
116116
return z + tgL * (vx * cosAlp + vy * sinAlp - x);
117117
}
118118

119+
// weighted distance^2 to other track (accounting for own errors only)
120+
float getDist2(const TrackVF& o) const
121+
{
122+
auto dtnorm2 = (timeEst.getTimeStamp() - o.timeEst.getTimeStamp()) / timeEst.getTimeStampError();
123+
auto dz = z - o.z;
124+
return dtnorm2 + dz * dz * sig2ZI;
125+
}
126+
127+
// weighted distance^2 to other track (accounting for both track errors errors only)
128+
float getDist2Sym(const TrackVF& o) const
129+
{
130+
auto dt = timeEst.getTimeStamp() - o.timeEst.getTimeStamp();
131+
auto dz = z - o.z;
132+
float dte2 = o.timeEst.getTimeStampError() * o.timeEst.getTimeStampError() + timeEst.getTimeStampError() * timeEst.getTimeStampError();
133+
return dt / dte2 + dz * dz / (1. / sig2ZI + 1. / o.sig2ZI);
134+
}
135+
119136
float getResiduals(const PVertex& vtx, float& dy, float& dz) const
120137
{
121138
// get residuals (Y and Z DCA in track frame) and calculate chi2
@@ -139,7 +156,6 @@ struct TrackVF {
139156
};
140157

141158
struct VertexingInput {
142-
gsl::span<TrackVF> tracks;
143159
gsl::span<int> idRange;
144160
TimeEst timeEst{0, -1.}; // negative error means don't use time info
145161
float scaleSigma2 = 10;
@@ -227,7 +243,7 @@ struct SeedHisto {
227243
}
228244
};
229245

230-
struct TimeCluster {
246+
struct TimeZCluster {
231247
TimeEst timeEst;
232248
int first = -1;
233249
int last = -1;
@@ -275,7 +291,7 @@ struct TimeCluster {
275291
}
276292
}
277293

278-
void merge(TimeCluster& c)
294+
void merge(TimeZCluster& c)
279295
{
280296
if (c.first < last) {
281297
first = c.first;

Detectors/Vertexing/include/DetectorsVertexing/PVertexerParams.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@ namespace vertexing
2525
struct PVertexerParams : public o2::conf::ConfigurableParamHelper<PVertexerParams> {
2626
static constexpr float kDefTukey = 5.0f; ///< def.value for tukey constant
2727

28+
// DBSCAN clustering settings
29+
float dbscanMaxDist2 = 9.; ///< distance^2 cut (eps^2).
30+
float dbscanDeltaT = 10.; ///< abs. time difference cut
31+
float dbscanAdaptCoef = 0.1; ///< adapt dbscan minPts for each cluster as minPts=max(minPts, currentSize*dbscanAdaptCoef).
32+
33+
int maxVerticesPerCluster = 1; ///< max vertices per time-z cluster to look for
34+
int maxTrialsPerCluster = 3; ///< max unsucessful trials for vertex search per vertex
35+
36+
// track selection
37+
float dcaTolerance = 1.3; ///< consider tracks within this abs DCA to mean vertex
38+
float pullIniCut = 9; ///< cut on pull (n^2 sigma) on dca to mean vertex
39+
2840
// parameters
29-
float minZSeedRange = 0.5; ///< min proximity of Zseed which should be covered by 1st iteration
3041
float zHistoRange = 20.; ///< +-range of the Zseed histo
3142
float zHistoBinSize = 0.5; ///< size of the Zseed histo bin
3243
float tukey = kDefTukey; ///< 1./[Tukey parameter]^2

0 commit comments

Comments
 (0)