Skip to content

Commit 7b9b14b

Browse files
committed
TPC: fix initialization of FFTW arrays in aggregator-ft
1 parent 25f4dfe commit 7b9b14b

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

Detectors/TPC/calibration/include/TPCCalibration/IDCFourierTransform.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@ class IDCFourierTransform : public IDCFourierTransformBase<Type>
4545
template <bool IsEnabled = true, typename std::enable_if<(IsEnabled && (std::is_same<Type, IDCFourierTransformBaseAggregator>::value)), int>::type = 0>
4646
IDCFourierTransform(const unsigned int rangeIDC = 200, const unsigned int nFourierCoefficientsStore = 200 + 2) : IDCFourierTransformAggregator(rangeIDC), mFourierCoefficients{1, nFourierCoefficientsStore}, mVal1DIDCs(sNThreads), mCoefficients(sNThreads)
4747
{
48-
initFFTW3Members();
49-
};
48+
}
5049

5150
/// constructor for EPN type
5251
/// \param rangeIDC number of IDCs for each interval which will be used to calculate the fourier coefficients
5352
/// \param nFourierCoefficientsStore number of courier coefficients (real+imag) which will be stored (the maximum can be 'rangeIDC + 2', should be an even number when using naive FT). If less than maximum is setn the inverse fourier transform will not work.
5453
template <bool IsEnabled = true, typename std::enable_if<(IsEnabled && (std::is_same<Type, IDCFourierTransformBaseEPN>::value)), int>::type = 0>
5554
IDCFourierTransform(const unsigned int rangeIDC = 200, const unsigned int nFourierCoefficientsStore = 200 + 2) : IDCFourierTransformEPN(rangeIDC), mFourierCoefficients{1, nFourierCoefficientsStore}, mVal1DIDCs(sNThreads), mCoefficients(sNThreads)
5655
{
57-
initFFTW3Members();
58-
};
56+
}
5957

6058
// Destructor
6159
~IDCFourierTransform();
@@ -72,6 +70,9 @@ class IDCFourierTransform : public IDCFourierTransformBase<Type>
7270
sNThreads = nThreads;
7371
}
7472

73+
/// initalizing fftw members, e.g. when changing sNThreads via setNThreads after first initialization
74+
void initFFTW3Members();
75+
7576
/// calculate fourier coefficients for one TPC side
7677
template <bool IsEnabled = true, typename std::enable_if<(IsEnabled && (std::is_same<Type, IDCFourierTransformBaseAggregator>::value)), int>::type = 0>
7778
void calcFourierCoefficients(const unsigned int timeFrames = 2000)
@@ -155,9 +156,6 @@ class IDCFourierTransform : public IDCFourierTransformBase<Type>
155156
/// \return returns maximum numbers of stored real/imag fourier coeffiecients
156157
unsigned int getNMaxCoefficients() const { return this->mRangeIDC / 2 + 1; }
157158

158-
/// initalizing fftw members
159-
void initFFTW3Members();
160-
161159
/// performing of ft using FFTW
162160
void fftwLoop(const std::vector<float>& idcOneExpanded, const std::vector<unsigned int>& offsetIndex, const unsigned int interval, const unsigned int thread);
163161

Detectors/TPC/calibration/src/IDCFourierTransform.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ o2::tpc::IDCFourierTransform<Type>::~IDCFourierTransform()
3535
template <class Type>
3636
void o2::tpc::IDCFourierTransform<Type>::initFFTW3Members()
3737
{
38+
mVal1DIDCs.resize(sNThreads);
39+
mCoefficients.resize(sNThreads);
3840
for (int thread = 0; thread < sNThreads; ++thread) {
3941
mVal1DIDCs[thread] = fftwf_alloc_real(this->mRangeIDC);
4042
mCoefficients[thread] = fftwf_alloc_complex(getNMaxCoefficients());

Detectors/TPC/calibration/test/testO2TPCIDCFourierTransform.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ BOOST_AUTO_TEST_CASE(IDCFourierTransformAggregator_test)
6767
FtType::setNThreads(2);
6868

6969
FtType idcFourierTransform{rangeIDC, nFourierCoeff};
70+
idcFourierTransform.initFFTW3Members();
7071
const auto intervalsPerTF = getIntegrationIntervalsPerTF(integrationIntervals, tfs);
7172
idcFourierTransform.setIDCs(get1DIDCs(intervalsPerTF), intervalsPerTF);
7273
idcFourierTransform.setIDCs(get1DIDCs(intervalsPerTF), intervalsPerTF);
@@ -105,6 +106,7 @@ BOOST_AUTO_TEST_CASE(IDCFourierTransformEPN_test)
105106
const bool fft = iType == 0 ? false : true;
106107
FtType::setFFT(fft);
107108
FtType idcFourierTransform{rangeIDC, nFourierCoeff};
109+
idcFourierTransform.initFFTW3Members();
108110
const auto intervalsPerTF = getIntegrationIntervalsPerTF(integrationIntervals, tfs);
109111
idcFourierTransform.setIDCs(get1DIDCs(intervalsPerTF));
110112
idcFourierTransform.calcFourierCoefficients();

Detectors/TPC/workflow/include/TPCWorkflow/TPCFourierTransformAggregatorSpec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class TPCFourierTransformAggregatorSpec : public o2::framework::Task
6666
mEnableFFTCCDB = ic.options().get<bool>("enable-fft-CCDB");
6767
int nthreads = ic.options().get<int>("nthreads");
6868
TPCFourierTransformAggregatorSpec::IDCFType::setNThreads(nthreads);
69+
for (auto& fourierTransform : mIDCFourierTransform) {
70+
fourierTransform.initFFTW3Members();
71+
}
6972
resizeBuffer(mInputLanes);
7073
}
7174

0 commit comments

Comments
 (0)