From 837db021f41e8b081b1531b2f0fe3085305c3a4b Mon Sep 17 00:00:00 2001 From: Ernst Hellbar Date: Thu, 18 Jun 2026 14:02:05 +0200 Subject: [PATCH] TPC: fix initialization of FFTW arrays in aggregator-ft --- .../include/TPCCalibration/IDCFourierTransform.h | 12 +++++------- .../TPC/calibration/src/IDCFourierTransform.cxx | 2 ++ .../test/testO2TPCIDCFourierTransform.cxx | 2 ++ .../TPCWorkflow/TPCFourierTransformAggregatorSpec.h | 3 +++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Detectors/TPC/calibration/include/TPCCalibration/IDCFourierTransform.h b/Detectors/TPC/calibration/include/TPCCalibration/IDCFourierTransform.h index 8a27321e131f3..db79695ce9834 100644 --- a/Detectors/TPC/calibration/include/TPCCalibration/IDCFourierTransform.h +++ b/Detectors/TPC/calibration/include/TPCCalibration/IDCFourierTransform.h @@ -45,8 +45,7 @@ class IDCFourierTransform : public IDCFourierTransformBase template ::value)), int>::type = 0> IDCFourierTransform(const unsigned int rangeIDC = 200, const unsigned int nFourierCoefficientsStore = 200 + 2) : IDCFourierTransformAggregator(rangeIDC), mFourierCoefficients{1, nFourierCoefficientsStore}, mVal1DIDCs(sNThreads), mCoefficients(sNThreads) { - initFFTW3Members(); - }; + } /// constructor for EPN type /// \param rangeIDC number of IDCs for each interval which will be used to calculate the fourier coefficients @@ -54,8 +53,7 @@ class IDCFourierTransform : public IDCFourierTransformBase template ::value)), int>::type = 0> IDCFourierTransform(const unsigned int rangeIDC = 200, const unsigned int nFourierCoefficientsStore = 200 + 2) : IDCFourierTransformEPN(rangeIDC), mFourierCoefficients{1, nFourierCoefficientsStore}, mVal1DIDCs(sNThreads), mCoefficients(sNThreads) { - initFFTW3Members(); - }; + } // Destructor ~IDCFourierTransform(); @@ -72,6 +70,9 @@ class IDCFourierTransform : public IDCFourierTransformBase sNThreads = nThreads; } + /// initalizing fftw members, e.g. when changing sNThreads via setNThreads after first initialization + void initFFTW3Members(); + /// calculate fourier coefficients for one TPC side template ::value)), int>::type = 0> void calcFourierCoefficients(const unsigned int timeFrames = 2000) @@ -155,9 +156,6 @@ class IDCFourierTransform : public IDCFourierTransformBase /// \return returns maximum numbers of stored real/imag fourier coeffiecients unsigned int getNMaxCoefficients() const { return this->mRangeIDC / 2 + 1; } - /// initalizing fftw members - void initFFTW3Members(); - /// performing of ft using FFTW void fftwLoop(const std::vector& idcOneExpanded, const std::vector& offsetIndex, const unsigned int interval, const unsigned int thread); diff --git a/Detectors/TPC/calibration/src/IDCFourierTransform.cxx b/Detectors/TPC/calibration/src/IDCFourierTransform.cxx index c4b92b57c17ab..437fa4b8f1991 100644 --- a/Detectors/TPC/calibration/src/IDCFourierTransform.cxx +++ b/Detectors/TPC/calibration/src/IDCFourierTransform.cxx @@ -35,6 +35,8 @@ o2::tpc::IDCFourierTransform::~IDCFourierTransform() template void o2::tpc::IDCFourierTransform::initFFTW3Members() { + mVal1DIDCs.resize(sNThreads); + mCoefficients.resize(sNThreads); for (int thread = 0; thread < sNThreads; ++thread) { mVal1DIDCs[thread] = fftwf_alloc_real(this->mRangeIDC); mCoefficients[thread] = fftwf_alloc_complex(getNMaxCoefficients()); diff --git a/Detectors/TPC/calibration/test/testO2TPCIDCFourierTransform.cxx b/Detectors/TPC/calibration/test/testO2TPCIDCFourierTransform.cxx index c71889bfd2d08..874206ddf8add 100644 --- a/Detectors/TPC/calibration/test/testO2TPCIDCFourierTransform.cxx +++ b/Detectors/TPC/calibration/test/testO2TPCIDCFourierTransform.cxx @@ -67,6 +67,7 @@ BOOST_AUTO_TEST_CASE(IDCFourierTransformAggregator_test) FtType::setNThreads(2); FtType idcFourierTransform{rangeIDC, nFourierCoeff}; + idcFourierTransform.initFFTW3Members(); const auto intervalsPerTF = getIntegrationIntervalsPerTF(integrationIntervals, tfs); idcFourierTransform.setIDCs(get1DIDCs(intervalsPerTF), intervalsPerTF); idcFourierTransform.setIDCs(get1DIDCs(intervalsPerTF), intervalsPerTF); @@ -105,6 +106,7 @@ BOOST_AUTO_TEST_CASE(IDCFourierTransformEPN_test) const bool fft = iType == 0 ? false : true; FtType::setFFT(fft); FtType idcFourierTransform{rangeIDC, nFourierCoeff}; + idcFourierTransform.initFFTW3Members(); const auto intervalsPerTF = getIntegrationIntervalsPerTF(integrationIntervals, tfs); idcFourierTransform.setIDCs(get1DIDCs(intervalsPerTF)); idcFourierTransform.calcFourierCoefficients(); diff --git a/Detectors/TPC/workflow/include/TPCWorkflow/TPCFourierTransformAggregatorSpec.h b/Detectors/TPC/workflow/include/TPCWorkflow/TPCFourierTransformAggregatorSpec.h index 7facee78fb3d6..9c64634b438d9 100644 --- a/Detectors/TPC/workflow/include/TPCWorkflow/TPCFourierTransformAggregatorSpec.h +++ b/Detectors/TPC/workflow/include/TPCWorkflow/TPCFourierTransformAggregatorSpec.h @@ -66,6 +66,9 @@ class TPCFourierTransformAggregatorSpec : public o2::framework::Task mEnableFFTCCDB = ic.options().get("enable-fft-CCDB"); int nthreads = ic.options().get("nthreads"); TPCFourierTransformAggregatorSpec::IDCFType::setNThreads(nthreads); + for (auto& fourierTransform : mIDCFourierTransform) { + fourierTransform.initFFTW3Members(); + } resizeBuffer(mInputLanes); }