Skip to content
Snippets Groups Projects
Commit 3b6dd0f1 authored by Dominik Smith's avatar Dominik Smith Committed by Dominik Smith
Browse files

cbm::algo::tof::Hitfind: Cleanup.

parent 2608ae8b
No related branches found
No related tags found
1 merge request!1485RAII scheme for TOF online algorithms.
Pipeline #25579 passed
......@@ -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)) {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment