diff --git a/algo/detectors/tof/Clusterizer.cxx b/algo/detectors/tof/Clusterizer.cxx index b71c1cace4fea801ff2af8dacd901004ca49563f..14490b888874d803d6be99a6b16ba103508df52e 100644 --- a/algo/detectors/tof/Clusterizer.cxx +++ b/algo/detectors/tof/Clusterizer.cxx @@ -49,7 +49,12 @@ namespace cbm::algo::tof { // Hit variables Hit cluster; - std::vector<Hit> clustersOut; + + // Output variables + resultType result; + std::vector<Hit>& clustersOut = std::get<0>(result); // Hits + std::vector<size_t>& chanSizes = std::get<1>(result); // nClusters per channel + std::vector<u32>& chanAddresses = std::get<2>(result); // channel addresses // Reference cell of a cluster TofCell* cell = nullptr; @@ -68,6 +73,11 @@ namespace cbm::algo::tof } for (int32_t chan = 0; chan < numChan; chan++) { + + // Set partition vectors + chanSizes.push_back(clustersOut.size()); + chanAddresses.push_back(fParams.fChanPar[chan].address); + if (fParams.fDeadStrips & (1 << chan)) { continue; } // skip over dead channels inputType& storDigi = input[chan]; @@ -145,9 +155,14 @@ namespace cbm::algo::tof lastPosY = pos.Y(); lastTime = time; AddNextChan(input, lastChan, cluster, clustersOut, &lastChanPos); - } // while( 1 < storDigi.size() ) - storDigi.clear(); //D.Smith 11.8.23: In rare cases, a single digi remains and is deleted here. - } // for( int32_t chan = 0; chan < iNbCh; chan++ ) + } // while( 1 < storDigi.size() ) + + // Apply subtraction such that chanSize constains hit count per channel + chanSizes.back() = clustersOut.size() - chanSizes.back(); + + // In rare cases, a single digi remains and is deleted here. + storDigi.clear(); + } // for( int32_t chan = 0; chan < iNbCh; chan++ ) // Now check if another hit/cluster is started // and save it if it's the case. @@ -155,8 +170,10 @@ namespace cbm::algo::tof cluster.normalize(fParams.fTimeRes); cluster.finalize(*cell, fParams); clustersOut.push_back(cluster); + chanSizes.back()++; } - return clustersOut; + + return result; } bool Clusterizer::AddNextChan(std::vector<inputType>& input, int32_t lastChan, Hit& cluster, diff --git a/algo/detectors/tof/Clusterizer.h b/algo/detectors/tof/Clusterizer.h index aa13c2ebff4efbd71bfbd4d1e12f8fe8eeee6d1d..e1605eeea56118a67863164ce1bdc2817ffca9ad 100644 --- a/algo/detectors/tof/Clusterizer.h +++ b/algo/detectors/tof/Clusterizer.h @@ -21,11 +21,13 @@ class CbmTofDigi; #include <cmath> +#include "PartitionedVector.h" + namespace cbm::algo::tof { class Clusterizer { public: - typedef std::vector<Hit> resultType; + typedef std::tuple<std::vector<Hit>, std::vector<size_t>, std::vector<u32>> resultType; typedef std::vector<std::pair<CbmTofDigi*, int32_t>> inputType; /** diff --git a/algo/detectors/tof/Hitfind.cxx b/algo/detectors/tof/Hitfind.cxx index 06c562a0f6cf742eb1e37567db884cf9ad002bc4..0d09fec500edb12ae298c84479a6ee8088b9d493 100644 --- a/algo/detectors/tof/Hitfind.cxx +++ b/algo/detectors/tof/Hitfind.cxx @@ -44,8 +44,8 @@ namespace cbm::algo::tof } std::vector<Hit> clustersFlat; - std::vector<size_t> rpcSizes; // nClusters per RPC - std::vector<u32> rpcAddresses; // RPC addresses + std::vector<size_t> chanSizes; // nClusters per channel + std::vector<u32> chanAddresses; // channel addresses // --- RPC loop for (uint32_t SmType = 0; SmType < fNbSm.size(); SmType++) { @@ -58,18 +58,22 @@ namespace cbm::algo::tof std::vector<std::pair<CbmTofDigi*, int32_t>>& digiExp = fStorDigi[SmType][Sm * NbRpc + Rpc]; // Build clusters - std::vector<cbm::algo::tof::Hit> clusters = fAlgo[SmType][Sm * NbRpc + Rpc](digiExp); + auto rpcresult = fAlgo[SmType][Sm * NbRpc + Rpc](digiExp); + std::vector<Hit>& clusters = std::get<0>(rpcresult); // Hits + std::vector<size_t>& sizes = std::get<1>(rpcresult); // nClusters per channel + std::vector<u32>& addresses = std::get<2>(rpcresult); // channel addresses + + // Append clusters to output + clustersFlat.insert(clustersFlat.end(), std::make_move_iterator(clusters.begin()), + std::make_move_iterator(clusters.end())); // Store hw address of partition - // TODO: is this correct? Does this address make sense? - u32 rpcAddress = CbmTofAddress::GetUniqueAddress(Sm, Rpc, 0, 0, SmType); - rpcAddresses.push_back(rpcAddress); + chanAddresses.insert(chanAddresses.end(), std::make_move_iterator(addresses.begin()), + std::make_move_iterator(addresses.end())); // store partition size - rpcSizes.push_back(clusters.size()); - - // Append clusters to output - clustersFlat.insert(clustersFlat.end(), clusters.begin(), clusters.end()); + chanSizes.insert(chanSizes.end(), std::make_move_iterator(sizes.begin()), + std::make_move_iterator(sizes.end())); // Clear digi storage digiExp.clear(); @@ -82,8 +86,10 @@ namespace cbm::algo::tof monitor.fNumDigis = digiIn.size(); monitor.fNumHits = clustersFlat.size(); + //L_(info) << MakeReport("HitfindTime", monitor.fTime); + // Create ouput vector - clusterTs = PartitionedVector(std::move(clustersFlat), rpcSizes, rpcAddresses); + clusterTs = PartitionedVector(std::move(clustersFlat), chanSizes, chanAddresses); return result; }