From fa896b674ada5f7dc721caa6ccba675caa3791a1 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Tue, 16 May 2023 17:21:40 -0400 Subject: [PATCH] tested with PSD. seem OK --- ClassData.h | 15 ++++++----- DigiSettingsPanel.cpp | 59 +++++++++++++++++++++++++++---------------- FSUDAQ.cpp | 1 + RegisterAddress.h | 8 +++--- Scope.cpp | 53 +++++++++++++++++++++++++++++--------- test.cpp | 6 +++-- 6 files changed, 97 insertions(+), 45 deletions(-) diff --git a/ClassData.h b/ClassData.h index 04bdf0a..0c57aa2 100644 --- a/ClassData.h +++ b/ClassData.h @@ -334,7 +334,7 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ if ( DecodePHADualChannelBlock(chMask, fastDecode, verbose) < 0 ) break; } if( DPPType == V1730_DPP_PSD_CODE ) { - if ( DecodePHADualChannelBlock(chMask, fastDecode, verbose) < 0 ) break; + if ( DecodePSDDualChannelBlock(chMask, fastDecode, verbose) < 0 ) break; } } }else{ @@ -412,6 +412,8 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ //*================================================= inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose){ + //printf("======= %s\n", __func__); + nw = nw + 1; unsigned int word = ReadBuffer(nw, verbose); @@ -647,6 +649,8 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe //*================================================= inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose){ + //printf("======= %s\n", __func__); + nw = nw + 1; unsigned int word = ReadBuffer(nw, verbose); @@ -746,7 +750,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe nw += nSample/2; }else{ for( unsigned int wi = 0; wi < nSample/2; wi++){ - nw = nw +1 ; word = ReadBuffer(nw, verbose - 2); + nw = nw +1 ; word = ReadBuffer(nw, verbose-4); bool dp2b = (( word >> 31 ) & 0x1 ); bool dp1b = (( word >> 30 ) & 0x1 ); unsigned short waveb = (( word >> 16) & 0x3FFF); @@ -786,9 +790,9 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe nw = nw +1 ; word = ReadBuffer(nw, verbose); unsigned int Qlong = (( word >> 16) & 0xFFFF); unsigned int Qshort = (word & 0x7FFF); - bool isEnergyCorrect = ((word >> 15) & 0x1); + bool isEnergyCorrect = ((word >> 15) & 0x1); // the PUR, either pileup or saturated - if( isEnergyCorrect == 1 ) { + if( isEnergyCorrect == 0 ) { EventIndex[channel] ++; if( EventIndex[channel] > MaxNData ) EventIndex[channel] = 0; @@ -799,8 +803,6 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe Energy2[channel][EventIndex[channel]] = Qlong; Timestamp[channel][EventIndex[channel]] = timeStamp; - //TODO pile up - if( SaveWaveToMemory ) { if( hasDualTrace ){ Waveform1[channel][EventIndex[channel]] = tempWaveform1; @@ -810,6 +812,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe } DigiWaveform1[channel][EventIndex[channel]] = tempDigiWaveform1; DigiWaveform2[channel][EventIndex[channel]] = tempDigiWaveform2; + } } diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 6c1447c..28c5655 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -1278,8 +1278,8 @@ void DigiSettingsPanel::SetUpPHABoard(){ SetUpComboBoxBit(cbAnaProbe1[ID], "Ana. Probe 1 ", bdCfgLayout[ID], 1, 2, DPP::Bit_BoardConfig::ListAnaProbe1_PHA, DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe1, 1, 0); SetUpComboBoxBit(cbAnaProbe2[ID], "Ana. Probe 2 ", bdCfgLayout[ID], 2, 2, DPP::Bit_BoardConfig::ListAnaProbe2_PHA, DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe2, 1, 0); - SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", bdCfgLayout[ID], 3, 2, DPP::Bit_BoardConfig::ListDigiProbe1_PHA, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1, 1, 0); - SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", bdCfgLayout[ID], 4, 2, DPP::Bit_BoardConfig::ListDigiProbe2_PHA, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel2, 1, 0); + SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", bdCfgLayout[ID], 3, 2, DPP::Bit_BoardConfig::ListDigiProbe1_PHA, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PHA, 1, 0); + SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", bdCfgLayout[ID], 4, 2, DPP::Bit_BoardConfig::ListDigiProbe2_PHA, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel2_PHA, 1, 0); } @@ -1715,14 +1715,14 @@ void DigiSettingsPanel::SetUpPSDBoard(){ SetUpCheckBox(chkAutoDataFlush[ID], "Auto Data Flush", bdCfgLayout[ID], 1, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableAutoDataFlush); SetUpCheckBox(chkTrigPropagation[ID], "Trig. Propagate", bdCfgLayout[ID], 2, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::TrigPropagation); - SetUpCheckBox(chkDecimateTrace[ID], "Disable Digi. Trace", bdCfgLayout[ID], 3, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DisableDigiTrace); + SetUpCheckBox(chkDecimateTrace[ID], "Disable Digi. Trace", bdCfgLayout[ID], 3, 0, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DisableDigiTrace_PSD); SetUpCheckBox(chkTraceRecording[ID], "Record Trace", bdCfgLayout[ID], 2, 1, DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace); SetUpCheckBox(chkEnableExtra2[ID], "Enable Extra", bdCfgLayout[ID], 3, 1, DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableExtra2); SetUpComboBoxBit(cbAnaProbe1[ID], "Ana. Probe ", bdCfgLayout[ID], 1, 2, DPP::Bit_BoardConfig::ListAnaProbe_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnaProbe_PSD, 1, 0); - SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", bdCfgLayout[ID], 3, 2, DPP::Bit_BoardConfig::ListDigiProbe1_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1, 1, 0); - SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", bdCfgLayout[ID], 4, 2, DPP::Bit_BoardConfig::ListDigiProbe2_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel2, 1, 0); + SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", bdCfgLayout[ID], 3, 2, DPP::Bit_BoardConfig::ListDigiProbe1_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PHA, 1, 0); + SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", bdCfgLayout[ID], 4, 2, DPP::Bit_BoardConfig::ListDigiProbe2_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel2_PHA, 1, 0); } @@ -2371,26 +2371,12 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ chkEnableExtra2[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::EnableExtra2) ); - int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1); - for(int i = 0; i < cbDigiProbe1[ID]->count(); i++){ - if( cbDigiProbe1[ID]->itemData(i).toInt() == temp) { - cbDigiProbe1[ID]->setCurrentIndex(i); - break; - } - } - temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel2); - for(int i = 0; i < cbDigiProbe2[ID]->count(); i++){ - if( cbDigiProbe2[ID]->itemData(i).toInt() == temp) { - cbDigiProbe2[ID]->setCurrentIndex(i); - break; - } - } if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) { chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DecimateTrace) ); chkDualTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DualTrace) ); - temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1); + int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1); for( int i = 0; i < cbAnaProbe1[ID]->count(); i++){ if( cbAnaProbe1[ID]->itemData(i).toInt() == temp) { cbAnaProbe1[ID]->setCurrentIndex(i); @@ -2405,17 +2391,46 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ break; } } + temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1_PHA); + for(int i = 0; i < cbDigiProbe1[ID]->count(); i++){ + if( cbDigiProbe1[ID]->itemData(i).toInt() == temp) { + cbDigiProbe1[ID]->setCurrentIndex(i); + break; + } + } + temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel2_PHA); + for(int i = 0; i < cbDigiProbe2[ID]->count(); i++){ + if( cbDigiProbe2[ID]->itemData(i).toInt() == temp) { + cbDigiProbe2[ID]->setCurrentIndex(i); + break; + } + } } if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) { - chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DisableDigiTrace) ); - temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnaProbe_PSD); + chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DisableDigiTrace_PSD) ); + int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnaProbe_PSD); for( int i = 0; i < cbAnaProbe1[ID]->count(); i++){ if( cbAnaProbe1[ID]->itemData(i).toInt() == temp) { cbAnaProbe1[ID]->setCurrentIndex(i); break; } } + + temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1_PSD); + for(int i = 0; i < cbDigiProbe1[ID]->count(); i++){ + if( cbDigiProbe1[ID]->itemData(i).toInt() == temp) { + cbDigiProbe1[ID]->setCurrentIndex(i); + break; + } + } + temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel2_PSD); + for(int i = 0; i < cbDigiProbe2[ID]->count(); i++){ + if( cbDigiProbe2[ID]->itemData(i).toInt() == temp) { + cbDigiProbe2[ID]->setCurrentIndex(i); + break; + } + } } //*======================================== uint32_t chMask = digi[ID]->GetSettingFromMemory(DPP::ChannelEnableMask); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 4be4167..3d0f3f6 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -613,6 +613,7 @@ void MainWindow::StartACQ(){ readDataThread[i]->SetSaveData(chkSaveData->isChecked()); } digi[i]->StartACQ(); + readDataThread[i]->SetSaveData(false); readDataThread[i]->start(); } if( chkSaveData->isChecked() ) SaveLastRunFile(); diff --git a/RegisterAddress.h b/RegisterAddress.h index e363866..a43bedc 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -206,9 +206,8 @@ namespace DPP { const std::pair AnalogProbe2 = {2, 14} ; const std::pair RecordTrace = {1, 16} ; const std::pair EnableExtra2 = {1, 17} ; - const std::pair DigiProbel1 = {4, 20} ; - const std::pair DigiProbel2 = {3, 26} ; - const std::pair DisableDigiTrace = {1, 31} ; + const std::pair DigiProbel1_PHA = {4, 20} ; + const std::pair DigiProbel2_PHA = {3, 26} ; const std::vector> ListAnaProbe1_PHA = {{"Input", 0}, {"RC-CR", 1}, @@ -238,6 +237,9 @@ namespace DPP { ///-------------------------- const std::pair AnaProbe_PSD = {3, 11} ; + const std::pair DigiProbel1_PSD = {3, 23} ; + const std::pair DigiProbel2_PSD = {3, 26} ; + const std::pair DisableDigiTrace_PSD = {1, 31} ; const std::vector> ListAnaProbe_PSD = {{"Input + N/A", 0}, {"CFD + N/A", 2}, {"Input + Baseline",1}, diff --git a/Scope.cpp b/Scope.cpp index 2d17a29..b007891 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -125,6 +125,15 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh layout->addWidget(bnReadSettingsFromBoard, rowID, 2); connect(bnReadSettingsFromBoard, &QPushButton::clicked, this, &Scope::ReadSettingsFromBoard); + + QPushButton * bnClearMemory = new QPushButton("Clear Memory", this); + layout->addWidget(bnClearMemory, rowID, 3); + connect(bnClearMemory, &QPushButton::clicked, this, [=](){ + digiMTX[ID].lock(); + digi[ID]->GetData()->ClearData(); + digiMTX[ID].unlock(); + }); + //================ Trace settings rowID ++; { @@ -290,11 +299,22 @@ void Scope::UpdateScope(){ //printf("--- %d | %d \n", index, traceLength ); QVector points[4]; - for( int i = 0; i < (int) (data->Waveform1[ch][index]).size() ; i++ ) { - points[0].append(QPointF(ch2ns * i * factor, (data->Waveform1[ch][index])[i])); - if( i < (int) data->Waveform2[ch][index].size() ) points[1].append(QPointF(ch2ns * i * factor, (data->Waveform2[ch][index])[i])); - if( i < (int) data->DigiWaveform1[ch][index].size() ) points[2].append(QPointF(ch2ns * i * factor, (data->DigiWaveform1[ch][index])[i] * 1000)); - if( i < (int) data->DigiWaveform2[ch][index].size() ) points[3].append(QPointF(ch2ns * i * factor, (data->DigiWaveform2[ch][index])[i] * 1000 + 500)); + if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) { + for( int i = 0; i < (int) (data->Waveform1[ch][index]).size() ; i++ ) { + points[0].append(QPointF(ch2ns * i * factor, (data->Waveform1[ch][index])[i])); + points[1].append(QPointF(ch2ns * i * factor, (data->Waveform2[ch][index])[i])); + points[2].append(QPointF(ch2ns * i * factor, (data->DigiWaveform1[ch][index])[i] * 1000)); + points[3].append(QPointF(ch2ns * i * factor, (data->DigiWaveform2[ch][index])[i] * 1000 + 500)); + } + } + + if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) { + for( int i = 0; i < (int) (data->DigiWaveform1[ch][index]).size() ; i++ ) { + if( i < (int) data->Waveform1[ch][index].size() ) points[0].append(QPointF(ch2ns * i * factor, (data->Waveform1[ch][index])[i])); + if( i < (int) data->Waveform2[ch][index].size() ) points[1].append(QPointF(ch2ns * i * factor, (data->Waveform2[ch][index])[i])); + if( i < (int) data->DigiWaveform1[ch][index].size() ) points[2].append(QPointF(ch2ns * i, (data->DigiWaveform1[ch][index])[i] * 1000)); + if( i < (int) data->DigiWaveform2[ch][index].size() ) points[3].append(QPointF(ch2ns * i, (data->DigiWaveform2[ch][index])[i] * 1000 + 500)); + } } dataTrace[0]->replace(points[0]); dataTrace[1]->replace(points[1]); @@ -517,7 +537,7 @@ void Scope::SetUpPHAPanel(){ } connect(cbDigiProbe1, &RComboBox::currentIndexChanged, this, [=](){ if( !enableSignalSlot ) return; - digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex()); + digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PHA, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex()); dataTrace[2]->setName(cbDigiProbe1->currentText()); }); @@ -566,7 +586,16 @@ void Scope::SetUpPSDPanel(){ connect(cbAnaProbe1, &RComboBox::currentIndexChanged, this, [=](){ if( !enableSignalSlot ) return; digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnaProbe_PSD, cbAnaProbe1->currentData().toInt(), cbScopeCh->currentIndex()); - dataTrace[0]->setName(cbAnaProbe1->currentText()); + //dataTrace[0]->setName(cbAnaProbe1->currentText()); + + switch( cbAnaProbe1->currentIndex() ){ + case 0 : dataTrace[0]->setName("input"); dataTrace[1]->setName("N/A"); break; + case 1 : dataTrace[0]->setName("CFD"); dataTrace[1]->setName("N/A"); break; + case 2 : dataTrace[0]->setName("baseline"); dataTrace[1]->setName("input"); break; + case 3 : dataTrace[0]->setName("baseline"); dataTrace[1]->setName("CFD"); break; + case 4 : dataTrace[0]->setName("CFD"); dataTrace[1]->setName("input"); break; + } + }); SetUpComboBoxSimple(cbDigiProbe1, "Digi. Probe 1 ", rowID, 4); @@ -575,7 +604,7 @@ void Scope::SetUpPSDPanel(){ } connect(cbDigiProbe1, &RComboBox::currentIndexChanged, this, [=](){ if( !enableSignalSlot ) return; - digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex()); + digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PSD, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex()); dataTrace[2]->setName(cbDigiProbe1->currentText()); }); @@ -585,7 +614,7 @@ void Scope::SetUpPSDPanel(){ } connect(cbDigiProbe2, &RComboBox::currentIndexChanged, this, [=](){ if( !enableSignalSlot ) return; - digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex()); + digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PSD, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex()); dataTrace[3]->setName(cbDigiProbe2->currentText()); }); @@ -724,7 +753,7 @@ void Scope::UpdatePHAPanel(){ break; } } - temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1); + temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1_PHA); for(int i = 0; i < cbDigiProbe1->count(); i++){ if( cbDigiProbe1->itemData(i).toInt() == temp) { cbDigiProbe1->setCurrentIndex(i); @@ -764,7 +793,7 @@ void Scope::UpdatePSDPanel(){ break; } } - temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1); + temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1_PSD); for( int i = 0; i < cbDigiProbe1->count(); i++){ if( cbDigiProbe1->itemData(i).toInt() == temp ) { cbDigiProbe1->setCurrentIndex(i); @@ -772,7 +801,7 @@ void Scope::UpdatePSDPanel(){ break; } } - temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel2); + temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel2_PSD); for( int i = 0; i < cbDigiProbe2->count(); i++){ if( cbDigiProbe2->itemData(i).toInt() == temp ) { cbDigiProbe2->setCurrentIndex(i); diff --git a/test.cpp b/test.cpp index dd770f8..cc962e0 100644 --- a/test.cpp +++ b/test.cpp @@ -40,12 +40,14 @@ int main(int argc, char* argv[]){ Data * data = dig[0]->GetData(); + printf("################# DPP Type : %d , %s\n", data->DPPType, data->DPPTypeStr.c_str()); + dig[0]->StartACQ(); - for( int i = 0; i < 50; i ++ ){ + for( int i = 0; i < 5; i ++ ){ usleep(100*1000); dig[0]->ReadData(); - data->DecodeBuffer(false, 3); + data->DecodeBuffer(false, 5); data->PrintStat(); int index = data->NumEventsDecoded[0];