1515
1616#include " ITStracking/Vertexer.h"
1717#include " ITStracking/BoundedAllocator.h"
18- #include " ITStracking/Cluster.h"
19-
20- #include " ITStracking/ClusterLines.h"
21- #include " ITStracking/Tracklet.h"
22- #include " ITStracking/IndexTableUtils.h"
2318#include " ITStracking/VertexerTraits.h"
2419#include " ITStracking/TrackingConfigParam.h"
2520
@@ -41,16 +36,17 @@ float Vertexer<NLayers>::clustersToVertices(LogFunc logger)
4136 LogFunc evalLog = [](const std::string&) {};
4237
4338 if (mTimeFrame ->hasMCinformation () && mVertParams [0 ].useTruthSeeding ) {
44- float t = evaluateTask (&Vertexer::addTruthSeeds, StateNames[mCurState = TruthSeeding], 0 , evalLog);
39+ float t = evaluateTask (&Vertexer::addTruthSeeds, StateNames[mCurStep = TruthSeeding], 0 , evalLog);
4540 sortVertices ();
41+ ++mTimeFrameCounter ;
4642 return t;
4743 }
4844
4945 TrackingParameters trkPars;
5046 mTraits ->updateVertexingParameters (mVertParams );
5147
5248 auto handleException = [&](const auto & err) {
53- LOGP (error, " Encountered critical error in step {}, stopping further processing of this TF: {}" , StateNames[mCurState ], err.what ());
49+ LOGP (error, " Encountered critical error in step {}, stopping further processing of this TF: {}" , StateNames[mCurStep ], err.what ());
5450 if (!mVertParams [0 ].DropTFUponFailure ) {
5551 throw err;
5652 } else {
@@ -59,22 +55,23 @@ float Vertexer<NLayers>::clustersToVertices(LogFunc logger)
5955 };
6056
6157 float timeTracklet{0 .f }, timeSelection{0 .f }, timeVertexing{0 .f }, timeInit{0 .f };
58+ bool completed = false ;
6259 try {
6360 for (int iteration = 0 ; iteration < (int )mVertParams .size (); ++iteration) {
6461 mMemoryPool ->setMaxMemory (mVertParams [iteration].MaxMemory );
6562 unsigned int nTracklets01{0 }, nTracklets12{0 };
6663 logger (fmt::format (" === ITS {} Seeding vertexer iteration {} summary:" , mTraits ->getName (), iteration));
6764 trkPars.PhiBins = mTraits ->getVertexingParameters ()[0 ].PhiBins ;
6865 trkPars.ZBins = mTraits ->getVertexingParameters ()[0 ].ZBins ;
69- auto timeInitIteration = evaluateTask (&Vertexer::initialiseVertexer, StateNames[mCurState = Init], iteration, evalLog, trkPars, iteration);
70- auto timeTrackletIteration = evaluateTask (&Vertexer::findTracklets, StateNames[mCurState = Trackleting], iteration, evalLog, iteration);
66+ auto timeInitIteration = evaluateTask (&Vertexer::initialiseVertexer, StateNames[mCurStep = Init], iteration, evalLog, trkPars, iteration);
67+ auto timeTrackletIteration = evaluateTask (&Vertexer::findTracklets, StateNames[mCurStep = Trackleting], iteration, evalLog, iteration);
7168 nTracklets01 = mTimeFrame ->getTotalTrackletsTF (0 );
7269 nTracklets12 = mTimeFrame ->getTotalTrackletsTF (1 );
73- auto timeSelectionIteration = evaluateTask (&Vertexer::validateTracklets, StateNames[mCurState = Validating ], iteration, evalLog, iteration);
70+ auto timeSelectionIteration = evaluateTask (&Vertexer::validateTracklets, StateNames[mCurStep = Selection ], iteration, evalLog, iteration);
7471 const auto nVerticesBefore = mTimeFrame ->getPrimaryVertices ().size ();
75- auto timeVertexingIteration = evaluateTask (&Vertexer::findVertices, StateNames[mCurState = Finding], iteration, evalLog, iteration);
72+ auto timeVertexingIteration = evaluateTask (&Vertexer::findVertices, StateNames[mCurStep = Finding], iteration, evalLog, iteration);
7673 const auto nVerticesAfter = mTimeFrame ->getPrimaryVertices ().size ();
77- printEpilog (logger, nTracklets01, nTracklets12, mTimeFrame ->getNLinesTotal (), nVerticesAfter - nVerticesBefore, nVerticesAfter, timeTrackletIteration, timeSelectionIteration, timeVertexingIteration);
74+ printEpilog (logger, nTracklets01, nTracklets12, mTimeFrame ->getNLinesTotal (), nVerticesAfter - nVerticesBefore, nVerticesAfter, timeInitIteration, timeTrackletIteration, timeSelectionIteration, timeVertexingIteration);
7875 timeInit += timeInitIteration;
7976 timeTracklet += timeTrackletIteration;
8077 timeSelection += timeSelectionIteration;
@@ -84,6 +81,7 @@ float Vertexer<NLayers>::clustersToVertices(LogFunc logger)
8481 sortVertices ();
8582 mTimeFrame ->updateROFVertexLookupTable ();
8683 }
84+ completed = true ;
8785 } catch (const BoundedMemoryResource::MemoryLimitExceeded& err) {
8886 handleException (err);
8987 } catch (const std::bad_alloc& err) {
@@ -92,6 +90,10 @@ float Vertexer<NLayers>::clustersToVertices(LogFunc logger)
9290 LOGP (fatal, " Uncaught exception!" );
9391 }
9492
93+ if (completed) {
94+ ++mTimeFrameCounter ;
95+ }
96+
9597 return timeInit + timeTracklet + timeSelection + timeVertexing;
9698}
9799
@@ -135,15 +137,43 @@ void Vertexer<NLayers>::adoptTimeFrame(TimeFrameN& tf)
135137 mTraits ->adoptTimeFrame (&tf);
136138}
137139
140+ template <int NLayers>
141+ void Vertexer<NLayers>::addTimingStatCurStep(int iteration, double timeMs)
142+ {
143+ if (iteration < 0 ) {
144+ return ;
145+ }
146+ if (mTimingStats .size () < (iteration + 1 )) {
147+ mTimingStats .resize (iteration + 1 );
148+ }
149+ mTimingStats [iteration][mCurStep ].add (timeMs);
150+ }
151+
152+ template <int NLayers>
153+ void Vertexer<NLayers>::printSummary() const
154+ {
155+ LOGP (info, " Vertexer summary: Processed {} TFs" , mTimeFrameCounter );
156+ for (size_t iteration = 0 ; iteration < mTimingStats .size (); ++iteration) {
157+ for (size_t state = 0 ; state < NSteps; ++state) {
158+ const auto & stats = mTimingStats [iteration][state];
159+ if (!stats.calls ) {
160+ continue ;
161+ }
162+ LOGP (info, " - iter {} {}: calls={} total={:.2f} ms avg={:.2f} ms" , iteration, StateNames[state], stats.calls , stats.totalTimeMs , stats.averageTimeMs ());
163+ }
164+ }
165+ }
166+
138167template <int NLayers>
139168void Vertexer<NLayers>::printEpilog(LogFunc& logger,
140- const unsigned int trackletN01, const unsigned int trackletN12,
141- const unsigned selectedN, const unsigned int vertexN, const unsigned int totalVertexN,
142- const float trackletT, const float selecT, const float vertexT)
169+ unsigned int trackletN01, unsigned int trackletN12,
170+ unsigned selectedN, unsigned int vertexN, unsigned int totalVertexN,
171+ float initT, float trackletT, float selecT, float vertexT)
143172{
144- logger (fmt::format (" - {} Vertexer: found {} | {} tracklets in: {:.2f} ms" , mTraits ->getName (), trackletN01, trackletN12, trackletT));
145- logger (fmt::format (" - {} Vertexer: selected {} tracklets in: {:.2f} ms" , mTraits ->getName (), selectedN, selecT));
146- logger (fmt::format (" - {} Vertexer: found {} vertices (total: {}) in: {:.2f} ms" , mTraits ->getName (), vertexN, totalVertexN, vertexT));
173+ logger (fmt::format (" - {}: completed in {:.2f} ms" , StateNames[Init], initT));
174+ logger (fmt::format (" - {}: found {} | {} tracklets in {:.2f} ms" , StateNames[Trackleting], trackletN01, trackletN12, trackletT));
175+ logger (fmt::format (" - {}: selected {} tracklets in {:.2f} ms" , StateNames[Selection], selectedN, selecT));
176+ logger (fmt::format (" - {}: found {} vertices (total {}) in {:.2f} ms" , StateNames[Finding], vertexN, totalVertexN, vertexT));
147177}
148178
149179template class Vertexer <7 >;
0 commit comments