Skip to content

Commit 5491ae4

Browse files
committed
ITS: various changes
1 parent 5e3b188 commit 5491ae4

File tree

11 files changed

+265
-104
lines changed

11 files changed

+265
-104
lines changed

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct TrackingParameters {
5454
int ClusterSharing = 0;
5555
int MinTrackLength = 7;
5656
float NSigmaCut = 5;
57+
float NSigmaCutZ = 5;
58+
float NSigmaCutPhi = 1;
5759
int NTimeSlices{1};
5860
/// Trackleting cuts
5961
float TrackletMinPt = 0.3f;
@@ -84,6 +86,8 @@ struct TrackingParameters {
8486
float SeedingMaxChi2Iter{3.f}; // maximum chi2 change required to end iteration
8587
float SeedingTukeyStartIter{5.f}; // start value for tukey scaling for iteration
8688
float SeedingMinWghTrk{0.05f}; // minimum weight a track has to have to be accounted
89+
float SeedingMinPtTrk{0.0}; // minimum pt for cells to enter pool
90+
float SeedingMaxTglTrk{6.f}; // maximum accepted tgl for cells to enter pool
8791
int SeedingMaxFitIter{3}; // maximum iterations for fit
8892
int SeedingMinTracksIter{50}; // minimum tracks needed for one iteration
8993
int SeedingDBScanMinPt{100}; // DBSCAN: minimum number of cluster points
@@ -98,13 +102,14 @@ struct TrackingParameters {
98102
bool DropTFUponFailure = false;
99103
};
100104

101-
enum RecoIterationSteps : uint8_t {
105+
enum RecoIterationSteps : uint16_t {
102106
/// which steps should be run
103107
kRunTrackleting, // run the trackleting step
104108
kRunCellFinding, // run the cell finding step (connect tracklets)
105109
kRunCellSeeding, // run the cell seeding step (use cells to find seeding vertices)
106110
kRunCellNeighborFinding, // run the cell neighbor finding step (connect cells)
107111
kRunRoadFinding, // run the road finding step (resolve ambiguities to find best roads/tracks)
112+
kRunTruthSeeding, // run truth seeding (imposing MC event information as seeding vertices)
108113
/// extra steps
109114
kUpdateVertexTable, // update the vertex table for the current pool of vertices
110115
kUpdateClusters, // update the cluster position wrt current beam constraint

Detectors/ITSMFT/ITS/tracking/include/ITStracking/MathUtils.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ GPUhdi() float computeCurvatureCentreX(float x1, float y1, float x2, float y2, f
7878

7979
GPUhdi() float computeTanDipAngle(float x1, float y1, float x2, float y2, float z1, float z2)
8080
{
81-
// in case the points vertically align we go to pos/neg inifinity.
81+
// in case the points vertically align we go to pos/neg infinity.
8282
const float d = o2::gpu::CAMath::Hypot(x1 - x2, y1 - y2);
8383
if (o2::gpu::CAMath::Abs(d) < o2::its::constants::Tolerance) {
8484
return ((z1 > z2) ? -1.f : 1.f) * o2::constants::math::VeryBig;
@@ -96,6 +96,11 @@ GPUhdi() float Sq(float v)
9696
return v * v;
9797
}
9898

99+
GPUhdi() float SqDiff(float x, float y)
100+
{
101+
return Sq(x - y);
102+
}
103+
99104
GPUhdi() float MSangle(float mass, float p, float xX0)
100105
{
101106
float beta = p / o2::gpu::CAMath::Hypot(mass, p);

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Seeding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct LinearizedTrack {
7272
uint8_t status{0}; ///< status bits
7373

7474
GPUhdi() void markDead() noexcept { status |= kDead; }
75-
GPUhdi() bool isDead() const noexcept { return (status & kDead) == kDead; }
75+
GPUhdi() bool isDead() const noexcept { return ((status & kDead) == kDead) || cellIdx < 0; }
7676

7777
GPUh() void print() const
7878
{

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct TimeFrame {
106106
int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const;
107107
int getSortedIndex(int rofId, int layer, int idx) const { return mROFramesClusters[layer][rofId] + idx; }
108108
int getSortedStartIndex(const int rofId, const int layer) const { return mROFramesClusters[layer][rofId]; }
109-
int getNrof(int layer) const { return mROFramesClusters[layer].size(); }
109+
int getNrof(int layer) const { return mROFramesClusters[layer].size() - 1; }
110110

111111
auto& getMinRs() { return mMinR; }
112112
auto& getMaxRs() { return mMaxR; }
@@ -119,9 +119,11 @@ struct TimeFrame {
119119
float getPositionResolution(int layer) const { return mPositionResolution[layer]; }
120120
auto& getPositionResolutions() { return mPositionResolution; }
121121

122-
// seeding vertex constraint
122+
// seeding vertex constraint or current best estimate
123123
void setMeanVertex(const dataformats::MeanVertexObject* mv, float extraErr2 = 0.f);
124-
const dataformats::MeanVertexObject* getMeanVertex() const { return mMeanVertex; }
124+
const dataformats::MeanVertexObject* getMeanVertexConstraint() const { return mMeanVertex; }
125+
auto& getMeanVertexRolling() { return mRollingVertex; }
126+
const dataformats::VertexBase& getMeanVertex() const { return (hasMeanVertex()) ? mMeanVertex->getMeanVertex() : mRollingVertex; }
125127
const auto& getMeanVertexInvErr() const { return mMeanVertexXYInvErr; }
126128
bool hasMeanVertex() const noexcept { return mMeanVertex != nullptr; }
127129

@@ -288,19 +290,20 @@ struct TimeFrame {
288290
const o2::base::PropagatorImpl<float>* mPropagatorDevice = nullptr; // Needed only for GPU
289291
float mBz = 999.;
290292
const dataformats::MeanVertexObject* mMeanVertex{nullptr};
293+
dataformats::VertexBase mRollingVertex;
291294
std::array<float, 3> mMeanVertexXYInvErr;
292295
std::array<float, NLayers> mMinR;
293296
std::array<float, NLayers> mMaxR;
294-
bounded_vector<float> mMSangles;
295-
bounded_vector<float> mPhiCuts;
296-
bounded_vector<float> mPositionResolution;
297+
std::array<float, NLayers> mMSangles;
298+
std::array<float, NLayers - 1> mPhiCuts;
299+
std::array<float, NLayers> mPositionResolution;
297300
std::array<bounded_vector<uint8_t>, NLayers> mClusterSize;
298301

299302
bounded_vector<std::array<float, 2>> mPValphaX; /// PV x and alpha for track propagation
300303
std::vector<bounded_vector<MCCompLabel>> mTrackletLabels;
301304
std::vector<bounded_vector<MCCompLabel>> mCellLabels;
302305
std::vector<bounded_vector<int>> mCellsNeighboursLUT;
303-
bounded_vector<int> mBogusClusters; /// keep track of clusters with wild coordinates
306+
std::array<uint32_t, NLayers> mBogusClusters; /// keep track of clusters with wild coordinates
304307

305308
// lookup tables
306309
IndexTableUtilsN mIndexTableUtils;

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Tracker.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class Tracker
7979
void findRoads(int iteration) { mTraits->findRoads(iteration); }
8080
void findShortPrimaries(int iteration) { mTraits->findShortPrimaries(iteration); }
8181
void extendTracks(int iteration) { mTraits->extendTracks(iteration); }
82+
void computeTruthSeeding(int) { mTraits->computeTruthSeeding(); }
8283

8384
void computeTracksMClabels();
8485
void rectifyClusterIndices();
@@ -99,15 +100,17 @@ class Tracker
99100
std::shared_ptr<BoundedMemoryResource> mMemoryPool;
100101

101102
enum State {
102-
TFInit = 0,
103-
Trackleting,
104-
Celling,
105-
Neighbouring,
106-
Roading,
107-
NStates,
103+
kTFInit = 0,
104+
kTrackleting,
105+
kCelling,
106+
kSeeding,
107+
kNeighbouring,
108+
kRoading,
109+
kTruthSeeding,
110+
kNStates,
108111
};
109-
State mCurState{TFInit};
110-
static constexpr std::array<const char*, NStates> StateNames{"TimeFrame initialisation", "Tracklet finding", "Cell finding", "Neighbour finding", "Road finding"};
112+
State mCurState{kTFInit};
113+
static constexpr std::array<const char*, kNStates> StateNames{"TimeFrame initialisation", "Tracklet finding", "Cell finding", "Seeding", "Neighbour finding", "Road finding", "TruthSeeding"};
111114
};
112115

113116
template <int NLayers>

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class TrackerTraits
6666
virtual void extendTracks(const int iteration);
6767
virtual bool supportsFindShortPrimaries() const noexcept { return true; }
6868
virtual void findShortPrimaries(const int iteration);
69+
virtual void computeTruthSeeding();
6970

7071
virtual bool trackFollowing(TrackITSExt* track, int rof, bool outward, const int iteration);
7172
virtual void processNeighbours(int iteration, int iLayer, int iLevel, const bounded_vector<CellSeedN>& currentCellSeed, const bounded_vector<int>& currentCellId, bounded_vector<CellSeedN>& updatedCellSeed, bounded_vector<int>& updatedCellId);

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerPara
3636
float maxChi2ClusterAttachment = -1.f;
3737
float maxChi2NDF = -1.f;
3838
float nSigmaCut = -1.f;
39+
float nSigmaCutZ = -1.f;
40+
float nSigmaCutPhi = -1.f;
3941
float deltaTanLres = -1.f;
4042
float minPt = -1.f;
4143
int LUTbinsPhi = -1;
@@ -67,6 +69,7 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerPara
6769
float seedingDBScanEpsZ{0.1f}; // DBSCAN: maximum epsilon z
6870
float seedingDBScanEpsT{10.f}; // DBSCAN: maximum epsilon t (BC)
6971
float seedingVertexExtraErr2[6] = {0.f}; // impose additional errors on seeding vertices
72+
bool seedingUseMCTruth{false}; // skip seeding and impose MC event information
7073

7174
bool createArtefactLabels{false}; // create on-the-fly labels for the artefacts
7275

Detectors/ITSMFT/ITS/tracking/src/Configuration.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ std::vector<RecoIteration> TrackingMode::getRecoIterations(TrackingMode::Type mo
167167
p.PhiBins = tc.LUTbinsPhi > 0 ? tc.LUTbinsPhi : p.PhiBins;
168168
p.ZBins = tc.LUTbinsZ > 0 ? tc.LUTbinsZ : p.ZBins;
169169
p.NSigmaCut *= tc.nSigmaCut > 0 ? tc.nSigmaCut : 1.f;
170+
p.NSigmaCutZ *= tc.nSigmaCutZ > 0 ? tc.nSigmaCutZ : 1.f;
171+
p.NSigmaCutPhi *= tc.nSigmaCutPhi > 0 ? tc.nSigmaCutPhi : 1.f;
170172
p.CellDeltaTanLambdaSigma *= tc.deltaTanLres > 0 ? tc.deltaTanLres : 1.f;
171173
p.TrackletMinPt *= tc.minPt > 0 ? tc.minPt : 1.f;
172174
p.PerPrimaryVertexProcessing = tc.perPrimaryVertexProcessing;
@@ -209,6 +211,12 @@ std::vector<RecoIteration> TrackingMode::getRecoIterations(TrackingMode::Type mo
209211
recoIterations[0].params.SeedingDBScanMinPt = tc.seedingDBScanMinPt;
210212
recoIterations[0].params.SeedingDBScanEpsZ = tc.seedingDBScanEpsZ;
211213
recoIterations[0].params.SeedingDBScanEpsT = tc.seedingDBScanEpsT;
214+
215+
if (tc.seedingUseMCTruth) {
216+
recoIterations[0].name = "MC_SEEDING";
217+
recoIterations[0].steps.reset();
218+
recoIterations[0].steps.set(kRunTruthSeeding);
219+
}
212220
}
213221

214222
if (mode == TrackingMode::Async) {

Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void TimeFrame<NLayers>::resetROFrameData(size_t nRofs, int layer)
117117
deepVectorClear(mUnsortedClusters[iLayer], getMaybeExternalHostResource());
118118
deepVectorClear(mTrackingFrameInfo[iLayer], getMaybeExternalHostResource());
119119
deepVectorClear(mClusterExternalIndices[iLayer], mMemoryPool.get());
120-
clearResizeBoundedVector(mROFramesClusters[iLayer], nRofs, getMaybeExternalHostResource());
120+
clearResizeBoundedVector(mROFramesClusters[iLayer], nRofs + 1, getMaybeExternalHostResource());
121121
}
122122
}
123123

@@ -214,6 +214,7 @@ void TimeFrame<NLayers>::initialise(const RecoIteration& reco)
214214
{
215215
const auto& trkParam = reco.params;
216216
if (reco.steps[kInitMemory]) {
217+
mBogusClusters.fill(0); // reset bogus counter for this TF
217218
clearResizeBoundedVector(mCells, trkParam.CellsPerRoad(), mMemoryPool.get());
218219
clearResizeBoundedVector(mCellsLookupTable, trkParam.CellsPerRoad() - 1, mMemoryPool.get());
219220
clearResizeBoundedVector(mCellsNeighbours, trkParam.CellsPerRoad() - 1, mMemoryPool.get());
@@ -223,17 +224,14 @@ void TimeFrame<NLayers>::initialise(const RecoIteration& reco)
223224
clearResizeBoundedVector(mTrackletLabels, trkParam.TrackletsPerRoad(), mMemoryPool.get());
224225
clearResizeBoundedVector(mTrackletsLookupTable, trkParam.TrackletsPerRoad(), mMemoryPool.get());
225226
mIndexTableUtils.setTrackingParameters(trkParam);
226-
clearResizeBoundedVector(mPositionResolution, trkParam.NLayers, mMemoryPool.get());
227-
clearResizeBoundedVector(mBogusClusters, trkParam.NLayers, mMemoryPool.get());
228-
for (unsigned int iLayer{0}; iLayer < (int)mClusters.size(); ++iLayer) {
227+
for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) {
229228
clearResizeBoundedVector(mClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeExternalHostResource());
230229
clearResizeBoundedVector(mUsedClusters[iLayer], mUnsortedClusters[iLayer].size(), getMaybeExternalHostResource());
231-
mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt(0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer]) + trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]);
232230
if (iLayer < (int)mCells.size()) {
233231
mTrackletsLookupTable[iLayer].resize(mClusters[iLayer + 1].size() + 1, 0);
234232
}
235233
}
236-
for (unsigned int iLayer{0}; iLayer < (int)mClusters.size(); ++iLayer) {
234+
for (int iLayer{0}; iLayer < NLayers; ++iLayer) {
237235
clearResizeBoundedVector(mIndexTables[iLayer], getNrof(iLayer) * ((trkParam.ZBins * trkParam.PhiBins) + 1), getMaybeExternalHostResource());
238236
}
239237
for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) {
@@ -248,16 +246,20 @@ void TimeFrame<NLayers>::initialise(const RecoIteration& reco)
248246
mMinR.fill(10000.);
249247
mMaxR.fill(-1.);
250248
}
249+
251250
if (reco.steps[kUpdateClusters]) {
252251
prepareClusters(trkParam, reco.params.NLayers);
253252
}
254-
mMSangles.resize(trkParam.NLayers);
255-
mPhiCuts.resize(mClusters.size() - 1, 0.f);
253+
254+
// these change dynamically with the given tracking parameters
255+
mMSangles.fill(0.f);
256+
mPhiCuts.fill(0.f);
257+
mPositionResolution.fill(0.f);
256258
float oneOverR{0.001f * 0.3f * std::abs(mBz) / trkParam.TrackletMinPt};
257-
for (unsigned int iLayer{0}; iLayer < NLayers; ++iLayer) {
259+
for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) {
258260
mMSangles[iLayer] = math_utils::MSangle(0.14f, trkParam.TrackletMinPt, trkParam.LayerxX0[iLayer]);
259261
mPositionResolution[iLayer] = o2::gpu::CAMath::Sqrt(0.5f * (trkParam.SystErrorZ2[iLayer] + trkParam.SystErrorY2[iLayer]) + trkParam.LayerResolution[iLayer] * trkParam.LayerResolution[iLayer]);
260-
if (iLayer < mClusters.size() - 1) {
262+
if (iLayer < trkParam.NLayers - 1) {
261263
const float r1 = trkParam.LayerRadii[iLayer];
262264
const float r2 = trkParam.LayerRadii[iLayer + 1];
263265
const float res1 = mPositionResolution[iLayer];
@@ -269,6 +271,17 @@ void TimeFrame<NLayers>::initialise(const RecoIteration& reco)
269271
mPhiCuts[iLayer] = std::min(o2::gpu::CAMath::ASin(0.5f * x * oneOverR) + 2.f * mMSangles[iLayer] + delta, o2::constants::math::PI * 0.5f);
270272
}
271273
}
274+
275+
if (static bool initOnce{false}; !initOnce) {
276+
initOnce = true;
277+
// initialise the rolling vertex once with large weights
278+
mRollingVertex.setX(0.f);
279+
mRollingVertex.setY(0.f);
280+
mRollingVertex.setZ(0.f);
281+
mRollingVertex.setCov(1e6, dataformats::VertexBase::kCovXX);
282+
mRollingVertex.setCov(1e6, dataformats::VertexBase::kCovYY);
283+
mRollingVertex.setCov(1e6, dataformats::VertexBase::kCovZZ);
284+
}
272285
}
273286

274287
template <int NLayers>
@@ -336,12 +349,8 @@ void TimeFrame<NLayers>::setMemoryPool(std::shared_ptr<BoundedMemoryResource> po
336349
initContainers(mClusterExternalIndices);
337350
initVector(mPrimaryVertices);
338351
initVector(mRoads);
339-
initVector(mMSangles);
340-
initVector(mPhiCuts);
341-
initVector(mPositionResolution);
342352
initContainers(mClusterSize);
343353
initVector(mPValphaX);
344-
initVector(mBogusClusters);
345354
initVector(mTracks);
346355
initContainers(mTracklets);
347356
initContainers(mCells);
@@ -373,12 +382,8 @@ void TimeFrame<NLayers>::wipe()
373382
deepVectorClear(mPrimaryVertices);
374383
deepVectorClear(mTrackletsLookupTable);
375384
deepVectorClear(mClusterExternalIndices);
376-
deepVectorClear(mMSangles);
377-
deepVectorClear(mPhiCuts);
378-
deepVectorClear(mPositionResolution);
379385
deepVectorClear(mClusterSize);
380386
deepVectorClear(mPValphaX);
381-
deepVectorClear(mBogusClusters);
382387
// if we use the external host allocator then the assumption is that we
383388
// don't clear the memory ourself
384389
if (!hasExternalHostAllocator()) {

Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,32 @@ void Tracker<NLayers>::clustersToTracks(const LogFunc& logger, const LogFunc& er
9494
iVertex = std::min(maxNvertices, 0);
9595
logger(std::format("==== ITS {} Tracking iteration {} summary ==== ({})", mTraits->getName(), iteration, reco.name));
9696

97-
total += evaluateTask(&Tracker::initialiseTimeFrame, StateNames[mCurState = TFInit], iteration, logger);
97+
if (reco.steps[kRunTruthSeeding]) {
98+
evaluateTask(&Tracker::computeTruthSeeding, StateNames[mCurState = kTruthSeeding], iteration, evalLog);
99+
continue;
100+
}
101+
102+
total += evaluateTask(&Tracker::initialiseTimeFrame, StateNames[mCurState = kTFInit], iteration, logger);
98103
do {
99104
for (iSlice = 0; iSlice < reco.params.NTimeSlices; ++iSlice) {
100105
if (reco.steps[kRunTrackleting]) {
101-
timeTracklets += evaluateTask(&Tracker::computeTracklets, StateNames[mCurState = Trackleting], iteration, evalLog, iSlice, iVertex);
106+
timeTracklets += evaluateTask(&Tracker::computeTracklets, StateNames[mCurState = kTrackleting], iteration, evalLog, iSlice, iVertex);
102107
nTracklets += mTraits->getTFNumberOfTracklets();
103108
}
104109
if (reco.steps[kRunCellFinding]) {
105-
timeCells += evaluateTask(&Tracker::computeCells, StateNames[mCurState = Celling], iteration, evalLog);
110+
timeCells += evaluateTask(&Tracker::computeCells, StateNames[mCurState = kCelling], iteration, evalLog);
106111
nCells += mTraits->getTFNumberOfCells();
107112
}
108113
if (reco.steps[kRunCellSeeding]) {
109-
timeCellSeeds += evaluateTask(&Tracker::findCellSeeds, StateNames[mCurState = Celling], iteration, evalLog);
114+
timeCellSeeds += evaluateTask(&Tracker::findCellSeeds, StateNames[mCurState = kSeeding], iteration, evalLog);
110115
nCellSeeds += mTimeFrame->getPrimaryVerticesNum();
111116
}
112117
if (reco.steps[kRunCellNeighborFinding]) {
113-
timeNeighbours += evaluateTask(&Tracker::findCellsNeighbours, StateNames[mCurState = Neighbouring], iteration, evalLog);
118+
timeNeighbours += evaluateTask(&Tracker::findCellsNeighbours, StateNames[mCurState = kNeighbouring], iteration, evalLog);
114119
nNeighbours += mTimeFrame->getNumberOfNeighbours();
115120
}
116121
if (reco.steps[kRunRoadFinding]) {
117-
timeRoads += evaluateTask(&Tracker::findRoads, StateNames[mCurState = Roading], iteration, evalLog);
122+
timeRoads += evaluateTask(&Tracker::findRoads, StateNames[mCurState = kRoading], iteration, evalLog);
118123
}
119124
}
120125
} while (++iVertex < maxNvertices);

0 commit comments

Comments
 (0)