From c27d97fbaf0a20b8b97396029af6e296fe88ba5a Mon Sep 17 00:00:00 2001 From: Renat Dusaev <rdusaev@cern.ch> Date: Sat, 22 Feb 2025 16:16:45 +0100 Subject: [PATCH] time cluss sorted by abs dist from MT --- p348reco/example.cc | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/p348reco/example.cc b/p348reco/example.cc index 5172c928..d67bf667 100644 --- a/p348reco/example.cc +++ b/p348reco/example.cc @@ -1,6 +1,7 @@ // DaqDataDecoding #include "DaqEventsManager.h" #include "DaqEvent.h" +#include <algorithm> using namespace CS; // ROOT @@ -290,18 +291,28 @@ int main(int argc, char *argv[]) // lower_bound(t) will return first element that is not considered // to go before t, i.e. equal or greater than given k. Iterating // from this element will result on clusters ascending by time - std::cout << "Clusters going after master time = " << e.masterTime << ":" << std::endl; - for( auto it = selection.by_time().lower_bound(e.masterTime) - ; it != selection.by_time().end() - ; ++it - ) { - std::ostringstream oss; - auto & entry = *it; - const na64util::p348reco::TimeClusterStats & cluster - = *entry.second->second.second; - oss << " id=" << entry.second->first << ", t'=" - << cluster.mean_time() - e.masterTime; - std::cout << oss.str() << std::endl; + std::cout << "Clusters by distance from master time = " << e.masterTime << ":" << std::endl; + { + std::multimap<double, na64util::p348reco::TimeClusters::Selection::iterator> + byTimeDist; + std::transform( selection.by_time().begin(), selection.by_time().end() + , std::inserter(byTimeDist, byTimeDist.end()) + , [&]( auto & p ) { + return std::pair<double, na64util::p348reco::TimeClusters::Selection::iterator>( + std::fabs(e.masterTime - p.first), p.second); + } ); + for( auto it = byTimeDist.begin() + ; it != byTimeDist.end() + ; ++it + ) { + std::ostringstream oss; + auto & entry = *it; + const na64util::p348reco::TimeClusterStats & cluster + = *entry.second->second.second; + oss << " id=" << entry.second->first << ", t'=" + << cluster.mean_time() - e.masterTime; + std::cout << oss.str() << std::endl; + } } //break; } -- GitLab