@@ -188,54 +188,70 @@ void FindPeaksConvolve::performConvolution(const size_t dataIndex) {
188
188
<< " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
189
189
const auto specNum{m_specNums[dataIndex]};
190
190
const HistogramData::HistogramX *xData{&m_inputDataWS->x (specNum)};
191
- std::cout << " performConvolution 2" << std::endl; // TODO remove
191
+ std::cout << " performConvolution 2"
192
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
192
193
std::pair<const size_t , const bool > kernelBinCount{getKernelBinCount (xData)};
193
- std::cout << " performConvolution 3" << std::endl; // TODO remove
194
+ std::cout << " performConvolution 3"
195
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
194
196
if (kernelBinCount.second ) {
195
197
g_log.error (" The kernel size for spectrum " + std::to_string (m_specNums[dataIndex]) +
196
198
" exceeds the range of the x axis. Please reduce the peak extent." );
197
199
} else {
198
- std::cout << " performConvolution 4" << std::endl; // TODO remove
200
+ std::cout << " performConvolution 4"
201
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
199
202
const Tensor1D kernel{createKernel (static_cast <int >(kernelBinCount.first ))};
200
- std::cout << " performConvolution 5" << std::endl; // TODO remove
203
+ std::cout << " performConvolution 5"
204
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
201
205
const auto binCount{m_inputDataWS->getNumberBins (specNum)};
202
206
// Edge handling is performed by padding the input data with 0 values. Each convolution requires a padding of kernel
203
207
// size + 1. The 1st conv is performed with a kernel of size n, the second size n/2. The resultant pad is split
204
208
// either side of the data.
205
209
const double paddingSize = (std::ceil (static_cast <double >(kernelBinCount.first ) * 1.5 ) - 2 ) / 2 ;
206
- std::cout << " performConvolution 6" << std::endl; // TODO remove
210
+ std::cout << " performConvolution 6"
211
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
207
212
const TensorMap_const yData{&m_inputDataWS->y (specNum).front (), binCount};
208
- std::cout << " performConvolution 7" << std::endl; // TODO remove
213
+ std::cout << " performConvolution 7"
214
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
209
215
Eigen::array<std::pair<double , double >, 1 > paddings{
210
216
std::make_pair (std::ceil (paddingSize), std::floor (paddingSize))};
211
- std::cout << " performConvolution 8" << std::endl; // TODO remove
217
+ std::cout << " performConvolution 8"
218
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
212
219
const auto yData_padded{yData.pad (paddings)};
213
- std::cout << " performConvolution 9" << std::endl; // TODO remove
220
+ std::cout << " performConvolution 9"
221
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
214
222
const Eigen::array<ptrdiff_t , 1 > dims ({0 });
215
- std::cout << " performConvolution 10" << std::endl; // TODO remove
223
+ std::cout << " performConvolution 10"
224
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
216
225
const Tensor1D yConvOutput{yData_padded.convolve (kernel, dims)};
217
- std::cout << " performConvolution 11" << std::endl; // TODO remove
226
+ std::cout << " performConvolution 11"
227
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
218
228
219
229
const auto eData{TensorMap_const{&m_inputDataWS->e (specNum).front (), binCount}.pad (paddings)};
220
230
const Tensor1D eConvOutput{eData.square ().convolve (kernel.square (), dims).sqrt ()};
221
- std::cout << " performConvolution 12" << std::endl; // TODO remove
231
+ std::cout << " performConvolution 12"
232
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
222
233
const Tensor1D smoothKernel{
223
234
createSmoothKernel (static_cast <size_t >(std::ceil (static_cast <double >(kernelBinCount.first ) / 2.0 )))};
224
- std::cout << " performConvolution 13" << std::endl; // TODO remove
235
+ std::cout << " performConvolution 13"
236
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
225
237
Tensor1D iOverSig{(yConvOutput / eConvOutput).unaryExpr ([](double val) { return std::isfinite (val) ? val : 0.0 ; })};
226
- std::cout << " performConvolution 14" << std::endl; // TODO remove
238
+ std::cout << " performConvolution 14"
239
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
227
240
const Tensor1D iOverSigConvOutput{iOverSig.convolve (smoothKernel, dims)};
228
- std::cout << " performConvolution 15" << std::endl; // TODO remove
241
+ std::cout << " performConvolution 15"
242
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
229
243
230
244
extractPeaks (dataIndex, iOverSigConvOutput, xData, yData, kernelBinCount.first / 2 );
231
245
232
- std::cout << " performConvolution 16" << std::endl; // TODO remove
246
+ std::cout << " performConvolution 16"
247
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
233
248
if (m_createIntermediateWorkspaces) {
234
249
auto wsNames = createIntermediateWorkspaces (dataIndex, kernel, iOverSigConvOutput, xData);
235
- std::lock_guard<std::mutex> lock (mtx );
250
+ std::lock_guard<std::mutex> lock (m_mtx );
236
251
m_intermediateWsNames.insert (m_intermediateWsNames.end (), wsNames.cbegin (), wsNames.cend ());
237
252
}
238
- std::cout << " performConvolution 17" << std::endl; // TODO remove
253
+ std::cout << " performConvolution 17"
254
+ << " by thread " << std::this_thread::get_id () << std::endl; // TODO remove
239
255
}
240
256
}
241
257
@@ -332,6 +348,7 @@ void FindPeaksConvolve::storePeakResults(const size_t dataIndex,
332
348
if (peakCount > m_maxPeakCount) {
333
349
m_maxPeakCount = peakCount;
334
350
}
351
+ std::lock_guard<std::mutex> lock (m_mtx);
335
352
m_peakResults[dataIndex] = std::move (peakCentres);
336
353
}
337
354
}
@@ -367,6 +384,7 @@ size_t FindPeaksConvolve::findPeakInRawData(const int xIndex, const TensorMap_co
367
384
368
385
void FindPeaksConvolve::generateNormalPDF (const int peakExtentBinNumber) {
369
386
if (m_pdf.size () == 0 ) {
387
+ std::lock_guard<std::mutex> lock (m_mtx);
370
388
m_pdf.resize (peakExtentBinNumber);
371
389
boost::math::normal_distribution<> dist (0.0 ,
372
390
peakExtentBinNumber / 2.0 ); // assures 2 stddevs in the resultant vector
0 commit comments