histogram bug fix. histogram internal counter not reset after ACQ stop or histogram clear

This commit is contained in:
carina@hades 2023-08-16 17:54:35 -04:00
parent 35953797d9
commit c20771567b
7 changed files with 40 additions and 18 deletions

View File

@ -156,6 +156,7 @@
"qrandomgenerator": "cpp", "qrandomgenerator": "cpp",
"source_location": "cpp", "source_location": "cpp",
"splitpole.C": "cpp", "splitpole.C": "cpp",
"forward_list": "cpp" "forward_list": "cpp",
"fstream": "cpp"
} }
} }

View File

@ -894,13 +894,18 @@ void MainWindow::UpdateScalar(){
// digi[iDigi]->GetData()->PrintAllData(true, 10); // digi[iDigi]->GetData()->PrintAllData(true, 10);
if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize(); if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize();
for( int i = 0; i < digi[iDigi]->GetNChannels(); i++){ for( int i = 0; i < digi[iDigi]->GetNChannels(); i++){
QString a = "";
QString b = "";
if( digi[iDigi]->GetChannelOnOff(i) == true ) { if( digi[iDigi]->GetChannelOnOff(i) == true ) {
//printf(" %3d %2d | %7.2f %7.2f \n", digi[iDigi]->GetSerialNumber(), i, digi[iDigi]->GetData()->TriggerRate[i], digi[iDigi]->GetData()->NonPileUpRate[i]); //printf(" %3d %2d | %7.2f %7.2f \n", digi[iDigi]->GetSerialNumber(), i, digi[iDigi]->GetData()->TriggerRate[i], digi[iDigi]->GetData()->NonPileUpRate[i]);
leTrigger[iDigi][i]->setText(QString::number(digi[iDigi]->GetData()->TriggerRate[i], 'f', 2)); QString a = QString::number(digi[iDigi]->GetData()->TriggerRate[i], 'f', 2);
leAccept[iDigi][i]->setText(QString::number(digi[iDigi]->GetData()->NonPileUpRate[i], 'f', 2)); QString b = QString::number(digi[iDigi]->GetData()->NonPileUpRate[i], 'f', 2);
leTrigger[iDigi][i]->setText(a);
leAccept[iDigi][i]->setText(b);
if( influx ){ if( influx && a != "inf" ){
influx->AddDataPoint("Rate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + QString::number(digi[iDigi]->GetData()->TriggerRate[i], 'f', 2).toStdString()); influx->AddDataPoint("Rate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + a.toStdString());
} }
} }
} }
@ -979,7 +984,7 @@ void MainWindow::StartACQ(){
if( onlineAnalyzer ) onlineAnalyzer->StartThread(); if( onlineAnalyzer ) onlineAnalyzer->StartThread();
{//^=== elog and database {//^=== elog and database
if( influx ){ if( influx && chkSaveData->isChecked() ){
influx->AddDataPoint("RunID value=" + std::to_string(runID)); influx->AddDataPoint("RunID value=" + std::to_string(runID));
influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1"); influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1");
influx->WriteData(dataBaseName.toStdString()); influx->WriteData(dataBaseName.toStdString());
@ -1033,10 +1038,11 @@ void MainWindow::StopACQ(){
if( onlineAnalyzer ) onlineAnalyzer->StopThread(); if( onlineAnalyzer ) onlineAnalyzer->StopThread();
if( histThread->isRunning()){ if( canvas && histThread->isRunning()){
histThread->Stop(); histThread->Stop();
histThread->quit(); histThread->quit();
histThread->wait(); histThread->wait();
canvas->ClearInternalDataCount();
} }
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>"); lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
@ -1049,7 +1055,7 @@ void MainWindow::StopACQ(){
cbAutoRun->setEnabled(true); cbAutoRun->setEnabled(true);
{//^=== elog and database {//^=== elog and database
if( influx ){ if( influx && chkSaveData->isChecked() ){
influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0"); influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0");
influx->WriteData(dataBaseName.toStdString()); influx->WriteData(dataBaseName.toStdString());
influx->ClearDataPointsBuffer(); influx->ClearDataPointsBuffer();
@ -1356,6 +1362,7 @@ void MainWindow::OpenScope(){
histThread->Stop(); histThread->Stop();
histThread->quit(); histThread->quit();
histThread->wait(); histThread->wait();
canvas->ClearInternalDataCount();
} }
} }
} }

View File

@ -210,6 +210,9 @@ public:
txt[0]->setText("Under Flow : 0"); txt[0]->setText("Under Flow : 0");
txt[1]->setText("Total Entry : 0"); txt[1]->setText("Total Entry : 0");
txt[2]->setText("Over Flow : 0"); txt[2]->setText("Over Flow : 0");
totalEntry = 0;
underFlow = 0;
overFlow = 0;
UpdatePlot(); UpdatePlot();
} }

View File

@ -97,3 +97,7 @@ The following files must be excluded from the *.pro, as they are not related to
Those file can be compiled using Those file can be compiled using
`make -f Makefile_test` `make -f Makefile_test`
# Known Bugs
* for PHA firmware, when the peak average changed, trace disapear and causing program lag.

View File

@ -44,6 +44,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
for( unsigned int i = 0; i < nDigi; i++){ for( unsigned int i = 0; i < nDigi; i++){
for( int j = 0; j < MaxNChannels; j++){ for( int j = 0; j < MaxNChannels; j++){
if( hist[i][j] ) hist[i][j]->Clear(); if( hist[i][j] ) hist[i][j]->Clear();
lastFilledIndex[i][j] = -1;
loopFilledIndex[i][j] = 0;
} }
} }
}); });
@ -85,13 +87,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
layout->setStretch(0, 1); layout->setStretch(0, 1);
layout->setStretch(1, 6); layout->setStretch(1, 6);
ClearInternalDataCount();
for( unsigned int i = 0; i < nDigi; i++){
for( int ch = 0; ch < MaxNChannels ; ch++) {
lastFilledIndex[i][ch] = -1;
loopFilledIndex[i][ch] = 0;
}
}
oldBd = -1; oldBd = -1;
oldCh = -1; oldCh = -1;
@ -108,6 +105,15 @@ SingleSpectra::~SingleSpectra(){
} }
} }
void SingleSpectra::ClearInternalDataCount(){
for( unsigned int i = 0; i < nDigi; i++){
for( int ch = 0; ch < MaxNChannels ; ch++) {
lastFilledIndex[i][ch] = -1;
loopFilledIndex[i][ch] = 0;
}
}
}
void SingleSpectra::ChangeHistView(){ void SingleSpectra::ChangeHistView(){
if( oldCh >= 0 ) { if( oldCh >= 0 ) {
@ -136,7 +142,7 @@ void SingleSpectra::FillHistograms(){
int temp1 = lastIndex + loopIndex*MaxNData; int temp1 = lastIndex + loopIndex*MaxNData;
int temp2 = lastFilledIndex[i][ch] + loopFilledIndex[i][ch]*MaxNData; int temp2 = lastFilledIndex[i][ch] + loopFilledIndex[i][ch]*MaxNData;
//printf("%d |%d %d \n", ch, temp2, temp1); // printf("%d |%d %d \n", ch, temp2, temp1);
if( lastIndex < 0 ) continue; if( lastIndex < 0 ) continue;
if( temp1 <= temp2 ) continue; if( temp1 <= temp2 ) continue;

View File

@ -27,6 +27,7 @@ public:
SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent = nullptr); SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent = nullptr);
~SingleSpectra(); ~SingleSpectra();
void ClearInternalDataCount();
void SetFillHistograms(bool onOff) { fillHistograms = onOff;} void SetFillHistograms(bool onOff) { fillHistograms = onOff;}
bool IsFillHistograms() const {return fillHistograms;} bool IsFillHistograms() const {return fillHistograms;}