From 55ec7995c7249988651ef54d2fe8c4f10598484e Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Wed, 20 Mar 2024 15:35:48 -0400 Subject: [PATCH] when the trigger rate is small and Event/Agg is large, the trigger rate would be 0/0 = nan, fixed this. disable digiPlanel button when ACQ started --- ClassData.h | 18 ++++++++++++++---- DigiSettingsPanel.cpp | 9 ++++++++- FSUDAQ.cpp | 3 +++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ClassData.h b/ClassData.h index 30ca44f..92cbed4 100644 --- a/ClassData.h +++ b/ClassData.h @@ -47,6 +47,7 @@ class Data{ unsigned long TotNumNonPileUpEvents[MaxNChannels]; /// also exclude overthrow unsigned short NumEventsDecoded [MaxNChannels]; /// reset after trig-rate calculation unsigned short NumNonPileUpDecoded [MaxNChannels]; /// reset after trig-rate calculation + uShort countNumEventDecodeZero[MaxNChannels]; /// when > 3, set trigger rate to be zero; unsigned int TotalAggCount ; unsigned short AggCount ; /// reset after trig-rate calculation @@ -72,6 +73,7 @@ class Data{ std::vector ** DigiWaveform3; std::vector ** DigiWaveform4; + public: Data(unsigned short numCh, uInt dataSize = DefaultDataSize); ~Data(); @@ -108,7 +110,7 @@ class Data{ uint64_t GetTotalFileSize() const {return FinishedOutFilesSize + outFileSize;} void ZeroTotalFileSize() { FinishedOutFilesSize = 0; } - void CalTriggerRate(); + void CalTriggerRate(); // this method is called by FSUDAQ::UpdateScalar() void ClearReferenceTime(); protected: @@ -167,6 +169,7 @@ inline Data::Data(unsigned short numCh, uInt dataSize): numInputCh(numCh){ for ( int i = 0; i < MaxNChannels; i++) { TotNumNonPileUpEvents[i] = 0; t0[i] = 0; + countNumEventDecodeZero[i] = 0; } ClearData(); ClearTriggerRate(); @@ -286,6 +289,7 @@ inline void Data::ClearNumEventsDecoded(){ for( int i = 0 ; i < MaxNChannels; i++) { NumEventsDecoded[i] = 0; NumNonPileUpDecoded[i] = 0; + countNumEventDecodeZero[i] = 0; } AggCount = 0; } @@ -347,19 +351,23 @@ inline void Data::ClearReferenceTime(){ for( int ch = 0; ch < numInputCh; ch ++ ) t0[ch] = 0; } -inline void Data::CalTriggerRate(){ +inline void Data::CalTriggerRate(){ // this method is called by FSUDAQ::UpdateScalar() unsigned long long dTime = 0; double sec = -999; - for( int ch = 0; ch < numInputCh; ch ++ ){ - if( t0[ch] == 0 ) { + if( t0[ch] == 0 || countNumEventDecodeZero[ch] > 3) { TriggerRate[ch] = 0; NonPileUpRate[ch] = 0; + countNumEventDecodeZero[ch] = 0; continue; } + if( NumEventsDecoded[ch] == 0 ) { + countNumEventDecodeZero[ch] ++; + continue; + } if( NumEventsDecoded[ch] < dataSize ){ @@ -369,6 +377,8 @@ inline void Data::CalTriggerRate(){ TriggerRate[ch] = (NumEventsDecoded[ch])/sec; NonPileUpRate[ch] = (NumNonPileUpDecoded[ch])/sec; + // printf("%2d | %d | %f %f \n", ch, NumEventsDecoded[ch], sec, TriggerRate[ch]); + }else{ uShort nEvent = 100; diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 4d20e44..15c9e32 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -339,11 +339,18 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr enableSignalSlot = true; + //If any digitizer is running ACQ, disable the panel. + for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ + if( digi[iDigi]->IsRunning() ) { + this->setEnabled(false); + break; + } + } + } DigiSettingsPanel::~DigiSettingsPanel(){ printf("%s \n", __func__); - } //*================================================================ diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index b0053ca..3eb2d39 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -766,6 +766,7 @@ void MainWindow::CloseDigitizers(){ readDataThread = nullptr; for(unsigned int i = 0; i < nDigi; i ++){ + digi[i]->StopACQ(); digi[i]->CloseDigitizer(); delete digi[i]; } @@ -1120,6 +1121,7 @@ void MainWindow::StartACQ(){ } chkSaveData->setEnabled(false); + bnDigiSettings->setEnabled(false); } @@ -1211,6 +1213,7 @@ void MainWindow::StopACQ(){ } chkSaveData->setEnabled(true); + bnDigiSettings->setEnabled(true); }