diff --git a/algo/detectors/tof/Clusterizer.cxx b/algo/detectors/tof/Clusterizer.cxx index 930b3c2ad6d9e559ec344e5fabef01cc557dad28..1ad2d527e1cc31096a3af7bdad9713e0a547158c 100644 --- a/algo/detectors/tof/Clusterizer.cxx +++ b/algo/detectors/tof/Clusterizer.cxx @@ -35,14 +35,14 @@ namespace cbm::algo::tof result[chan].emplace_back(pDigi, index); } - /// Sort channel-wise by time - for (size_t chan = 0; chan < fParams.fChanPar.size(); chan++) { - std::sort( - result[chan].begin(), result[chan].end(), - [](const std::pair<const CbmTofDigi*, int32_t>& a, const std::pair<const CbmTofDigi*, int32_t>& b) -> bool { - return a.first->GetTime() < b.first->GetTime(); - }); - } + /// Sort channel-wise by time // not needed if digis are pre-sorted + //for (size_t chan = 0; chan < fParams.fChanPar.size(); chan++) { + // std::sort( + // result[chan].begin(), result[chan].end(), + // [](const std::pair<const CbmTofDigi*, int32_t>& a, const std::pair<const CbmTofDigi*, int32_t>& b) -> bool { + // return a.first->GetTime() < b.first->GetTime(); + // }); + //} return result; } @@ -257,8 +257,8 @@ namespace cbm::algo::tof digiIndRef.push_back(i2->second); // remove digis at positions i1 and i2 from pool in efficient way (replaces two vector::erase calls). - std::copy(i1 + 1, i2, i1); - std::copy(i2 + 1, storDigi.end(), i2 - 1); + std::move(i1 + 1, i2, i1); + std::move(i2 + 1, storDigi.end(), i2 - 1); storDigi.resize(storDigi.size() - 2); if (AddNextChan(input, chan, cluster, clustersOut, digiIndRef)) { diff --git a/algo/detectors/tof/Clusterizer.h b/algo/detectors/tof/Clusterizer.h index 28ad1dbe6a0bece29915c8e6bccd5d6705793430..6a369e4f780d1ee1920925ce8124c9a5114e8ade 100644 --- a/algo/detectors/tof/Clusterizer.h +++ b/algo/detectors/tof/Clusterizer.h @@ -30,18 +30,13 @@ namespace cbm::algo::tof /** ** @brief Constructor. **/ - Clusterizer(std::unique_ptr<ClusterizerRpcPar> params) { fParams = *(std::move(params)); } + Clusterizer(ClusterizerRpcPar params) : fParams(params) {}; /** ** @brief Default constructor. **/ Clusterizer() = default; - /** - ** @brief Destructor. - **/ - ~Clusterizer() = default; - /** ** @brief Build clusters out of ToF Digis and store the resulting info in a TofHit. **/ @@ -50,7 +45,7 @@ namespace cbm::algo::tof private: typedef std::vector<std::pair<const CbmTofDigi*, int32_t>> inputType; - ClusterizerRpcPar fParams = {}; ///< Parameter container + ClusterizerRpcPar fParams; ///< Parameter container std::vector<inputType> chanSortDigis(const std::vector<std::pair<CbmTofDigi, int32_t>>& digisIn); diff --git a/algo/detectors/tof/Hitfind.cxx b/algo/detectors/tof/Hitfind.cxx index bc9863ac069e2b82b2964f79e78a30073253895f..c90838986bf2c57252b488de5009bc574c5da2c5 100644 --- a/algo/detectors/tof/Hitfind.cxx +++ b/algo/detectors/tof/Hitfind.cxx @@ -15,16 +15,8 @@ using fles::Subsystem; namespace cbm::algo::tof { // ----- Constructor ------------------------------------------------------ - Hitfind::Hitfind(tof::HitfindSetup setup) + Hitfind::Hitfind(tof::HitfindSetup setup) : fNbSm(setup.NbSm), fNbRpc(setup.NbRpc), fStorDigi(fNbSm.size()) { - //Number of SMs per super module type - fNbSm = setup.NbSm; - - //Number of RPCs per super module type - fNbRpc = setup.NbRpc; - - //Prepare digi storage - fStorDigi.resize(fNbSm.size()); // Create one algorithm per RPC for TOF and configure it with parametersa for (uint32_t SmType = 0; SmType < fNbSm.size(); SmType++) { @@ -36,7 +28,7 @@ namespace cbm::algo::tof for (int32_t Sm = 0; Sm < NbSm; Sm++) { for (int32_t Rpc = 0; Rpc < NbRpc; Rpc++) { - std::unique_ptr<cbm::algo::tof::ClusterizerRpcPar> par(new cbm::algo::tof::ClusterizerRpcPar()); + auto par = std::make_unique<cbm::algo::tof::ClusterizerRpcPar>(); HitfindSetup::Rpc rpcPar = setup.rpcs[SmType][Sm * NbRpc + Rpc]; par->fDeadStrips = rpcPar.deadStrips; @@ -65,7 +57,7 @@ namespace cbm::algo::tof par->fChanPar[Ch].cell.sizeX = rpcPar.cell.sizeX; par->fChanPar[Ch].cell.sizeY = rpcPar.cell.sizeY; } - fAlgo[SmType].emplace(std::make_pair(Sm * NbRpc + Rpc, tof::Clusterizer(std::move(par)))); + fAlgo[SmType].emplace(std::make_pair(Sm * NbRpc + Rpc, tof::Clusterizer(std::move(*par)))); } } } @@ -102,7 +94,7 @@ namespace cbm::algo::tof // Error already counted for monitoring during Digis calibration, so just discard here continue; } - fStorDigi[SmType][Sm * NbRpc + Rpc].push_back(std::make_pair(*pDigi, idigi)); + fStorDigi[SmType][Sm * NbRpc + Rpc].emplace_back(*pDigi, idigi); } std::vector<Hit> clustersFlat; @@ -153,8 +145,6 @@ 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), chanSizes, chanAddresses); diff --git a/algo/detectors/tof/Hitfind.h b/algo/detectors/tof/Hitfind.h index fcab40e3964e2ca3715050dd93fa0c1fe047028f..59a3e62de1a966df8422757e17a5b9dbc6f0a76f 100644 --- a/algo/detectors/tof/Hitfind.h +++ b/algo/detectors/tof/Hitfind.h @@ -36,8 +36,8 @@ namespace cbm::algo::tof std::string print() const { std::stringstream ss; - ss << "Hitfind stats: num digis " << fNumDigis << ", time " << fTime.wall() << ", num hits " << fNumHits - << std::endl; + ss << "Hitfind stats: num digis " << fNumDigis << ", time " << fTime.wall() << " ms ( " << fTime.throughput() + << " GB/s ), num hits " << fNumHits << std::endl; return ss.str(); } }; @@ -62,23 +62,20 @@ namespace cbm::algo::tof resultType operator()(gsl::span<CbmTofDigi> digiIn); /** @brief Constructor **/ - Hitfind(tof::HitfindSetup); - - /** @brief Destructor **/ - ~Hitfind() {}; + explicit Hitfind(tof::HitfindSetup); private: // members /** @brief TOF hitfinders **/ - std::map<uint32_t, std::map<uint32_t, tof::Clusterizer>> fAlgo = {}; //[nbType][nbSm*nbRpc] - - /** @brief Intermediate storage variables (digi, index) **/ - std::vector<std::vector<std::vector<std::pair<CbmTofDigi, int32_t>>>> fStorDigi; //[nbType][nbSm*nbRpc][nDigis] + std::map<uint32_t, std::map<uint32_t, tof::Clusterizer>> fAlgo; //[nbType][nbSm*nbRpc] /** @brief Number of SMs per super module type **/ std::vector<int32_t> fNbSm; /** @brief Number of RPCs per super module type **/ std::vector<int32_t> fNbRpc; + + /** @brief Intermediate storage variables (digi, index) **/ + std::vector<std::vector<std::vector<std::pair<CbmTofDigi, int32_t>>>> fStorDigi; //[nbType][nbSm*nbRpc][nDigis] }; } // namespace cbm::algo::tof diff --git a/reco/tasks/CbmTaskTofClusterizer.cxx b/reco/tasks/CbmTaskTofClusterizer.cxx index 2e979e2be8972921f233cec5f7f77c3247ccccb4..b44060443a0ec258321f60315647b896925f9604 100644 --- a/reco/tasks/CbmTaskTofClusterizer.cxx +++ b/reco/tasks/CbmTaskTofClusterizer.cxx @@ -353,12 +353,11 @@ bool CbmTaskTofClusterizer::BuildClusters() *fTofCalDigiVec = fCalibrate(fTofDigiVec).first; //Call cluster finder - auto clusterOut = (*fAlgo)(*fTofCalDigiVec); - auto& clusters = std::get<0>(clusterOut); - auto& indices = std::get<2>(clusterOut); - size_t indexOffset = 0; + auto [clusters, monitor, indices] = (*fAlgo)(*fTofCalDigiVec); + LOG(info) << monitor.print(); //Store hits and match + size_t indexOffset = 0; for (auto const& cluster : clusters.Data()) { const int32_t hitIndex = fTofHitsColl->GetEntriesFast(); TVector3 hitpos = TVector3(cluster.hitPos.X(), cluster.hitPos.Y(), cluster.hitPos.Z()); @@ -378,7 +377,6 @@ bool CbmTaskTofClusterizer::BuildClusters() } indexOffset += cluster.numChan() * 2; } - std::cout << "hits " << fiNbHits << std::endl; fdEvent++; return true;