diff --git a/algo/detectors/tof/Clusterizer.cxx b/algo/detectors/tof/Clusterizer.cxx index 62f7bef70c441e0d6b7e53112cb75786af8e426f..a00e4d321ada4088e4b220470745363089e554b6 100644 --- a/algo/detectors/tof/Clusterizer.cxx +++ b/algo/detectors/tof/Clusterizer.cxx @@ -229,12 +229,7 @@ namespace cbm::algo::tof cluster.reset(); } } - else { - // first fired strip in this RPC - cluster.reset(); - } cluster.add(pos, time, totSum, totSum, storDigi[0].second, storDigi[1].second); - storDigi.erase(storDigi.begin()); storDigi.erase(storDigi.begin()); @@ -264,60 +259,57 @@ 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); - size_t numChan = fParams.fChanPar.size(); - int32_t chan = lastChan + 1; - inputType& storDigi = input[chan]; + size_t numChan = fParams.fChanPar.size(); + int32_t chan = lastChan + 1; while (fParams.fDeadStrips & (1 << chan)) { chan++; if (chan >= numChan) { return false; } } - if (chan == numChan) { return false; } - if (0 == storDigi.size()) { return false; } - bool addedHit = false; - for (size_t i1 = 0; i1 < storDigi.size() - 1; i1++) { - if (addedHit) { break; } + inputType& storDigi = input[chan]; + if (0 == storDigi.size()) { return false; } - size_t i2 = i1; - while (!addedHit && ++i2 < storDigi.size()) { + for (auto i1 = storDigi.begin(); i1 < storDigi.end() - 1; i1++) { - const CbmTofDigi* xDigiA = storDigi[i1].first; - const CbmTofDigi* xDigiB = storDigi[i2].first; + auto i2 = i1; + //D.Smith 7.9.23: Do we really need to loop through all remaining digis? + //Maybe break at i2 == i1 + 2 ? + while (++i2 < storDigi.end()) { + const CbmTofDigi* xDigiA = i1->first; + const CbmTofDigi* xDigiB = i2->first; if (xDigiA->GetSide() == xDigiB->GetSide()) { continue; } + const double time = 0.5 * (xDigiA->GetTime() + xDigiB->GetTime()); if (std::abs(time - cluster.weightedTime / cluster.weightsSum) >= fParams.fdMaxTimeDist) { continue; } - TofCell* cell = &fParams.fChanPar[chan].cell; - const double timeDif = xDigiA->GetTime() - xDigiB->GetTime(); double posY = fParams.fSigVel * timeDif * 0.5; - if (1 != xDigiA->GetSide()) { posY *= -1.; } if (std::abs(posY - cluster.weightedPos.Y() / cluster.weightsSum) >= fParams.fdMaxSpaceDist) { continue; } // append digi pair to current cluster - const double posX = ((-(double) numChan / 2. + chan) + 0.5) * cell->sizeX; + const double posX = ((-(double) numChan / 2. + chan) + 0.5) * fParams.fChanPar[chan].cell.sizeX; const double totSum = xDigiA->GetTot() + xDigiB->GetTot(); ROOT::Math::XYZVector pos(posX, posY, 0.); - cluster.add(pos, time, totSum, totSum, storDigi[i1].second, storDigi[i2].second); + cluster.add(pos, time, totSum, totSum, i1->second, i2->second); // remove selected digis from pool - storDigi.erase(storDigi.begin() + i2); - storDigi.erase(storDigi.begin() + i1); + storDigi.erase(i2); + storDigi.erase(i1); if (AddNextChan(input, chan, cluster, clustersOut)) { return true; // signal hit was already added } - addedHit = true; + i1 = storDigi.end(); // jump to end of outer loop + break; } } - TofCell cell = fParams.fChanPar[0].cell; //D.Smith 17.8.23: This is equivalent to using iDetId, see below //D.Smith 10.8.23: Why pass iDetId here and not iChId? cluster.normalize(fParams.fTimeRes);