40 LogFunc evalLog = [](
const std::string&) {};
43 mTraits->updateTrackingParameters(mTrkParams);
46 if (mTrkParams[0].PerPrimaryVertexProcessing) {
47 maxNvertices = mTimeFrame->getROFVertexLookupTableView().getMaxVerticesPerROF();
50 int iteration{0}, iVertex{0};
51 auto handleException = [&](
const auto& err) {
52 LOGP(error,
"Too much memory in {} in iteration {} iVtx={}: {:.2f} GB. Current limit is {:.2f} GB, check the detector status and/or the selections.",
53 StateNames[mCurStep], iteration, iVertex,
54 (
double)mTimeFrame->getArtefactsMemory() /
GB,
55 (
double)mTrkParams[iteration].MaxMemory /
GB);
56 if (
typeid(err) !=
typeid(std::bad_alloc)) {
57 LOGP(error,
"Exception: {}", err.what());
59 if (mTrkParams[iteration].DropTFUponFailure) {
62 ++mNumberOfDroppedTFs;
63 error(std::format(
"...Dropping TimeSlice {} (out of {} dropped {})...", mTimeSlice, mTimeFrameCounter, mNumberOfDroppedTFs));
70 for (iteration = 0; iteration < (
int)mTrkParams.size(); ++iteration) {
71 mMemoryPool->setMaxMemory(mTrkParams[iteration].MaxMemory);
73 mTimeFrame->useUPCMask();
75 float timeFrame{0.}, timeTracklets{0.}, timeCells{0.}, timeNeighbours{0.}, timeRoads{0.};
76 size_t nTracklets{0}, nCells{0}, nNeighbours{0};
77 int nTracks{-
static_cast<int>(mTimeFrame->getNumberOfTracks())};
78 iVertex = std::min(maxNvertices, 0);
79 logger(std::format(
"==== ITS {} Tracking iteration {} summary ====", mTraits->getName(), iteration));
80 total += timeFrame = evaluateTask(&Tracker::initialiseTimeFrame, StateNames[mCurStep = TFInit], iteration, evalLog, iteration);
81 logger(std::format(
" - TimeFrame initialisation completed in {:.2f} ms", timeFrame));
83 timeTracklets += evaluateTask(&Tracker::computeTracklets, StateNames[mCurStep = Trackleting], iteration, evalLog, iteration, iVertex);
84 nTracklets += mTraits->getTFNumberOfTracklets();
85 timeCells += evaluateTask(&Tracker::computeCells, StateNames[mCurStep = Celling], iteration, evalLog, iteration);
86 nCells += mTraits->getTFNumberOfCells();
87 timeNeighbours += evaluateTask(&Tracker::findCellsNeighbours, StateNames[mCurStep = Neighbouring], iteration, evalLog, iteration);
88 nNeighbours += mTimeFrame->getNumberOfNeighbours();
89 timeRoads += evaluateTask(&Tracker::findRoads, StateNames[mCurStep = Roading], iteration, evalLog, iteration);
90 }
while (++iVertex < maxNvertices);
91 logger(std::format(
" - Tracklet finding: {} tracklets found in {:.2f} ms", nTracklets, timeTracklets));
92 logger(std::format(
" - Cell finding: {} cells found in {:.2f} ms", nCells, timeCells));
93 logger(std::format(
" - Neighbours finding: {} neighbours found in {:.2f} ms", nNeighbours, timeNeighbours));
94 logger(std::format(
" - Track finding: {} tracks found in {:.2f} ms", nTracks + mTimeFrame->getNumberOfTracks(), timeRoads));
96 logger(std::format(
" - Integrated track extension: {} tracks accepted using {} clusters", mTimeFrame->getNExtendedTracks(), mTimeFrame->getNExtendedClusters()));
98 total += timeTracklets + timeCells + timeNeighbours + timeRoads;
101 handleException(err);
103 }
catch (
const std::bad_alloc& err) {
104 handleException(err);
106 }
catch (
const std::exception& err) {
107 error(std::format(
"Uncaught exception, all bets are off... {}", err.
what()));
109 mTimeFrame->getTracks().clear();
113 if (mTimeFrame->hasMCinformation()) {
114 computeTracksMClabels();
116 rectifyClusterIndices();
128 for (
auto&
track : mTimeFrame->getTracks()) {
129 std::vector<std::pair<MCCompLabel, size_t>> occurrences;
133 const int index =
track.getClusterIndex(iCluster);
137 auto labels = mTimeFrame->getClusterLabels(iCluster,
index);
139 for (
size_t iOcc{0}; iOcc < occurrences.size(); ++iOcc) {
140 std::pair<o2::MCCompLabel, size_t>& occurrence = occurrences[iOcc];
142 if (
label == occurrence.first) {
151 occurrences.emplace_back(
label, 1);
155 std::sort(std::begin(occurrences), std::end(occurrences), [](
auto e1,
auto e2) {
156 return e1.second > e2.second;
159 auto maxOccurrencesValue = occurrences[0].first;
163 auto clid =
track.getClusterIndex(ic);
165 auto labelsSpan = mTimeFrame->getClusterLabels(ic, clid);
166 for (
const auto& currentLabel : labelsSpan) {
167 if (currentLabel == maxOccurrencesValue) {
175 if (occurrences[0].second <
track.getNumberOfClusters()) {
176 maxOccurrencesValue.setFakeFlag();
178 mTimeFrame->getTracksLabel().emplace_back(maxOccurrencesValue);
251 auto avgTF = mTotalTime * 1.e-3 / ((mTimeFrameCounter > 0) ? (
double)mTimeFrameCounter : -1.0);
252 auto avgTFwithDropped = mTotalTime * 1.e-3 / (((mTimeFrameCounter + mNumberOfDroppedTFs) > 0) ? (double)(mTimeFrameCounter + mNumberOfDroppedTFs) : -1.0);
253 LOGP(info,
"Tracker summary: Processed {} TFs (dropped {}) in TOT={:.2f} s, AVG/TF={:.2f} ({:.2f}) s", mTimeFrameCounter, mNumberOfDroppedTFs, mTotalTime * 1.e-3, avgTF, avgTFwithDropped);
254 for (
size_t iteration = 0; iteration < mTimingStats.size(); ++iteration) {
256 const auto& stats = mTimingStats[iteration][
state];
260 LOGP(info,
" - iter {} {}: calls={} total={:.2f} ms avg={:.2f} ms", iteration, StateNames[
state], stats.calls, stats.totalTimeMs, stats.averageTimeMs());