From d3f97358e2e1ad3d9f969459898fe90eece52b20 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Thu, 21 Nov 2024 18:21:32 -0500 Subject: [PATCH] QDC, Add the OverThresholdWidth setting, but only for ROC > 4.15 and AMC > 135.15 --- ClassDigitizer.cpp | 30 +++++++++++++++++++++++++-- ClassDigitizer.h | 2 ++ DigiSettingsPanel.cpp | 47 ++++++++++++++++++++++++++++++++++--------- DigiSettingsPanel.h | 4 ++-- RegisterAddress.h | 6 +++--- 5 files changed, 72 insertions(+), 17 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 80570d1..f15514e 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -142,8 +142,31 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose NCoupledCh = NumRegChannel; isInputChEqRegCh = false; ModelType = ModelTypeCode::VME; - tick2ns = 16.0; break; ///ns -> 62.5 MSamples/s - } + tick2ns = 16.0; ///ns -> 62.5 MSamples/s + + std::string ROC = BoardInfo.ROC_FirmwareRel; + std::string AMC = BoardInfo.AMC_FirmwareRel; + + std::size_t pos = ROC.find(" - "); + std::string versionROCStr = (pos != std::string::npos) ? ROC.substr(0, pos) : ""; + pos = AMC.find(" - "); + std::string versionAMCStr = (pos != std::string::npos) ? AMC.substr(0, pos) : ""; + + double versionROC = 0.0; + double versionAMC = 0.0; + if (!versionROCStr.empty()) versionROC = std::stod(versionROCStr); + if (!versionAMCStr.empty()) versionAMC = std::stod(versionAMCStr); + + printf(" QDC ROC version : %.2f \n", versionROC); + printf(" QDC AMC version : %.2f \n", versionAMC); + if( versionROC <= 4.25 || versionAMC <= 135.15 ){ + printf(" QDC ROC or AMC version not support OverThreshold Width.\n"); + hasOverThresholdWidth = false; + }else{ + hasOverThresholdWidth = true; + } + + }; break; default : tick2ns = 4.0; break; } @@ -777,6 +800,7 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool } if( registerAddress.GetRWType() == RW::ReadONLY ) return; + if( !hasOverThresholdWidth && registerAddress == DPP::QDC::OverThresholdWidth ) return ; ret = CAEN_DGTZ_WriteRegister(handle, registerAddress.ActualAddress(ch), value); @@ -821,6 +845,8 @@ uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool is if( registerAddress.GetRWType() == RW::WriteONLY ) return 0; // if( registerAddress == DPP::QDC::RecordLength_W ) return 0; + if( !hasOverThresholdWidth && registerAddress == DPP::QDC::OverThresholdWidth ) return 0; + ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), &returnData); if( ret == 0 && isSave2MemAndFile && !AcqRun) { diff --git a/ClassDigitizer.h b/ClassDigitizer.h index af10da9..36bc628 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -60,6 +60,7 @@ class Digitizer{ bool isSettingFileExist; /// bool isSettingFileUpdate; bool isSettingFilledinMemeory; /// false for disabled ReadAllSettingFromBoard() + bool hasOverThresholdWidth; /// for QDC unsigned int setting[SETTINGSIZE]; /// Setting, 4bytes x 2048 = 8192 bytes //^-------- other protected functions @@ -152,6 +153,7 @@ class Digitizer{ int GetErrorCode() const {return ret;} unsigned int GetChMemSizekSample() const {return MemorySizekSample;} std::string GetFamilyName() const {return familyName;} + bool HasOverThresholdWidth_QDC() const {return hasOverThresholdWidth;} //^================ Setting Reg FindRegister(uint32_t address); diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 0377d5a..0c66b11 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -2760,13 +2760,22 @@ void DigiSettingsPanel::SetUpChannel_QDC(){ SetUpCheckBox(chkDisableSelfTrigger[ID][numGroup], "Disable Self Trigger ", triggerLayout, 0, 1, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableSelfTrigger); SetUpCheckBox(chkDisableTriggerHysteresis[ID][numGroup], "Disbale Trig. Hysteresis ", triggerLayout, 2, 1, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableTriggerHysteresis, -1, 2); + SetUpComboBoxBit(cbTrigMode[ID][numGroup], "Trig. Mode : ", triggerLayout, 0, 2, DPP::QDC::Bit_DPPAlgorithmControl::ListTrigMode, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::TriggerMode); SetUpSpinBox(sbTriggerHoldOff[ID][numGroup], "Trig. Holdoff [ns] : ", triggerLayout, 2, 2, DPP::QDC::TriggerHoldOffWidth); SetUpSpinBox(sbShapedTrigWidth[ID][numGroup], "Trig. Out Width [ns] : ", triggerLayout, 3, 2, DPP::QDC::TRGOUTWidth); + + int rowID = 4; + if( digi[ID]->HasOverThresholdWidth_QDC() ){ + SetUpCheckBox(chkOverthreshold[ID][numGroup], "Enable OverThreshold Width ", triggerLayout, rowID, 1, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::OverThresholdWitdhEnable); + SetUpSpinBox(sbOverThresholdWidth[ID][numGroup], "OverThreshold Width [ns] :", triggerLayout, rowID, 2, DPP::QDC::OverThresholdWidth); + rowID ++; + } + /// Trigger Threshold QGroupBox * widget = new QGroupBox("Threshold [LSB]", triggerBox); - triggerLayout->addWidget(widget, 4, 0, 1, 4); + triggerLayout->addWidget(widget, rowID, 0, 1, 4); QGridLayout * dcLayout = new QGridLayout(widget); dcLayout->setSpacing(2); @@ -3025,7 +3034,7 @@ void DigiSettingsPanel::SetUpChannel_QDC(){ QTabWidget * trigTab = new QTabWidget(this); trigLayout->addWidget(trigTab); - QStringList tabName = {"Common Settings", "Threshold", "Others"}; + QStringList tabName = {"Common Settings", "Threshold", "OverThreshold Width", "Others"}; const int nTab = tabName.count(); @@ -3105,6 +3114,20 @@ void DigiSettingsPanel::SetUpChannel_QDC(){ } if( i == 2 ){ + + if( digi[ID]->HasOverThresholdWidth_QDC() ){ + if( ch == 0 ){ + QLabel * lb0 = new QLabel("OverThreshold Width [ns]", this); lb0->setAlignment(Qt::AlignHCenter); tabLayout->addWidget(lb0, 0, 4); + } + SetUpCheckBox(chkOverthreshold[ID][ch], "Enable OverThreshold Width ", tabLayout, ch+1, 1, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::OverThresholdWitdhEnable, ch); + SetUpSpinBox(sbOverThresholdWidth[ID][ch], "", tabLayout, ch+1, 3, DPP::QDC::OverThresholdWidth, ch); + }else{ + QLabel * lb0 = new QLabel("OverThreshold Width not supported.", this); lb0->setAlignment(Qt::AlignHCenter); tabLayout->addWidget(lb0, 0, 1); + } + + } + + if( i == 3 ){ SetUpCheckBox(chkDisableSelfTrigger[ID][ch], "Disable Self Trigger ", tabLayout, ch+1, 1, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableSelfTrigger, ch); SetUpCheckBox(chkDisableTriggerHysteresis[ID][ch], "Disbale Trig. Hysteresis ", tabLayout, ch+1, 3, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableTriggerHysteresis, ch, 2); } @@ -3113,7 +3136,7 @@ void DigiSettingsPanel::SetUpChannel_QDC(){ } } -{//^================================== QDC + {//^================================== QDC QVBoxLayout *trapLayout = new QVBoxLayout(chTrap); @@ -3172,7 +3195,7 @@ void DigiSettingsPanel::SetUpChannel_QDC(){ } } -{//^======================================== Others + {//^======================================== Others QVBoxLayout *otherLayout = new QVBoxLayout(chOthers); QTabWidget * othersTab = new QTabWidget(this); @@ -3972,22 +3995,23 @@ void DigiSettingsPanel::SyncAllChannelsTab_QDC(){ DebugPrint("%s", "DigiSettingsPanel"); if( !enableSignalSlot ) return; - // SyncSpinBox(sbRecordLength); SyncSpinBox(sbPreTrigger); SyncSpinBox(sbDCOffset); SyncSpinBox(sbTriggerHoldOff); SyncSpinBox(sbShapedTrigWidth); - // SyncSpinBox(sbNumEventAgg); SyncSpinBox(sbShortGate); SyncSpinBox(sbGateOffset); - //SyncSpinBox(sbOverThresholdWidth); SyncCheckBox(chkDisableSelfTrigger); SyncCheckBox(chkDisableTriggerHysteresis); - //SyncCheckBox(chkOverthreshold); SyncCheckBox(chkChargePedestal); SyncCheckBox(chkTestPule); + if( digi[ID]->HasOverThresholdWidth_QDC() ){ + SyncSpinBox(sbOverThresholdWidth); + SyncCheckBox(chkOverthreshold); + } + SyncComboBox(cbPolarity); SyncComboBox(cbRCCR2Smoothing); SyncComboBox(cbBaseLineAvg); @@ -4081,7 +4105,7 @@ void DigiSettingsPanel::UpdateSettings_QDC(){ UpdateSpinBox(sbShapedTrigWidth[ID][grp], DPP::QDC::TRGOUTWidth, grp); UpdateSpinBox(sbShortGate[ID][grp], DPP::QDC::GateWidth, grp); UpdateSpinBox(sbGateOffset[ID][grp], DPP::QDC::GateOffset, grp); - //UpdateSpinBox(sbOverThresholdWidth[ID][grp], DPP::QDC::OverThresholdWidth, grp); + uint32_t subChMask = digi[ID]->GetSettingFromMemory(DPP::QDC::SubChannelMask, grp); @@ -4104,10 +4128,13 @@ void DigiSettingsPanel::UpdateSettings_QDC(){ chkDisableSelfTrigger[ID][grp]->setChecked( Digitizer::ExtractBits(dpp, DPP::QDC::Bit_DPPAlgorithmControl::DisableSelfTrigger) ); chkDisableTriggerHysteresis[ID][grp]->setChecked( Digitizer::ExtractBits(dpp, DPP::QDC::Bit_DPPAlgorithmControl::DisableTriggerHysteresis) ); - //chkOverthreshold[ID][grp]->setChecked( Digitizer::ExtractBits(dpp, DPP::QDC::Bit_DPPAlgorithmControl::OverThresholdWitdhEnable) ); chkChargePedestal[ID][grp]->setChecked( Digitizer::ExtractBits(dpp, DPP::QDC::Bit_DPPAlgorithmControl::ChargePedestal)); chkTestPule[ID][grp]->setChecked( Digitizer::ExtractBits(dpp, DPP::QDC::Bit_DPPAlgorithmControl::InternalTestPulse)); + if( digi[ID]->HasOverThresholdWidth_QDC() ) { + UpdateSpinBox(sbOverThresholdWidth[ID][grp], DPP::QDC::OverThresholdWidth, grp); + chkOverthreshold[ID][grp]->setChecked( Digitizer::ExtractBits(dpp, DPP::QDC::Bit_DPPAlgorithmControl::OverThresholdWitdhEnable) ); + } uint32_t dcOffSet_low = digi[ID]->GetSettingFromMemory(DPP::QDC::DCOffset_LowCh, grp); diff --git a/DigiSettingsPanel.h b/DigiSettingsPanel.h index 80f6c06..407aabd 100644 --- a/DigiSettingsPanel.h +++ b/DigiSettingsPanel.h @@ -294,8 +294,8 @@ private: //Trig Hold off with -> sbTriggerHoldOff //Trig out width -> sbShapedTrigWidth - //QCheckBox * chkOverthreshold[MaxNDigitizer][MaxRegChannel+1]; //TODO need firmware version 4.25 & 135.17 - //RSpinBox * sbOverThresholdWidth[MaxNDigitizer][MaxRegChannel + 1]; + QCheckBox * chkOverthreshold[MaxNDigitizer][MaxRegChannel+1]; //TODO need firmware version 4.25 & 135.17 + RSpinBox * sbOverThresholdWidth[MaxNDigitizer][MaxRegChannel + 1]; QPushButton * pbSubChMask[MaxNDigitizer][MaxRegChannel+1][8]; RSpinBox * sbSubChOffset[MaxNDigitizer][MaxRegChannel + 1][8]; RSpinBox * sbSubChThreshold[MaxNDigitizer][MaxRegChannel + 1][8]; diff --git a/RegisterAddress.h b/RegisterAddress.h index 905257b..9be71e9 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -795,7 +795,7 @@ namespace DPP { const Reg DPPAlgorithmControl ("DPPAlgorithmControl" , 0x1040, RW::ReadWrite, false, {}); /// R/W const Reg TriggerHoldOffWidth ("Trigger Hold-off width" , 0x1074, RW::ReadWrite, false, 0xFFFF, 1); /// R/W const Reg TRGOUTWidth ("Trigger out width" , 0x1078, RW::ReadWrite, false, 0xFFFF, 1); /// R/W - //const Reg OverThresholdWidth ("Over Threshold width" , 0x107C, RW::ReadWrite, false, 0xFFFF, 1); /// R/W // need firmware version 4.25 & 135.17 + const Reg OverThresholdWidth ("Over Threshold width" , 0x107C, RW::ReadWrite, false, 0xFFFF, 1); /// R/W // need firmware version 4.25 & 135.17 const Reg GroupStatus_R ("Group Status" , 0x1088, RW::ReadONLY, false, {}); /// R/ const Reg AMCFirmwareRevision_R ("AMC firmware version" , 0x108C, RW::ReadONLY, false, {}); /// R/ const Reg DCOffset ("DC offset" , 0x1098, RW::ReadWrite, false, 0xFFFF, -1); /// R/W @@ -821,7 +821,7 @@ namespace DPP { const std::pair ChargeSensitivity = {3, 0} ; /// length, smallest pos const std::pair InternalTestPulse = {1, 4}; const std::pair TestPulseRate = {2, 5}; - //const std::pair OverThresholdWitdhEnable = {1, 7}; ///need firmware version 4.25 & 135.17 + const std::pair OverThresholdWitdhEnable = {1, 7}; ///need firmware version 4.25 & 135.17 const std::pair ChargePedestal = {1, 8}; const std::pair InputSmoothingFactor = {3, 12}; const std::pair Polarity = {1, 16}; @@ -937,7 +937,7 @@ const std::vector RegisterChannelList_QDC = { DPP::QDC::DPPAlgorithmControl, DPP::QDC::TriggerHoldOffWidth, DPP::QDC::TRGOUTWidth, - //DPP::QDC::OverThresholdWidth, + DPP::QDC::OverThresholdWidth, DPP::QDC::GroupStatus_R, DPP::QDC::AMCFirmwareRevision_R, DPP::QDC::DCOffset,