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

View File

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

View File

@ -96,4 +96,8 @@ The following files must be excluded from the *.pro, as they are not related to
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( int j = 0; j < MaxNChannels; j++){
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(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;
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(){
if( oldCh >= 0 ) {
@ -136,7 +142,7 @@ void SingleSpectra::FillHistograms(){
int temp1 = lastIndex + loopIndex*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( temp1 <= temp2 ) continue;

View File

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

View File

@ -152,6 +152,6 @@ void InfluxDB::Execute(){
}
size_t InfluxDB::WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}