39 LogFunc evalLog = [](
const std::string&) {};
42 mTraits->updateTrackingParameters(mTrkParams);
45 if (mTrkParams[0].PerPrimaryVertexProcessing) {
46 maxNvertices = mTimeFrame->getROFVertexLookupTableView().getMaxVerticesPerROF();
49 int iteration{0}, iVertex{0};
50 auto handleException = [&](
const auto& err) {
51 LOGP(error,
"Too much memory in {} in iteration {} iVtx={}: {:.2f} GB. Current limit is {:.2f} GB, check the detector status and/or the selections.",
52 StateNames[mCurStep], iteration, iVertex,
53 (
double)mTimeFrame->getArtefactsMemory() /
GB,
54 (
double)mTrkParams[iteration].MaxMemory /
GB);
55 if (
typeid(err) !=
typeid(std::bad_alloc)) {
56 LOGP(error,
"Exception: {}", err.what());
58 if (mTrkParams[iteration].DropTFUponFailure) {
61 ++mNumberOfDroppedTFs;
62 error(std::format(
"...Dropping TimeSlice {} (out of {} dropped {})...", mTimeSlice, mTimeFrameCounter, mNumberOfDroppedTFs));
69 for (iteration = 0; iteration < (
int)mTrkParams.size(); ++iteration) {
70 mMemoryPool->setMaxMemory(mTrkParams[iteration].MaxMemory);
71 if (iteration == 3 && mTrkParams[0].DoUPCIteration) {
72 mTimeFrame->useUPCMask();
74 float timeFrame{0.}, timeTracklets{0.}, timeCells{0.}, timeNeighbours{0.}, timeRoads{0.};
75 size_t nTracklets{0}, nCells{0}, nNeighbours{0};
76 int nTracks{-
static_cast<int>(mTimeFrame->getNumberOfTracks())};
77 iVertex = std::min(maxNvertices, 0);
78 logger(std::format(
"==== ITS {} Tracking iteration {} summary ====", mTraits->getName(), iteration));
79 total += timeFrame = evaluateTask(&Tracker::initialiseTimeFrame, StateNames[mCurStep = TFInit], iteration, evalLog, iteration);
80 logger(std::format(
" - TimeFrame initialisation completed in {:.2f} ms", timeFrame));
82 timeTracklets += evaluateTask(&Tracker::computeTracklets, StateNames[mCurStep = Trackleting], iteration, evalLog, iteration, iVertex);
83 nTracklets += mTraits->getTFNumberOfTracklets();
84 timeCells += evaluateTask(&Tracker::computeCells, StateNames[mCurStep = Celling], iteration, evalLog, iteration);
85 nCells += mTraits->getTFNumberOfCells();
86 timeNeighbours += evaluateTask(&Tracker::findCellsNeighbours, StateNames[mCurStep = Neighbouring], iteration, evalLog, iteration);
87 nNeighbours += mTimeFrame->getNumberOfNeighbours();
88 timeRoads += evaluateTask(&Tracker::findRoads, StateNames[mCurStep = Roading], iteration, evalLog, iteration);
89 }
while (++iVertex < maxNvertices);
90 logger(std::format(
" - Tracklet finding: {} tracklets found in {:.2f} ms", nTracklets, timeTracklets));
91 logger(std::format(
" - Cell finding: {} cells found in {:.2f} ms", nCells, timeCells));
92 logger(std::format(
" - Neighbours finding: {} neighbours found in {:.2f} ms", nNeighbours, timeNeighbours));
93 logger(std::format(
" - Track finding: {} tracks found in {:.2f} ms", nTracks + mTimeFrame->getNumberOfTracks(), timeRoads));
94 total += timeTracklets + timeCells + timeNeighbours + timeRoads;
99 }
catch (
const std::bad_alloc& err) {
100 handleException(err);
102 }
catch (
const std::exception& err) {
103 error(std::format(
"Uncaught exception, all bets are off... {}", err.
what()));
105 mTimeFrame->getTracks().clear();
109 if (mTimeFrame->hasMCinformation()) {
110 computeTracksMClabels();
112 rectifyClusterIndices();
124 for (
auto& track : mTimeFrame->getTracks()) {
125 std::vector<std::pair<MCCompLabel, size_t>> occurrences;
129 const int index = track.getClusterIndex(iCluster);
133 auto labels = mTimeFrame->getClusterLabels(iCluster,
index);
135 for (
size_t iOcc{0}; iOcc < occurrences.size(); ++iOcc) {
136 std::pair<o2::MCCompLabel, size_t>& occurrence = occurrences[iOcc];
138 if (
label == occurrence.first) {
147 occurrences.emplace_back(
label, 1);
151 std::sort(std::begin(occurrences), std::end(occurrences), [](
auto e1,
auto e2) {
152 return e1.second > e2.second;
155 auto maxOccurrencesValue = occurrences[0].first;
156 uint32_t
pattern = track.getPattern();
159 auto clid = track.getClusterIndex(ic);
161 auto labelsSpan = mTimeFrame->getClusterLabels(ic, clid);
162 for (
const auto& currentLabel : labelsSpan) {
163 if (currentLabel == maxOccurrencesValue) {
171 if (occurrences[0].second < track.getNumberOfClusters()) {
172 maxOccurrencesValue.setFakeFlag();
174 mTimeFrame->getTracksLabel().emplace_back(maxOccurrencesValue);
247 auto avgTF = mTotalTime * 1.e-3 / ((mTimeFrameCounter > 0) ? (
double)mTimeFrameCounter : -1.0);
248 auto avgTFwithDropped = mTotalTime * 1.e-3 / (((mTimeFrameCounter + mNumberOfDroppedTFs) > 0) ? (double)(mTimeFrameCounter + mNumberOfDroppedTFs) : -1.0);
249 LOGP(info,
"Tracker summary: Processed {} TFs (dropped {}) in TOT={:.2f} s, AVG/TF={:.2f} ({:.2f}) s", mTimeFrameCounter, mNumberOfDroppedTFs, mTotalTime * 1.e-3, avgTF, avgTFwithDropped);
250 for (
size_t iteration = 0; iteration < mTimingStats.size(); ++iteration) {
252 const auto& stats = mTimingStats[iteration][
state];
256 LOGP(info,
" - iter {} {}: calls={} total={:.2f} ms avg={:.2f} ms", iteration, StateNames[
state], stats.calls, stats.totalTimeMs, stats.averageTimeMs());