diff --git a/algo/ca/core/tracking/CaTrackFinder.cxx b/algo/ca/core/tracking/CaTrackFinder.cxx index 695dabeaefd6ed6777c86132883580841ed1db79..7884a020508bf5bc0fa837ff7160b662fb239922 100644 --- a/algo/ca/core/tracking/CaTrackFinder.cxx +++ b/algo/ca/core/tracking/CaTrackFinder.cxx @@ -46,6 +46,13 @@ TrackFinder::~TrackFinder() {} // void TrackFinder::FindTracks() { + frAlgo.fRecoTracks.clear(); + frAlgo.fRecoHits.clear(); + if (frAlgo.GetInputData().GetNhits() < 1) { + LOG(warn) << "No hits were passed to the ca::TrackFinder. Stopping the routine"; + return; + } + // // The main CaTrackFinder routine // It splits the input data into sub-timeslices @@ -182,24 +189,29 @@ void TrackFinder::FindTracks() if (fStatTsEnd < fStatTsStart) { // all hits belong to one sub-timeslice - // statTsEnd = statTsStart; + fStatTsEnd = fStatTsStart; } if (fStatTsEnd > fStatTsStart + 500.e6) { // 500 ms maximal length of the TS fStatTsEnd = fStatTsStart + 500.e6; } - LOG(info) << "CA tracker process time slice " << fStatTsStart / 1.e6 << " ms ... " << fStatTsEnd / 1.e6 << " ms with " + LOG(info) << "CA tracker process time slice " << fStatTsStart * 1.e-6 << " -- " << fStatTsEnd * 1.e-6 << " [ms] with " << fStatNhitsTotal << " hits"; int nWindows = static_cast<int>((fStatTsEnd - fStatTsStart - fWindowOverlap - fWindowMargin) / (fWindowLength - fWindowOverlap - fWindowMargin)) + 1; + if (nWindows < 1) { // Situation, when fStatTsEnd == fStatTsStart + nWindows = 1; + } + int nWindowsThread = nWindows / frAlgo.GetNofThreads(); float windowDelta = fWindowLength - fWindowOverlap - fWindowMargin; //LOG(info) << "CA: estimated number of time windows: " << nWindows; + fvWindowStartThread[0] = fStatTsStart; { // Estimation of number of hits in time windows //Timer time; //time.Start(); @@ -247,7 +259,6 @@ void TrackFinder::FindTracks() HitIndex_t nHitsPerThread = nHitsCollected / frAlgo.GetNofThreads(); auto windowIt = nHitsWindow.begin(); size_t iWbegin = 0; - fvWindowStartThread[0] = fStatTsStart; for (int iTh = 1; iTh < frAlgo.GetNofThreads(); ++iTh) { windowIt = std::lower_bound(windowIt, nHitsWindow.end(), iTh * nHitsPerThread); iWbegin = std::distance(nHitsWindow.begin(), windowIt) + 1; @@ -277,8 +288,6 @@ void TrackFinder::FindTracks() frAlgo.fMonitorData.StopTimer(ETimer::PrepareTimeslice); // Save tracks - frAlgo.fRecoTracks.clear(); - frAlgo.fRecoHits.clear(); if (frAlgo.GetNofThreads() == 1) { this->FindTracksThread(0); frAlgo.fMonitorData.StartTimer(ETimer::StoreTracksFinal);