From 20c9a8b63de5c007069749c0c21a135366b8b286 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Tue, 22 Aug 2023 14:38:37 -0400 Subject: [PATCH] many improvement from Encore experiment --- .gitignore | 3 ++- ClassData.h | 12 ++++++------ ClassDigitizer.cpp | 5 +++-- DigiSettingsPanel.cpp | 2 ++ EventBuilder.cpp | 2 +- FSUDAQ.cpp | 42 ++++++++++++++++++++---------------------- Scope.cpp | 23 +++++++++++++++++++++-- 7 files changed, 55 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 9aee1f1..38d240f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ test test_indep programSettings.txt EventKenshikushi +EventBuilder DataGenerator DataReaderScript pid.dat @@ -55,4 +56,4 @@ Thumbs.db *.rc /.qmake.cache /.qmake.stash -*.gdb_history \ No newline at end of file +*.gdb_history diff --git a/ClassData.h b/ClassData.h index f1e3744..48e3243 100644 --- a/ClassData.h +++ b/ClassData.h @@ -256,14 +256,15 @@ inline void Data::CloseSaveFile(){ //^####################################################### Print inline void Data::PrintStat() const{ + printf("============================= Print Stat. Digi-%d\n", boardSN); if( !IsNotRollOverFakeAgg ) { printf(" this is roll-over fake event or no events.\n"); return; } - printf("%2s | %6s | %9s | %9s | %6s\n", "ch", "# Evt.", "Rate [Hz]", "N-PileUp", "Tot. Evt."); + printf("%2s | %6s | %9s | %9s | %6s | %6s(%4s)\n", "ch", "# Evt.", "Rate [Hz]", "N-PileUp", "Tot. Evt.", "index", "loop"); printf("---+--------+-----------+-----------+----------\n"); for(int ch = 0; ch < MaxNChannels; ch++){ - printf("%2d | %6d | %9.2f | %9.2f | %6lu\n", ch, NumEventsDecoded[ch], TriggerRate[ch], NonPileUpRate[ch], TotNumEvents[ch]); + printf("%2d | %6d | %9.2f | %9.2f | %6lu | %6d(%2d)\n", ch, NumEventsDecoded[ch], TriggerRate[ch], NonPileUpRate[ch], TotNumEvents[ch], DataIndex[ch], LoopIndex[ch]); } printf("---+--------+-----------+-----------+----------\n"); } @@ -415,13 +416,12 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ int indexStart = DataIndex[ch] - NumEventsDecoded[ch] + 1; if( indexStart < 0 ) indexStart += MaxNData; - //printf("%d %d| %d %d \n", DataIndex[ch], NumEventsDecoded[ch], indexStart, DataIndex[ch] ); - unsigned long long dTime = Timestamp[ch][DataIndex[ch]] - Timestamp[ch][indexStart]; double sec = dTime * tick2ns / 1e9; - TriggerRate[ch] = NumEventsDecoded[ch]/sec; - NonPileUpRate[ch] = NumNonPileUpDecoded[ch]/sec; + TriggerRate[ch] = (NumEventsDecoded[ch]-1)/sec; + //printf("%d %d| %d | %llu, %.3e | %.2f\n", indexStart, DataIndex[ch], NumEventsDecoded[ch], dTime, sec , TriggerRate[ch]); + NonPileUpRate[ch] = (NumNonPileUpDecoded[ch]-1)/sec; }else{ // look in to the data in the memory, not just this agg. diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 1c2be56..be87aa4 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -391,8 +391,8 @@ void Digitizer::StartACQ(){ unsigned int bufferSize = CalByteForBuffer(); if( bufferSize > 160 * 1024 * 1024 ){ - printf("============= buffer size bigger than 160 MB"); - return; + printf("============= buffer size bigger than 160 MB (%u)\n", bufferSize ); + //return; } if( DPPType == V1730_DPP_PSD_CODE) bufferSize = 80 * 1024 * 1024; //TODO allocate 80 MB for PSD @@ -435,6 +435,7 @@ void Digitizer::StopACQ(){ if( ret != 0 ) ErrorMsg("something wrong when try to stop ACQ and clear buffer"); printf("\n\e[1m\e[33m====== Acquisition STOPPED for %d | Board %d, Port %d\e[0m\n", BoardInfo.SerialNumber, boardID, portID); AcqRun = false; + data->PrintStat(); data->ClearTriggerRate(); data->ClearBuffer(); data->ZeroTotalFileSize(); diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 49805b4..4e74ca5 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -190,6 +190,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr usleep(1000*500); // wait for 0.2 sec ReadSettingsFromBoard(); + emit UpdateOtherPanels(); + }); bnClearBuffer = new QPushButton("Clear Buffer/FIFO", this); diff --git a/EventBuilder.cpp b/EventBuilder.cpp index cabb48e..5af57e6 100644 --- a/EventBuilder.cpp +++ b/EventBuilder.cpp @@ -19,7 +19,7 @@ void quickSort(int arr[], int kaka[], TString file[], int start, int end); int main(int argc, char **argv) { printf("=========================================\n"); - printf("=== *.fsu Events Kenshikushi ===\n"); + printf("=== *.fsu Events Builder ===\n"); printf("=========================================\n"); if (argc <= 3) { printf("Incorrect number of arguments:\n"); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 6a0b0cf..da462ca 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -223,19 +223,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ connect( bnStartACQ, &QPushButton::clicked, this, &MainWindow::AutoRun); bnStopACQ = new QPushButton("Stop ACQ", this); connect( bnStopACQ, &QPushButton::clicked, this, [=](){ - if( chkSaveData->isChecked() ){ - if( runTimer->isActive() ){ - runTimer->stop(); - runTimer->disconnect(runTimerConnection); - StopACQ(); - }else{ - breakAutoRepeat = true; - runTimer->disconnect(runTimerConnection); - } - needManualComment = true; + if( runTimer->isActive() ){ + runTimer->stop(); + runTimer->disconnect(runTimerConnection); }else{ - StopACQ(); + breakAutoRepeat = true; + runTimer->disconnect(runTimerConnection); } + needManualComment = true; + StopACQ(); }); layout->addWidget(lbPrefix, rowID, 0); @@ -630,13 +626,13 @@ void MainWindow::OpenDigitizers(){ }else{ LogMsg("Found " + fileName + " for digitizer settings."); - if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){ - LogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber())); - digi[i]->ProgramSettingsToBoard(); - - }else{ - LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber())); - } + // if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){ + // LogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber())); + // digi[i]->ProgramSettingsToBoard(); + // + // }else{ + // LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber())); + // } } digi[i]->ReadAllSettingsFromBoard(true); @@ -1352,13 +1348,15 @@ void MainWindow::OpenScope(){ if( scope ) { if( onOff ) { lbScalarACQStatus->setText("ACQ On"); - influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1"); + if( influx ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1"); }else{ lbScalarACQStatus->setText("ACQ Off"); - influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0"); + if( influx ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0"); + } + if( influx ){ + influx->WriteData(dataBaseName.toStdString()); + influx->ClearDataPointsBuffer(); } - influx->WriteData(dataBaseName.toStdString()); - influx->ClearDataPointsBuffer(); } if( canvas ){ diff --git a/Scope.cpp b/Scope.cpp index dbc5f81..18533ac 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -116,6 +116,7 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh tick2ns = digi[ID]->GetTick2ns(); factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1; + enableSignalSlot = false; //---setup cbScopeCh cbScopeCh->clear(); for( int i = 0; i < digi[ID]->GetNChannels(); i++) cbScopeCh->addItem("Ch-" + QString::number(i)); @@ -156,6 +157,11 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh digiMTX[ID].unlock(); }); + QPushButton * bnClearBuffer = new QPushButton("Clear Buffer/FIFO", this); + layout->addWidget(bnClearBuffer, rowID, 4); + connect(bnClearBuffer, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1);}); + + //================ Trace settings rowID ++; { @@ -308,6 +314,7 @@ void Scope::StopScope(){ } digiMTX[iDigi].lock(); digi[iDigi]->StopACQ(); + //digi[iDigi]->GetData()->PrintAllData(); digiMTX[iDigi].unlock(); digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[iDigi], -1); @@ -691,13 +698,25 @@ void Scope::EnableControl(bool enable){ if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ){ + sbReordLength->setEnabled(enable); sbPreTrigger->setEnabled(enable); + sbDCOffset->setEnabled(enable); + cbDynamicRange->setEnabled(enable); + + sbInputRiseTime->setEnabled(enable); + //sbThreshold->setEnabled(enable); + sbTriggerHoldOff->setEnabled(enable); + cbSmoothingFactor->setEnabled(enable); + sbTrapRiseTime->setEnabled(enable); sbTrapFlatTop->setEnabled(enable); sbDecayTime->setEnabled(enable); + sbPeakingTime->setEnabled(enable); - sbInputRiseTime->setEnabled(enable); - cbSmoothingFactor->setEnabled(enable); + cbPolarity->setEnabled(enable); + cbBaselineAvg->setEnabled(enable); + cbPeakAvg->setEnabled(enable); + sbPeakHoldOff->setEnabled(enable); }