28 std::vector<inputType> result(
fParams.fChanPar.size());
31 for (
size_t iDigi = 0; iDigi < digisIn.size(); iDigi++) {
32 const CbmTofDigi* pDigi = &digisIn[iDigi].first;
33 const int32_t index = digisIn[iDigi].second;
35 result[chan].emplace_back(pDigi, index);
57 auto& [clustersOut, chanSizes, chanAddresses, digiIndRef] = result;
63 int32_t lastChan = -1;
64 double lastPosY = 0.0;
65 double lastTime = 0.0;
67 const size_t numChan =
fParams.fChanPar.size();
70 std::vector<inputType::iterator> lastChanPos;
71 for (
size_t chan = 0; chan < numChan; chan++) {
72 lastChanPos.push_back(input[chan].begin());
75 for (int32_t chan = 0; (size_t) chan < numChan; chan++) {
78 chanSizes.push_back(clustersOut.size());
79 chanAddresses.push_back(
fParams.fChanPar[chan].address);
82 if (
fParams.fDeadStrips & (1 << chan)) {
87 auto digiIt = storDigi.begin();
89 while (1 < std::distance(digiIt, storDigi.end())) {
90 while (digiIt->first->GetSide() == std::next(digiIt)->first->GetSide()) {
92 if (2 > std::distance(digiIt, storDigi.end())) {
96 if (2 > std::distance(digiIt, storDigi.end())) {
101 cell = &
fParams.fChanPar[chan].cell;
103 const CbmTofDigi* xDigiB = std::next(digiIt)->first;
106 ROOT::Math::XYZVector
pos(((-(
double) numChan / 2. + (
double) chan) + 0.5) * cell->
sizeX, 0., 0.);
115 while (std::distance(digiIt, storDigi.end()) > 2 && std::abs(
pos.Y()) > cell->
sizeY *
fParams.fPosYMaxScal) {
117 const CbmTofDigi* xDigiC = std::next(digiIt, 2)->first;
122 double posYN =
fParams.fSigVel * timeDifN * 0.5;
127 if (std::abs(posYN) >= std::abs(
pos.Y())) {
146 const double time = 0.5 * (xDigiA->
GetTime() + xDigiB->
GetTime());
149 const double totSum = xDigiA->
GetTot() + xDigiB->
GetTot();
156 if (!(std::abs(time - lastTime) <
fParams.fdMaxTimeDist && lastChan == chan - 1
157 && std::abs(
pos.Y() - lastPosY) <
fParams.fdMaxSpaceDist)) {
161 clustersOut.push_back(cluster);
165 cluster.
add(
pos, time, totSum, totSum);
166 digiIndRef.push_back(digiIt->second);
167 digiIndRef.push_back(std::next(digiIt)->second);
173 AddNextChan(input, lastChan, cluster, clustersOut, digiIndRef, &lastChanPos);
177 chanSizes.back() = clustersOut.size() - chanSizes.back();
188 clustersOut.push_back(cluster);
195 std::vector<Hit>& clustersOut, std::vector<int32_t>& digiIndRef,
196 std::vector<inputType::iterator>* lastChanPos)
201 size_t numChan =
fParams.fChanPar.size();
202 int32_t chan = lastChan + 1;
204 while (
fParams.fDeadStrips & (1 << chan)) {
206 if ((
size_t) chan >= numChan) {
210 if ((
size_t) chan == numChan) {
215 if (0 == storDigi.size()) {
223 auto i1 = (lastChanPos ==
nullptr) ? storDigi.begin() : (*lastChanPos)[chan];
227 i1 = std::lower_bound(i1, storDigi.end(), clusterTime -
fParams.fdMaxTimeDist,
228 [
this, cell](
const auto& obj,
double val) {
229 return obj.first->GetTime() + cell.sizeY * fParams.fPosYMaxScal / fParams.fSigVel < val;
236 (*lastChanPos)[chan] = i1;
239 for (; i1 < storDigi.end() - 1; i1++) {
247 while (++i2 < storDigi.end()) {
254 const double time = 0.5 * (xDigiA->
GetTime() + xDigiB->
GetTime());
257 if (time <= clusterTime -
fParams.fdMaxTimeDist) {
262 if (time >= clusterTime +
fParams.fdMaxTimeDist) {
267 double posY =
fParams.fSigVel * timeDif * 0.5;
270 if (std::abs(posY) > cell.
sizeY *
fParams.fPosYMaxScal) {
283 const double posX = ((-(double) numChan / 2. + chan) + 0.5) * cell.
sizeX;
284 const double totSum = xDigiA->
GetTot() + xDigiB->
GetTot();
286 ROOT::Math::XYZVector
pos(posX, posY, 0.);
287 cluster.
add(
pos, time, totSum, totSum);
288 digiIndRef.push_back(i1->second);
289 digiIndRef.push_back(i2->second);
292 std::move(i1 + 1, i2, i1);
293 std::move(i2 + 1, storDigi.end(), i2 - 1);
294 storDigi.resize(storDigi.size() - 2);
296 if (
AddNextChan(input, chan, cluster, clustersOut, digiIndRef)) {
308 clustersOut.push_back(cluster);
bool AddNextChan(std::vector< inputType > &input, int32_t iLastChan, Hit &cluster, std::vector< Hit > &clustersOut, std::vector< int32_t > &digiIndRef, std::vector< inputType::iterator > *lastChanPos=nullptr)