From a97b2a1b13bd6c479cc377eb2455ccf1154b0996 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Mon, 8 Jun 2026 13:42:11 +0200 Subject: [PATCH 1/2] EventPlaneHelper: avoid copying FT0 Geometry on every call GetPhiFT0 and SumQvectors took o2::ft0::Geometry by value, causing a full copy (TObject heap allocation + destruction) on every invocation. SumQvectors is called ~208 times per event, so this was ~14% of CPU in Q-vector trains. --- Common/Core/EventPlaneHelper.cxx | 5 ++--- Common/Core/EventPlaneHelper.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Common/Core/EventPlaneHelper.cxx b/Common/Core/EventPlaneHelper.cxx index 9ffd39538a4..6a31b10e823 100644 --- a/Common/Core/EventPlaneHelper.cxx +++ b/Common/Core/EventPlaneHelper.cxx @@ -61,7 +61,7 @@ double EventPlaneHelper::GetPhiFV0(int chno, o2::fv0::Geometry* fv0geom) return TMath::ATan2(chPos.y + offsetY, chPos.x + offsetX); } -double EventPlaneHelper::GetPhiFT0(int chno, o2::ft0::Geometry ft0geom) +double EventPlaneHelper::GetPhiFT0(int chno, const o2::ft0::Geometry& ft0geom) { /* Calculate the azimuthal angle in FT0 for the channel number 'chno'. The offset of FT0-A is taken into account if chno is between 0 and 95. */ @@ -76,12 +76,11 @@ double EventPlaneHelper::GetPhiFT0(int chno, o2::ft0::Geometry ft0geom) ft0geom.calculateChannelCenter(); auto chPos = ft0geom.getChannelCenter(chno); - /// printf("Channel id: %d X: %.3f Y: %.3f\n", chno, chPos.X(), chPos.Y()); return TMath::ATan2(chPos.Y() + offsetY, chPos.X() + offsetX); } -void EventPlaneHelper::SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, o2::ft0::Geometry ft0geom, o2::fv0::Geometry* fv0geom) +void EventPlaneHelper::SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, const o2::ft0::Geometry& ft0geom, o2::fv0::Geometry* fv0geom) { /* Calculate the complex Q-vector for the provided detector and channel number, before adding it to the total Q-vector given as argument. */ diff --git a/Common/Core/EventPlaneHelper.h b/Common/Core/EventPlaneHelper.h index 820af4336c2..1b1cc470db2 100644 --- a/Common/Core/EventPlaneHelper.h +++ b/Common/Core/EventPlaneHelper.h @@ -60,12 +60,12 @@ class EventPlaneHelper } // Methods to calculate the azimuthal angles for each part of FIT, given the channel number. - double GetPhiFT0(int chno, o2::ft0::Geometry ft0geom); + double GetPhiFT0(int chno, const o2::ft0::Geometry& ft0geom); double GetPhiFV0(int chno, o2::fv0::Geometry* fv0geom); // Method to get the Q-vector and sum of amplitudes for any channel in FIT, given // the detector and amplitude. - void SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, o2::ft0::Geometry ft0geom, o2::fv0::Geometry* fv0geom); + void SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, const o2::ft0::Geometry& ft0geom, o2::fv0::Geometry* fv0geom); // Method to get the bin corresponding to a centrality percentile, according to the // centClasses[] array defined in Tasks/qVectorsQA.cxx. From 2b9c129e03b018d65fb67e0e536f7ec0495a1ecb Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Mon, 8 Jun 2026 13:42:38 +0200 Subject: [PATCH 2/2] EventPlaneHelper: invoke geometry invariant helper once calculateChannelCenter() was called inside GetPhiFT0 on every channel, recomputing all 208 channel positions from scratch each time despite the geometry being constant. --- Common/Core/EventPlaneHelper.cxx | 1 - Common/TableProducer/qVectorsTable.cxx | 1 + PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Common/Core/EventPlaneHelper.cxx b/Common/Core/EventPlaneHelper.cxx index 6a31b10e823..49fd347c8a1 100644 --- a/Common/Core/EventPlaneHelper.cxx +++ b/Common/Core/EventPlaneHelper.cxx @@ -74,7 +74,6 @@ double EventPlaneHelper::GetPhiFT0(int chno, const o2::ft0::Geometry& ft0geom) offsetY = mOffsetFT0AY; } - ft0geom.calculateChannelCenter(); auto chPos = ft0geom.getChannelCenter(chno); return TMath::ATan2(chPos.Y() + offsetY, chPos.X() + offsetX); diff --git a/Common/TableProducer/qVectorsTable.cxx b/Common/TableProducer/qVectorsTable.cxx index ba8af37b094..50b362ff3bf 100644 --- a/Common/TableProducer/qVectorsTable.cxx +++ b/Common/TableProducer/qVectorsTable.cxx @@ -256,6 +256,7 @@ struct qVectorsTable { AxisSpec axisChID = {220, 0, 220}; fv0geom = o2::fv0::Geometry::instance(o2::fv0::Geometry::eUninitialized); + ft0geom.calculateChannelCenter(); histosQA.add("ChTracks", "", {HistType::kTHnSparseF, {axisPt, axisEta, axisPhi, axixCent}}); histosQA.add("FT0Amp", "", {HistType::kTH2F, {axisFITamp, axisChID}}); diff --git a/PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx b/PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx index d3afbfe1963..e4a6815e2b7 100644 --- a/PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx +++ b/PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx @@ -444,6 +444,7 @@ struct JEPFlowAnalysis { ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); fv0geom = o2::fv0::Geometry::instance(o2::fv0::Geometry::eUninitialized); + ft0geom.calculateChannelCenter(); detId = getdetId(cfgDetName); refAId = getdetId(cfgRefAName);