Skip to content

Commit

Permalink
wip: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
aphecetche committed Dec 6, 2023
1 parent 1ede047 commit 714b516
Showing 1 changed file with 35 additions and 36 deletions.
71 changes: 35 additions & 36 deletions Detectors/MUON/MCH/Evaluation/src/clustermap-display.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <sys/stat.h>
#include "DetectorsBase/GeometryManager.h"
#include "MCHContour/Polygon.h"
#include <fmt/format.h>
#include "MCHGlobalMapping/DsIndex.h"

using namespace o2::mch::mapping;

Expand Down Expand Up @@ -333,35 +335,6 @@ std::vector<int> getDualSampasBorNB(int deId, bool isBending)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Getting all DualSampas of NChambers:
std::vector<int> getAllDualSampas(int numChambers)
{

std::vector<int> allDualSampas;
int count = 0;

for (int nChamber = 1; nChamber <= numChambers; nChamber++) {

std::vector<int> deIds = getAllDeIds(nChamber);
std::vector<int> dualSampas;

for (auto deId : deIds) {

std::vector<int> 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)
Expand Down Expand Up @@ -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<int> 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);
Expand All @@ -487,6 +464,31 @@ double calculateNmax(int nChamber, bool bending, const TH1F* ClustersperDualSamp
Nmax = std::max(Nmax, static_cast<double>(nClusters[dsIndex]));
}
}
auto e1 = std::chrono::high_resolution_clock::now();

auto s2 = std::chrono::high_resolution_clock::now();
std::vector<int> 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
Expand Down Expand Up @@ -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<int> nClusters = nClusters_dsindex.first;
std::vector<uint16_t> dsindex = nClusters_dsindex.second;
// std::vector<uint16_t> dsindex = nClusters_dsindex.second;

// Colors Vector in HEX RBG format
std::vector<std::string> colors = colorGradiant();
Expand Down Expand Up @@ -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<o2::mch::contour::BBox<double>> bboxes = {
{-175, -175, 175, 175},
Expand Down Expand Up @@ -816,4 +815,4 @@ int main(int argc, char* argv[])
}

return 0;
}
}

0 comments on commit 714b516

Please sign in to comment.