From 4ab72dc43d411e3a4a36cebb5d6013cd59b5c1fd Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Tue, 22 Oct 2024 16:38:01 -0400 Subject: [PATCH] fix all code with parallel thread --- SingleSpectra.cpp | 5 +---- analyzers/CoincidentAnalyzer.h | 13 ++++++++----- analyzers/NeutronGamma.h | 7 ++++++- analyzers/SplitPoleAnalyzer.h | 12 +++++++----- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index adef1b9..c23461d 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -164,9 +164,6 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms); connect( histWorker, &HistWorker::workDone, this, &SingleSpectra::ReplotHistograms); - - - workerThread->start(); } @@ -252,7 +249,7 @@ void SingleSpectra::FillHistograms(){ timespec ta, tb; printf("####################### SingleSpectra::%s\n", __func__); - qDebug() << __func__ << "| thread:" << QThread::currentThreadId(); + // qDebug() << __func__ << "| thread:" << QThread::currentThreadId(); clock_gettime(CLOCK_REALTIME, &ta); diff --git a/analyzers/CoincidentAnalyzer.h b/analyzers/CoincidentAnalyzer.h index 44556e1..93476c8 100644 --- a/analyzers/CoincidentAnalyzer.h +++ b/analyzers/CoincidentAnalyzer.h @@ -31,6 +31,7 @@ public: public slots: void UpdateHistograms(); + void ReplotHistograms(); private: @@ -486,11 +487,6 @@ inline void CoincidentAnalyzer::UpdateHistograms(){ } - h2D->UpdatePlot(); - h1->UpdatePlot(); - hMulti->UpdatePlot(); - h1g->UpdatePlot(); - if( influx ){ QList cutNameList = h2D->GetCutNameList(); for( int p = 0; p < cutList.count(); p ++){ @@ -509,6 +505,13 @@ inline void CoincidentAnalyzer::UpdateHistograms(){ } +inline void CoincidentAnalyzer::ReplotHistograms(){ + h2D->UpdatePlot(); + h1->UpdatePlot(); + hMulti->UpdatePlot(); + h1g->UpdatePlot(); +} + inline void CoincidentAnalyzer::SaveSettings(){ QString filePath = QFileDialog::getSaveFileName(this, "Save Settings to File", diff --git a/analyzers/NeutronGamma.h b/analyzers/NeutronGamma.h index 850a5b2..513fbe4 100644 --- a/analyzers/NeutronGamma.h +++ b/analyzers/NeutronGamma.h @@ -59,6 +59,8 @@ public: public slots: void UpdateHistograms(); + void ReplotHistograms(); + private: QVector generateNonRepeatedCombination(int size); void SetUpCanvas(); @@ -210,8 +212,11 @@ inline void NeutronGamma::UpdateHistograms(){ }while(lastFilledIndex[ID][ch] <= digi[ID]->GetData()->GetAbsDataIndex(ch)); - hist2D->UpdatePlot(); +} +inline void NeutronGamma::ReplotHistograms(){ + // qDebug() << __func__ << "| thread:" << QThread::currentThreadId(); + hist2D->UpdatePlot(); } inline QVector NeutronGamma::generateNonRepeatedCombination(int size) { diff --git a/analyzers/SplitPoleAnalyzer.h b/analyzers/SplitPoleAnalyzer.h index 088a1fe..c279084 100644 --- a/analyzers/SplitPoleAnalyzer.h +++ b/analyzers/SplitPoleAnalyzer.h @@ -63,6 +63,7 @@ public: public slots: void UpdateHistograms(); + void ReplotHistograms(); private: @@ -421,11 +422,6 @@ inline void SplitPole::UpdateHistograms(){ } } - hPID->UpdatePlot(); - h1->UpdatePlot(); - hMulti->UpdatePlot(); - h1g->UpdatePlot(); - QList cutNameList = hPID->GetCutNameList(); for( int p = 0; p < cutList.count(); p ++){ if( cutList[p].isEmpty() ) continue; @@ -441,5 +437,11 @@ inline void SplitPole::UpdateHistograms(){ } +inline void SplitPole::ReplotHistograms(){ + hPID->UpdatePlot(); + h1->UpdatePlot(); + hMulti->UpdatePlot(); + h1g->UpdatePlot(); +} #endif \ No newline at end of file