diff --git a/algo/detectors/tof/Clusterizer.cxx b/algo/detectors/tof/Clusterizer.cxx index a00e4d321ada4088e4b220470745363089e554b6..68b462701d1eea61129cbbaf53f147fc689e19aa 100644 --- a/algo/detectors/tof/Clusterizer.cxx +++ b/algo/detectors/tof/Clusterizer.cxx @@ -144,6 +144,7 @@ namespace cbm::algo::tof uint8_t offset = 0; /* D.Smith 14.8.23: This condition is never needed due to time-sorted input (check with PAL and VF) + //D. Smith 8.9.23: Theoretically, this could matter for two digis with identical time stamp but different TOT. Can this even happen? // use digi that is closer to the last one if (storDigi.size() > 2 && storDigi[2].first->GetSide() != storDigi[0].first->GetSide() && storDigi[2].first->GetTime() - storDigi[0].first->GetTime() @@ -151,6 +152,7 @@ namespace cbm::algo::tof offset++; } */ + storDigi.erase(storDigi.begin() + offset); if (2 > storDigi.size()) { break; } } // same condition side end @@ -258,7 +260,7 @@ namespace cbm::algo::tof { //D.Smith 25.8.23: Why are "C" digis (position "2") not considered here? - //const int32_t iDetId = CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType); + //const int32_t iDetId = CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType); //Kept for reference size_t numChan = fParams.fChanPar.size(); int32_t chan = lastChan + 1; @@ -276,6 +278,7 @@ namespace cbm::algo::tof auto i2 = i1; //D.Smith 7.9.23: Do we really need to loop through all remaining digis? //Maybe break at i2 == i1 + 2 ? + //D.Smith 8.9.23: Adding the break condition below probably makes this redundant. while (++i2 < storDigi.end()) { const CbmTofDigi* xDigiA = i1->first; @@ -284,7 +287,15 @@ namespace cbm::algo::tof const double time = 0.5 * (xDigiA->GetTime() + xDigiB->GetTime()); - if (std::abs(time - cluster.weightedTime / cluster.weightsSum) >= fParams.fdMaxTimeDist) { continue; } + //D.Smith 8.9.23: Original continue statement, in general much slower (replaced by the conditions below). + // The optimization relies on time-order. + //if (std::abs(time - cluster.weightedTime / cluster.weightsSum) >= fParams.fdMaxTimeDist) { continue; } + + //Break if digis are in the future of cluster time + if (time - cluster.weightedTime / cluster.weightsSum >= fParams.fdMaxTimeDist) { break; } + + //Continue if digis are in the past of cluster time + if (cluster.weightedTime / cluster.weightsSum - time >= fParams.fdMaxTimeDist) { continue; } const double timeDif = xDigiA->GetTime() - xDigiB->GetTime(); double posY = fParams.fSigVel * timeDif * 0.5;