From 714b516df85cec74f4895d594551f473dd7a293b Mon Sep 17 00:00:00 2001 From: Laurent Aphecetche Date: Wed, 6 Dec 2023 18:41:13 +0100 Subject: [PATCH] wip: simplify --- .../MCH/Evaluation/src/clustermap-display.cxx | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/Detectors/MUON/MCH/Evaluation/src/clustermap-display.cxx b/Detectors/MUON/MCH/Evaluation/src/clustermap-display.cxx index 501c2d259ca1b..10269ba8ba35b 100644 --- a/Detectors/MUON/MCH/Evaluation/src/clustermap-display.cxx +++ b/Detectors/MUON/MCH/Evaluation/src/clustermap-display.cxx @@ -35,6 +35,8 @@ #include #include "DetectorsBase/GeometryManager.h" #include "MCHContour/Polygon.h" +#include +#include "MCHGlobalMapping/DsIndex.h" using namespace o2::mch::mapping; @@ -333,35 +335,6 @@ std::vector getDualSampasBorNB(int deId, bool isBending) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Getting all DualSampas of NChambers: -std::vector getAllDualSampas(int numChambers) -{ - - std::vector allDualSampas; - int count = 0; - - for (int nChamber = 1; nChamber <= numChambers; nChamber++) { - - std::vector deIds = getAllDeIds(nChamber); - std::vector dualSampas; - - for (auto deId : deIds) { - - std::vector dsIds = getDualSampas(deId); - - for (auto dsId : dsIds) { - dsId += count; - dualSampas.push_back(dsId); - } - } - - count = dualSampas.back() + 1; - allDualSampas.insert(allDualSampas.end(), dualSampas.begin(), dualSampas.end()); - } - - return allDualSampas; -} - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Convert DsIndex (Global) to DsId (Local) @@ -462,17 +435,21 @@ double calculateNmax(int nChamber, bool bending, const TH1F* ClustersperDualSamp { // Load clusters from TH1F Histogram - auto nClusters_dsindex = processClustersperDualSampa(ClustersperDualSampa); - std::vector nClusters = nClusters_dsindex.first; + auto [nClusters, _] = processClustersperDualSampa(ClustersperDualSampa); // Getting all DeIds for all Chambers auto deIds = getAllDeIds(nChamber); int dsIndex; double Nmax = 0.0; + // auto tStart = std::chrono::high_resolution_clock::now(); + // const auto& tracks = mTrackFinder.findTracks(clustersIn.subspan(clusterROF.getFirstIdx(), clusterROF.getNEntries())); + // auto tEnd = std::chrono::high_resolution_clock::now(); + // mElapsedTime += tEnd - tStart; if (IsNormalizedPerDSArea == false) { + auto s1 = std::chrono::high_resolution_clock::now(); // Calculate maximum number of clusters for (auto deId : deIds) { auto dualSampaContoursOut = transformLocalToGlobal(deId, bending, transformation); @@ -487,6 +464,31 @@ double calculateNmax(int nChamber, bool bending, const TH1F* ClustersperDualSamp Nmax = std::max(Nmax, static_cast(nClusters[dsIndex])); } } + auto e1 = std::chrono::high_resolution_clock::now(); + + auto s2 = std::chrono::high_resolution_clock::now(); + std::vector dsOfChamber = nClusters; + for (auto dsix = 0; dsix < nClusters.size(); dsix++) { + auto dsDetId = o2::mch::getDsDetId(dsix); + double v = nClusters[dsix]; + if (bending && dsDetId.dsId() >= 1024) { + dsOfChamber[dsix] = 0; + continue; + } + if (!bending && dsDetId.dsId() < 1024) { + dsOfChamber[dsix] = 0; + continue; + } + if (dsDetId.deId() / 100 != nChamber) { + dsOfChamber[dsix] = 0; + } + } + auto e2 = std::chrono::high_resolution_clock::now(); + auto simpler = *std::max_element(dsOfChamber.begin(), dsOfChamber.end()); + auto duration1 = (e1 - s1).count(); + auto duration2 = (e2 - s2).count(); + std::cout << fmt::format("TOTO nChamber={} Nmax={} simpler={} duration1/duration2={}\n", + nChamber, Nmax, simpler, duration1 / duration2); } else { // Calculate maximum ratio of clusters/DSArea @@ -652,7 +654,7 @@ void svgChamber(o2::mch::contour::SVGWriter& w, int nChamber, bool bending, cons // Load clusters from TH1F Histogram auto nClusters_dsindex = processClustersperDualSampa(ClustersperDualSampa); std::vector nClusters = nClusters_dsindex.first; - std::vector dsindex = nClusters_dsindex.second; + // std::vector dsindex = nClusters_dsindex.second; // Colors Vector in HEX RBG format std::vector colors = colorGradiant(); @@ -762,9 +764,6 @@ int main(int argc, char* argv[]) green = true; } - // Get All dualSampas for 10 chambers - getAllDualSampas(10); - // Define the bounding boxes for the 10 images: std::vector> bboxes = { {-175, -175, 175, 175}, @@ -816,4 +815,4 @@ int main(int argc, char* argv[]) } return 0; -} \ No newline at end of file +}