Skip to content

Commit b82b576

Browse files
authored
Preparing to next development for smaller memory footprint (#12256)
* Remove artefacts limits in async processing * Fix cell LUT creation + ROF span simplification * Remove unused function traverseCellsTree() in TrackerTraits class * Remove unused code Errors unrelated
1 parent 37468c1 commit b82b576

3 files changed

Lines changed: 17 additions & 188 deletions

File tree

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TrackerTraits
6262
virtual void findCellsNeighboursHybrid(const int iteration) { LOGP(error, "findCellsNeighboursHybrid: this method should never be called with CPU traits"); }
6363
virtual void findRoadsHybrid(const int iteration) { LOGP(error, "findRoadsHybrid: this method should never be called with CPU traits"); }
6464
virtual void findTracksHybrid(const int iteration) { LOGP(error, "findTracksHybrid: this method should never be called with CPU traits"); }
65-
virtual void findTracks();
65+
virtual void findTracks() { LOGP(error, "findTracks: this method is deprecated."); }
6666
virtual void extendTracks(const int iteration);
6767
virtual void findShortPrimaries();
6868
virtual void setBz(float bz);
@@ -98,7 +98,6 @@ class TrackerTraits
9898
float mBz = 5.f;
9999

100100
private:
101-
void traverseCellsTree(const int, const int);
102101
track::TrackParCov buildTrackSeed(const Cluster& cluster1, const Cluster& cluster2, const TrackingFrameInfo& tf3);
103102
bool fitTrack(TrackITSExt& track, int start, int end, int step, float chi2clcut = o2::constants::math::VeryBig, float chi2ndfcut = o2::constants::math::VeryBig, float maxQoverPt = o2::constants::math::VeryBig, int nCl = 0);
104103

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

Lines changed: 8 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ void TrackerTraits::computeLayerTracklets(const int iteration)
6262

6363
const Vertex diamondVert({mTrkParams[iteration].Diamond[0], mTrkParams[iteration].Diamond[1], mTrkParams[iteration].Diamond[2]}, {25.e-6f, 0.f, 0.f, 25.e-6f, 0.f, 36.f}, 1, 1.f);
6464
gsl::span<const Vertex> diamondSpan(&diamondVert, 1);
65-
for (int rof0{0}; rof0 < tf->getNrof(); ++rof0) {
65+
int startROF{0};
66+
int endROF{tf->getNrof()};
67+
for (int rof0{startROF}; rof0 < endROF; ++rof0) {
6668
gsl::span<const Vertex> primaryVertices = mTrkParams[iteration].UseDiamond ? diamondSpan : tf->getPrimaryVertices(rof0);
67-
int minRof = (rof0 >= mTrkParams[iteration].DeltaROF) ? rof0 - mTrkParams[iteration].DeltaROF : 0;
68-
int maxRof = (rof0 == tf->getNrof() - mTrkParams[iteration].DeltaROF) ? rof0 : rof0 + mTrkParams[iteration].DeltaROF;
69+
int minRof = std::max(startROF, rof0 - mTrkParams[iteration].DeltaROF);
70+
int maxRof = std::min(endROF - 1, rof0 + mTrkParams[iteration].DeltaROF);
6971
#pragma omp parallel for num_threads(mNThreads)
7072
for (int iLayer = 0; iLayer < mTrkParams[iteration].TrackletsPerRoad(); ++iLayer) {
7173
gsl::span<const Cluster> layer0 = tf->getClustersOnLayer(rof0, iLayer);
@@ -303,18 +305,13 @@ void TrackerTraits::computeLayerCells(const int iteration)
303305

304306
if (deltaTanLambda / mTrkParams[iteration].CellDeltaTanLambdaSigma < mTrkParams[iteration].NSigmaCut) {
305307

306-
if (iLayer > 0 && (int)tf->getCellsLookupTable()[iLayer - 1].size() <= iTracklet) {
307-
tf->getCellsLookupTable()[iLayer - 1].resize(iTracklet + 1, tf->getCells()[iLayer].size());
308-
}
309-
310308
/// Track seed preparation. Clusters are numbered progressively from the innermost going outward.
311309
const int clusId[3]{
312310
mTimeFrame->getClusters()[iLayer][currentTracklet.firstClusterIndex].clusterId,
313311
mTimeFrame->getClusters()[iLayer + 1][nextTracklet.firstClusterIndex].clusterId,
314312
mTimeFrame->getClusters()[iLayer + 2][nextTracklet.secondClusterIndex].clusterId};
315313
const auto& cluster1_glo = mTimeFrame->getUnsortedClusters()[iLayer].at(clusId[0]);
316314
const auto& cluster2_glo = mTimeFrame->getUnsortedClusters()[iLayer + 1].at(clusId[1]);
317-
// const auto& cluster3_glo = mTimeFrame->getUnsortedClusters()[iLayer + 2].at(clusId[2]);
318315
const auto& cluster3_tf = mTimeFrame->getTrackingFrameInfoOnLayer(iLayer + 2).at(clusId[2]);
319316
auto track{buildTrackSeed(cluster1_glo, cluster2_glo, cluster3_tf)};
320317

@@ -350,6 +347,9 @@ void TrackerTraits::computeLayerCells(const int iteration)
350347
if (!good) {
351348
continue;
352349
}
350+
if (iLayer > 0 && (int)tf->getCellsLookupTable()[iLayer - 1].size() <= iTracklet) {
351+
tf->getCellsLookupTable()[iLayer - 1].resize(iTracklet + 1, tf->getCells()[iLayer].size());
352+
}
353353
tf->getCells()[iLayer].emplace_back(iLayer, clusId[0], clusId[1], clusId[2],
354354
iTracklet, iNextTracklet, track, chi2);
355355
}
@@ -649,150 +649,6 @@ void TrackerTraits::findRoads(const int iteration)
649649
}
650650
}
651651

652-
void TrackerTraits::findTracks()
653-
{
654-
std::vector<TrackITSExt> tracks(mTimeFrame->getRoads().size());
655-
656-
std::atomic<size_t> trackIndex{0};
657-
#pragma omp parallel for num_threads(mNThreads)
658-
for (size_t ri = 0; ri < mTimeFrame->getRoads().size(); ++ri) {
659-
auto& road = mTimeFrame->getRoads()[ri];
660-
std::vector<int> clusters(mTrkParams[0].NLayers, constants::its::UnusedIndex);
661-
int lastCellLevel = constants::its::UnusedIndex;
662-
int lastCellIndex{-1};
663-
CA_DEBUGGER(int nClusters = 2);
664-
int firstTracklet{constants::its::UnusedIndex};
665-
std::vector<int> tracklets(mTrkParams[0].TrackletsPerRoad(), constants::its::UnusedIndex);
666-
667-
for (int iCell{0}; iCell < mTrkParams[0].CellsPerRoad(); ++iCell) {
668-
const int cellIndex = road[iCell];
669-
if (cellIndex == constants::its::UnusedIndex) {
670-
continue;
671-
} else {
672-
if (firstTracklet == constants::its::UnusedIndex) {
673-
firstTracklet = iCell;
674-
}
675-
tracklets[iCell] = mTimeFrame->getCells()[iCell][cellIndex].getFirstTrackletIndex();
676-
tracklets[iCell + 1] = mTimeFrame->getCells()[iCell][cellIndex].getSecondTrackletIndex();
677-
clusters[iCell] = mTimeFrame->getCells()[iCell][cellIndex].getFirstClusterIndex();
678-
clusters[iCell + 1] = mTimeFrame->getCells()[iCell][cellIndex].getSecondClusterIndex();
679-
clusters[iCell + 2] = mTimeFrame->getCells()[iCell][cellIndex].getThirdClusterIndex();
680-
assert(clusters[iCell] != constants::its::UnusedIndex &&
681-
clusters[iCell + 1] != constants::its::UnusedIndex &&
682-
clusters[iCell + 2] != constants::its::UnusedIndex);
683-
lastCellLevel = iCell;
684-
lastCellIndex = cellIndex;
685-
CA_DEBUGGER(nClusters++);
686-
}
687-
}
688-
689-
CA_DEBUGGER(assert(nClusters >= mTrkParams[0].MinTrackLength));
690-
int count{1};
691-
unsigned short rof{mTimeFrame->getTracklets()[firstTracklet][tracklets[firstTracklet]].rof[0]};
692-
for (int iT = firstTracklet; iT < 6; ++iT) {
693-
if (tracklets[iT] == constants::its::UnusedIndex) {
694-
continue;
695-
}
696-
if (rof == mTimeFrame->getTracklets()[iT][tracklets[iT]].rof[1]) {
697-
count++;
698-
} else {
699-
if (count == 1) {
700-
rof = mTimeFrame->getTracklets()[iT][tracklets[iT]].rof[1];
701-
} else {
702-
count--;
703-
}
704-
}
705-
}
706-
707-
CA_DEBUGGER(assert(nClusters >= mTrkParams[0].MinTrackLength));
708-
CA_DEBUGGER(roadCounters[nClusters - 4]++);
709-
710-
if (lastCellLevel == constants::its::UnusedIndex) {
711-
continue;
712-
}
713-
714-
/// From primary vertex context index to event index (== the one used as input of the tracking code)
715-
for (size_t iC{0}; iC < clusters.size(); iC++) {
716-
if (clusters[iC] != constants::its::UnusedIndex) {
717-
clusters[iC] = mTimeFrame->getClusters()[iC][clusters[iC]].clusterId;
718-
}
719-
}
720-
721-
TrackITSExt temporaryTrack{mTimeFrame->getCells()[lastCellLevel][lastCellIndex]};
722-
temporaryTrack.setChi2(mTimeFrame->getCells()[lastCellLevel][lastCellIndex].getChi2());
723-
for (size_t iC = 0; iC < clusters.size(); ++iC) {
724-
temporaryTrack.setExternalClusterIndex(iC, clusters[iC], clusters[iC] != constants::its::UnusedIndex);
725-
}
726-
bool fitSuccess = fitTrack(temporaryTrack, lastCellLevel - 1, -1, -1, mTrkParams[0].MaxChi2ClusterAttachment, mTrkParams[0].MaxChi2NDF, 1.e3, 3);
727-
if (!fitSuccess) {
728-
continue;
729-
}
730-
CA_DEBUGGER(fitCounters[nClusters - 4]++);
731-
temporaryTrack.resetCovariance();
732-
temporaryTrack.setChi2(0);
733-
fitSuccess = fitTrack(temporaryTrack, 0, mTrkParams[0].NLayers, 1, mTrkParams[0].MaxChi2ClusterAttachment, mTrkParams[0].MaxChi2NDF);
734-
if (!fitSuccess) {
735-
continue;
736-
}
737-
CA_DEBUGGER(backpropagatedCounters[nClusters - 4]++);
738-
temporaryTrack.getParamOut() = temporaryTrack;
739-
temporaryTrack.resetCovariance();
740-
temporaryTrack.setChi2(0);
741-
fitSuccess = fitTrack(temporaryTrack, mTrkParams[0].NLayers - 1, -1, -1, mTrkParams[0].MaxChi2ClusterAttachment, mTrkParams[0].MaxChi2NDF, 50.);
742-
if (!fitSuccess) {
743-
continue;
744-
}
745-
// temporaryTrack.setROFrame(rof);
746-
tracks[trackIndex++] = temporaryTrack;
747-
}
748-
749-
tracks.resize(trackIndex);
750-
751-
if (mApplySmoothing) {
752-
// Smoothing tracks
753-
}
754-
std::sort(tracks.begin(), tracks.end(),
755-
[](TrackITSExt& track1, TrackITSExt& track2) { return track1.isBetter(track2, 1.e6f); });
756-
757-
for (auto& track : tracks) {
758-
int nShared = 0;
759-
for (int iLayer{0}; iLayer < mTrkParams[0].NLayers; ++iLayer) {
760-
if (track.getClusterIndex(iLayer) == constants::its::UnusedIndex) {
761-
continue;
762-
}
763-
nShared += int(mTimeFrame->isClusterUsed(iLayer, track.getClusterIndex(iLayer)));
764-
}
765-
766-
if (nShared > mTrkParams[0].ClusterSharing) {
767-
continue;
768-
}
769-
770-
std::array<int, 3> rofs{INT_MAX, INT_MAX, INT_MAX};
771-
for (int iLayer{0}; iLayer < mTrkParams[0].NLayers; ++iLayer) {
772-
if (track.getClusterIndex(iLayer) == constants::its::UnusedIndex) {
773-
continue;
774-
}
775-
mTimeFrame->markUsedCluster(iLayer, track.getClusterIndex(iLayer));
776-
int currentROF = mTimeFrame->getClusterROF(iLayer, track.getClusterIndex(iLayer));
777-
for (int iR{0}; iR < 3; ++iR) {
778-
if (rofs[iR] == INT_MAX) {
779-
rofs[iR] = currentROF;
780-
}
781-
if (rofs[iR] == currentROF) {
782-
break;
783-
}
784-
}
785-
}
786-
if (rofs[2] != INT_MAX) {
787-
continue;
788-
}
789-
if (rofs[1] != INT_MAX) {
790-
track.setNextROFbit();
791-
}
792-
mTimeFrame->getTracks(std::min(rofs[0], rofs[1])).emplace_back(track);
793-
}
794-
}
795-
796652
void TrackerTraits::extendTracks(const int iteration)
797653
{
798654
if (!mTrkParams.back().UseTrackFollower) {
@@ -1117,39 +973,6 @@ track::TrackParCov TrackerTraits::buildTrackSeed(const Cluster& cluster1, const
1117973
0.f, 0.f, 0.f, 0.f, track::kC1Pt2max});
1118974
}
1119975

1120-
void TrackerTraits::traverseCellsTree(const int currentCellId, const int currentLayerId)
1121-
{
1122-
CellSeed& currentCell{mTimeFrame->getCells()[currentLayerId][currentCellId]};
1123-
const int currentCellLevel = currentCell.getLevel();
1124-
1125-
mTimeFrame->getRoads().back().addCell(currentLayerId, currentCellId);
1126-
1127-
if (currentLayerId > 0 && currentCellLevel > 1) {
1128-
bool isFirstValidNeighbour = true;
1129-
const int startNeighbourId = currentCellId ? mTimeFrame->getCellsNeighboursLUT()[currentLayerId - 1][currentCellId - 1] : 0;
1130-
const int endNeighbourId = mTimeFrame->getCellsNeighboursLUT()[currentLayerId - 1][currentCellId];
1131-
for (int iNeighbourCell{startNeighbourId}; iNeighbourCell < endNeighbourId; ++iNeighbourCell) {
1132-
const int neighbourCellId = mTimeFrame->getCellsNeighbours()[currentLayerId - 1][iNeighbourCell];
1133-
const CellSeed& neighbourCell = mTimeFrame->getCells()[currentLayerId - 1][neighbourCellId];
1134-
1135-
if (currentCellLevel - 1 != neighbourCell.getLevel()) {
1136-
continue;
1137-
}
1138-
1139-
if (isFirstValidNeighbour) {
1140-
isFirstValidNeighbour = false;
1141-
} else {
1142-
mTimeFrame->getRoads().push_back(mTimeFrame->getRoads().back());
1143-
}
1144-
1145-
traverseCellsTree(neighbourCellId, currentLayerId - 1);
1146-
}
1147-
}
1148-
1149-
// TODO: crosscheck for short track iterations
1150-
// currentCell.setLevel(0);
1151-
}
1152-
1153976
void TrackerTraits::setBz(float bz)
1154977
{
1155978
mBz = bz;

Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ void TrackerDPL::init(InitContext& ic)
8686
for (auto& param : trackParams) {
8787
param.ZBins = 64;
8888
param.PhiBins = 32;
89+
param.CellsPerClusterLimit = 1.e3f;
90+
param.TrackletsPerClusterLimit = 1.e3f;
8991
}
9092
trackParams[1].TrackletMinPt = 0.2f;
9193
trackParams[1].CellDeltaTanLambdaSigma *= 2.;
@@ -198,6 +200,7 @@ void TrackerDPL::run(ProcessingContext& pc)
198200
pattIt = patterns.begin();
199201
std::vector<int> savedROF;
200202
auto logger = [&](std::string s) { LOG(info) << s; };
203+
auto fatalLogger = [&](std::string s) { LOG(fatal) << s; };
201204
auto errorLogger = [&](std::string s) { LOG(error) << s; };
202205

203206
FastMultEst multEst; // mult estimator
@@ -266,7 +269,11 @@ void TrackerDPL::run(ProcessingContext& pc)
266269

267270
mTimeFrame->setMultiplicityCutMask(processingMask);
268271
// Run CA tracker
269-
mTracker->clustersToTracks(logger, errorLogger);
272+
if (mMode == "async") {
273+
mTracker->clustersToTracks(logger, fatalLogger);
274+
} else {
275+
mTracker->clustersToTracks(logger, errorLogger);
276+
}
270277
size_t totTracks{mTimeFrame->getNumberOfTracks()}, totClusIDs{mTimeFrame->getNumberOfUsedClusters()};
271278
allTracks.reserve(totTracks);
272279
allClusIdx.reserve(totClusIDs);

0 commit comments

Comments
 (0)