Skip to content

Commit a81acb0

Browse files
committed
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. Additionally, calculateChannelCenter() was called inside GetPhiFT0 on every channel, recomputing all 208 channel positions from scratch each time despite the geometry being constant. Fix: - Pass ft0::Geometry by const reference - Call calculateChannelCenter() once at init time - Remove the per-call calculateChannelCenter() from GetPhiFT0
1 parent 17f25d5 commit a81acb0

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

Common/Core/EventPlaneHelper.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ double EventPlaneHelper::GetPhiFV0(int chno, o2::fv0::Geometry* fv0geom)
6161
return TMath::ATan2(chPos.y + offsetY, chPos.x + offsetX);
6262
}
6363

64-
double EventPlaneHelper::GetPhiFT0(int chno, o2::ft0::Geometry ft0geom)
64+
double EventPlaneHelper::GetPhiFT0(int chno, const o2::ft0::Geometry& ft0geom)
6565
{
6666
/* Calculate the azimuthal angle in FT0 for the channel number 'chno'. The offset
6767
of FT0-A is taken into account if chno is between 0 and 95. */
@@ -74,14 +74,12 @@ double EventPlaneHelper::GetPhiFT0(int chno, o2::ft0::Geometry ft0geom)
7474
offsetY = mOffsetFT0AY;
7575
}
7676

77-
ft0geom.calculateChannelCenter();
7877
auto chPos = ft0geom.getChannelCenter(chno);
79-
/// printf("Channel id: %d X: %.3f Y: %.3f\n", chno, chPos.X(), chPos.Y());
8078

8179
return TMath::ATan2(chPos.Y() + offsetY, chPos.X() + offsetX);
8280
}
8381

84-
void EventPlaneHelper::SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, o2::ft0::Geometry ft0geom, o2::fv0::Geometry* fv0geom)
82+
void EventPlaneHelper::SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, const o2::ft0::Geometry& ft0geom, o2::fv0::Geometry* fv0geom)
8583
{
8684
/* Calculate the complex Q-vector for the provided detector and channel number,
8785
before adding it to the total Q-vector given as argument. */

Common/Core/EventPlaneHelper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ class EventPlaneHelper
6060
}
6161

6262
// Methods to calculate the azimuthal angles for each part of FIT, given the channel number.
63-
double GetPhiFT0(int chno, o2::ft0::Geometry ft0geom);
63+
double GetPhiFT0(int chno, const o2::ft0::Geometry& ft0geom);
6464
double GetPhiFV0(int chno, o2::fv0::Geometry* fv0geom);
6565

6666
// Method to get the Q-vector and sum of amplitudes for any channel in FIT, given
6767
// the detector and amplitude.
68-
void SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, o2::ft0::Geometry ft0geom, o2::fv0::Geometry* fv0geom);
68+
void SumQvectors(int det, int chno, float ampl, int nmod, TComplex& Qvec, float& sum, const o2::ft0::Geometry& ft0geom, o2::fv0::Geometry* fv0geom);
6969

7070
// Method to get the bin corresponding to a centrality percentile, according to the
7171
// centClasses[] array defined in Tasks/qVectorsQA.cxx.

Common/TableProducer/qVectorsTable.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ struct qVectorsTable {
257257
AxisSpec axisChID = {220, 0, 220};
258258

259259
fv0geom = o2::fv0::Geometry::instance(o2::fv0::Geometry::eUninitialized);
260+
ft0geom.calculateChannelCenter();
260261

261262
histosQA.add("ChTracks", "", {HistType::kTHnSparseF, {axisPt, axisEta, axisPhi, axixCent}});
262263
histosQA.add("FT0Amp", "", {HistType::kTH2F, {axisFITamp, axisChID}});

PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ struct JEPFlowAnalysis {
442442
ccdb->setCreatedNotAfter(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count());
443443

444444
fv0geom = o2::fv0::Geometry::instance(o2::fv0::Geometry::eUninitialized);
445+
ft0geom.calculateChannelCenter();
445446

446447
detId = getdetId(cfgDetName);
447448
refAId = getdetId(cfgRefAName);

0 commit comments

Comments
 (0)