From c43c2a8541602e9f30396ce9cac7f98258f93c5b Mon Sep 17 00:00:00 2001 From: Neelkamal Mallick Date: Tue, 17 Nov 2026 09:32:35 +0200 Subject: [PATCH 1/2] [PWGCF] JCorran/Tasks: Added custom centrality binning for SPC analysis --- PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx | 62 ++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx b/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx index cfe7f931a39..5ea49dc96f7 100644 --- a/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx +++ b/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx @@ -35,6 +35,7 @@ #include #include +#include #include @@ -64,6 +65,9 @@ using MyTracks = soa::Join centBinEdgeTree{"CentralityBinEdges", OutputObjHandlingPolicy::AnalysisObject}; + std::vector centBinEdges; FlowJSPCAnalysis spcAnalysis; FlowJSPCAnalysis::JQVectorsT jqvecs; template @@ -95,6 +99,10 @@ struct flowJSPCAnalysis { Configurable cfgMultMin{"cfgMultMin", 10, "Minimum number of particles required for the event to have."}; } cfgEventCuts; + // false: FlowJHistManager bins 0,5,10,20,30,40,50,60,70,100. true: cfgCustomCentBinEdges (at most 9 bins). + Configurable cfgUseCustomCentBins{"cfgUseCustomCentBins", false, "Use cfgCustomCentBinEdges instead of the default centrality bins."}; + Configurable> cfgCustomCentBinEdges{"cfgCustomCentBinEdges", {0.f, 100.f}, "last edge inclusive, e.g. [0,100] or [0,20,40,60,100]"}; + O2_DEFINE_CONFIGURABLE(cfgTrackBitMask, uint16_t, 0, "Track selection bitmask to use as defined in the filterCorrelations.cxx task"); O2_DEFINE_CONFIGURABLE(cfgMultCorrelationsMask, uint16_t, 0, "Selection bitmask for the multiplicity correlations. This should match the filter selection cfgEstimatorBitMask.") O2_DEFINE_CONFIGURABLE(cfgMultCutFormula, std::string, "", "Multiplicity correlations cut formula. A result greater than zero results in accepted event. Parameters: [cFT0C] FT0C centrality, [mFV0A] V0A multiplicity, [mGlob] global track multiplicity, [mPV] PV track multiplicity, [cFT0M] FT0M centrality") @@ -112,12 +120,50 @@ struct flowJSPCAnalysis { uint32_t mNhUse = FlowJSPCAnalysis::NhFull; uint32_t mNkUse = FlowJSPCAnalysis::NkFull; + // Bin index for cfgCustomCentBinEdges. Lower edges are inclusive; the last edge is inclusive. -1 if outside. + int getCustomCentBin(float cValue) const + { + const auto& edges = cfgCustomCentBinEdges.value; + const int nEdges = static_cast(edges.size()); + if (nEdges < 2 || cValue < edges.front() || cValue > edges.back()) { // o2-linter: disable=magic-number (minimum edge count) + return -1; + } + for (int i = 1; i < nEdges - 1; ++i) { + if (cValue < edges[i]) { + return i - 1; + } + } + return nEdges - 2; + } + void init(InitContext const&) { + if (cfgUseCustomCentBins.value) { + const auto& edges = cfgCustomCentBinEdges.value; + if (edges.size() < 2 || edges.size() > 10) { // o2-linter: disable=magic-number (2 to 10 edges, at most 9 bins) + LOGF(fatal, "cfgCustomCentBinEdges must contain 2 to 10 edges (at most 9 bins), got %zu.", edges.size()); + } + for (std::size_t i = 1; i < edges.size(); ++i) { + if (!(edges[i] > edges[i - 1])) { + LOGF(fatal, "cfgCustomCentBinEdges must be strictly increasing."); + } + } + LOGF(info, "Custom centrality bins in use (%zu bins).", edges.size() - 1); + } + // Add histomanager here spcAnalysis.setHistRegistry(&spcHistograms); spcAnalysis.createHistos(); + if (cfgUseCustomCentBins.value) { + centBinEdges.assign(cfgCustomCentBinEdges.value.begin(), cfgCustomCentBinEdges.value.end()); + } else { + centBinEdges = {0.f, 5.f, 10.f, 20.f, 30.f, 40.f, 50.f, 60.f, 70.f, 100.f}; + } + centBinEdgeTree.setObject(new TTree("CentralityBinEdges", "Centrality bin edges")); + centBinEdgeTree->Branch("centBinEdges", ¢BinEdges); + centBinEdgeTree->Fill(); + spcObservables.setSPCObservables(cfgWhichSPC); spcAnalysis.setFullCorrSet(spcObservables.harmonicArray); spcAnalysis.qVectorGrid(cfgWhichSPC, mNhUse, mNkUse); @@ -156,10 +202,20 @@ struct flowJSPCAnalysis { return; float cent = collision.multiplicity(); - if (cent < 0. || cent > 100.) { - return; + int cBin = -1; + if (!cfgUseCustomCentBins.value) { + if (cent < 0. || cent > 100.) { // o2-linter: disable=magic-number (full centrality range) + return; + } + cBin = histManager.getCentBin(cent); + } else { + cBin = getCustomCentBin(cent); + // LOGF(info, "Centrality bin is %d for centrality %f", cBin, cent); + if (cBin < 0 || cBin > 8) { // o2-linter: disable=magic-number (SPC histogram slots are 0-8) + LOGF(info, "Centrality bin %d is out of range", cBin); + return; + } } - int cBin = histManager.getCentBin(cent); spcHistograms.fill(HIST("FullCentrality"), cent); int nTracks = tracks.size(); From 7d92423451e62b1e7e3b4c7b0dcfadade5ae9ae6 Mon Sep 17 00:00:00 2001 From: Neelkamal Mallick Date: Tue, 17 Nov 2026 10:42:03 +0200 Subject: [PATCH 2/2] Added missing headers --- PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx b/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx index 5ea49dc96f7..6c0a786b469 100644 --- a/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx +++ b/PWGCF/JCorran/Tasks/flowJSPCAnalysis.cxx @@ -27,6 +27,7 @@ #include "Common/DataModel/TrackSelectionTables.h" #include +#include #include #include #include @@ -42,6 +43,7 @@ #include #include #include +#include #include #include #include