From c37f132477c0d3d4ff5f5bce20b24a6abd6203ea Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Fri, 28 Apr 2023 18:18:34 -0400 Subject: [PATCH] added channel settings (only UI) --- DigiSettingsPanel.cpp | 178 +++++++++++++++++++++++++++++++++++++++--- DigiSettingsPanel.h | 5 ++ RegisterAddress.h | 75 +++++++++++++++++- 3 files changed, 245 insertions(+), 13 deletions(-) diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index a2222c9..76815a0 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -32,7 +32,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QMai enableSignalSlot = false; setWindowTitle("Digitizer Settings"); - setGeometry(0, 0, 1000, 800); + setGeometry(0, 0, 1300, 800); tabWidget = new QTabWidget(this); setCentralWidget(tabWidget); @@ -141,6 +141,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QMai int rowID = 0 ; QLabel * lbSavePath = new QLabel("Save File Path : ", this); + lbSavePath->setAlignment(Qt::AlignRight | Qt::AlignCenter); buttonLayout->addWidget(lbSavePath, rowID, 0); leSaveFilePath = new QLineEdit(this); @@ -284,15 +285,35 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QMai QTabWidget * chTab = new QTabWidget(tab); tabLayout_H->addWidget(chTab); - QScrollArea * scrollArea = new QScrollArea(this); - scrollArea->setWidgetResizable(true); - scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - chTab->addTab(scrollArea, "Channel Settings"); + chAllSetting = new QWidget(this); + //chAllSetting->setStyleSheet("background-color: #ECECEC;"); + chTab->addTab(chAllSetting, "Channel Settings"); + + QWidget * chStatus = new QWidget(this); + //chStatus->setStyleSheet("background-color: #ECECEC;"); + chTab->addTab(chStatus, "Status"); + + QWidget * chInput = new QWidget(this); + chTab->addTab(chInput, "Input"); + + QWidget * chTrap = new QWidget(this); + chTab->addTab(chTrap, "Trapezoid"); + + QWidget * chOthers = new QWidget(this); + chTab->addTab(chOthers, "Others"); + + QWidget * chTrigger = new QWidget(this); + chTab->addTab(chTrigger, "Trigger"); + + SetUpPHAChannel(); } } + //TODO ----- Copy settings tab + + connect(tabWidget, &QTabWidget::currentChanged, this, [=](int index){ if( index < (int) nDigi) { ID = index; @@ -411,6 +432,7 @@ void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout sb->setValue( (std::round(value/step)*step)); } + sb->setStyleSheet(""); digi[ID]->WriteRegister(para, sb->value(), -1); //TODO for each channel }); @@ -485,9 +507,9 @@ void DigiSettingsPanel::SetUpPHABoard(){ SetUpCheckBox(chkEnableExtra2[ID], "Enable Extra2", settingLayout[ID], 3, 1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::EnableExtra2); - SetUpComboBoxBit(cbAnaProbe1[ID], "Ana. Probe 1 ", settingLayout[ID], 1, 2, Register::DPP::Bit_BoardConfig::ListAnaProbe1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::AnalogProbe1); - SetUpComboBoxBit(cbAnaProbe2[ID], "Ana. Probe 2 ", settingLayout[ID], 2, 2, Register::DPP::Bit_BoardConfig::ListAnaProbe2, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::AnalogProbe2); - SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", settingLayout[ID], 3, 2, Register::DPP::Bit_BoardConfig::ListDigiProbe1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DigiProbel1); + SetUpComboBoxBit(cbAnaProbe1[ID], "Ana. Probe 1 ", settingLayout[ID], 1, 2, Register::DPP::Bit_BoardConfig::ListAnaProbe1_PHA, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::AnalogProbe1); + SetUpComboBoxBit(cbAnaProbe2[ID], "Ana. Probe 2 ", settingLayout[ID], 2, 2, Register::DPP::Bit_BoardConfig::ListAnaProbe2_PHA, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::AnalogProbe2); + SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", settingLayout[ID], 3, 2, Register::DPP::Bit_BoardConfig::ListDigiProbe1_PHA, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DigiProbel1); SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", settingLayout[ID], 4, 2, {{"trigger", 0}}, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DigiProbel2); cbDigiProbe2[ID]->setEnabled(false); @@ -547,6 +569,144 @@ void DigiSettingsPanel::SetUpPHABoard(){ } +void DigiSettingsPanel::SetUpPHAChannel(){ + + QVBoxLayout * allSettingLayout = new QVBoxLayout(chAllSetting); + allSettingLayout->setAlignment(Qt::AlignTop); + + {//^========================= input + QGroupBox * inputBox = new QGroupBox("input Settings", this); + allSettingLayout->addWidget(inputBox); + + QGridLayout * inputLayout = new QGridLayout(inputBox); + + RSpinBox * sbRecordLength; + SetUpSpinBox(sbRecordLength, "Record Length [G][ns] : ", inputLayout, 0, 0, Register::DPP::RecordLength_G); + + RComboBox * cbDynamicRange; + SetUpComboBox(cbDynamicRange, "Dynamic Range : ", inputLayout, 0, 2, Register::DPP::InputDynamicRange); + + RSpinBox * sbPreTrigger; + SetUpSpinBox(sbPreTrigger, "Pre-Trigger [ns] : ", inputLayout, 1, 0, Register::DPP::PreTrigger); + + RComboBox * cbRCCR2Smoothing; + SetUpComboBox(cbRCCR2Smoothing, "Smoothing factor : ", inputLayout, 1, 2, Register::DPP::PHA::RCCR2SmoothingFactor); + + RSpinBox * sbInputRiseTime; + SetUpSpinBox(sbInputRiseTime, "Rise Time [ns] : ", inputLayout, 2, 0, Register::DPP::PHA::InputRiseTime); + + RSpinBox * sbThreshold; + SetUpSpinBox(sbThreshold, "Threshold [LSB] : ", inputLayout, 2, 2, Register::DPP::PHA::TriggerThreshold); + + RSpinBox * sbRiseTimeValidWin; + SetUpSpinBox(sbRiseTimeValidWin, "Rise Time Valid. Win. [ns] : ", inputLayout, 3, 0, Register::DPP::PHA::RiseTimeValidationWindow); + + RSpinBox * sbTriggerHoldOff; + SetUpSpinBox(sbTriggerHoldOff, "Tigger Hold-off [ns] : ", inputLayout, 3, 2, Register::DPP::PHA::TriggerHoldOffWidth); + + RSpinBox * sbShapedTrigWidth; + SetUpSpinBox(sbShapedTrigWidth, "Shaped Trig. Width [ns] : ", inputLayout, 4, 0, Register::DPP::PHA::ShapedTriggerWidth); + + RSpinBox * sbDCOffset; + SetUpSpinBox(sbDCOffset, "DC Offset [%] : ", inputLayout, 4, 2, Register::DPP::ChannelDCOffset); + + RComboBox * cbPolarity; + SetUpComboBoxBit(cbPolarity, "Polarity : ", inputLayout, 5, 0, Register::DPP::Bit_DPPAlgorithmControl::ListPolarity, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::Polarity); + + } + + {//^===================== Trapezoid + QGroupBox * trapBox = new QGroupBox("Trapezoid Settings", this); + allSettingLayout->addWidget(trapBox); + + QGridLayout * trapLayout = new QGridLayout(trapBox); + + RSpinBox * sbTrapRiseTime; + SetUpSpinBox(sbTrapRiseTime, "Rise Time [ns] : ", trapLayout, 0, 0, Register::DPP::PHA::TrapezoidRiseTime); + + RSpinBox * sbTrapFlatTop; + SetUpSpinBox(sbTrapFlatTop, "Flat Top [ns] : ", trapLayout, 0, 2, Register::DPP::PHA::TrapezoidFlatTop); + + RSpinBox * sbDecay; + SetUpSpinBox(sbDecay, "Decay [ns] : ", trapLayout, 1, 0, Register::DPP::PHA::DecayTime); + + RSpinBox * sbTrapScaling; + SetUpSpinBox(sbTrapScaling, "Rescaling : ", trapLayout, 1, 2, Register::DPP::PHA::DPPAlgorithmControl2_G); + + RSpinBox * sbPeaking; + SetUpSpinBox(sbPeaking, "Peaking [ns] : ", trapLayout, 2, 0, Register::DPP::PHA::PeakingTime); + + RSpinBox * sbPeakingHoldOff; + SetUpSpinBox(sbPeakingHoldOff, "Peaking Hold-off [ns] : ", trapLayout, 2, 2, Register::DPP::PHA::PeakHoldOff); + + RComboBox * cbPeakAvg; + SetUpComboBoxBit(cbPeakAvg, "Peak Avg. : ", trapLayout, 3, 0, Register::DPP::Bit_DPPAlgorithmControl::ListPeakMean, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::PeakMean); + + RComboBox * cBaseLineAvg; + SetUpComboBoxBit(cBaseLineAvg, "Baseline Avg. : ", trapLayout, 3, 2, Register::DPP::Bit_DPPAlgorithmControl::ListBaselineAvg, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::BaselineAvg); + + QCheckBox * chkActiveBaseline; + SetUpCheckBox(chkActiveBaseline, "Active basline [G]", trapLayout, 4, 0, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::ActivebaselineCalulation); + + QCheckBox * chkBaselineRestore; + SetUpCheckBox(chkBaselineRestore, "Baseline Restorer [G]", trapLayout, 4, 1, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::EnableActiveBaselineRestoration); + + RSpinBox * sbFineGain; + SetUpSpinBox(sbFineGain, "Fine Gain : ", trapLayout, 4, 2, Register::DPP::PHA::FineGain); + + + } + + {//^====================== Others + QGroupBox * otherBox = new QGroupBox("Others Settings", this); + allSettingLayout->addWidget(otherBox); + + QGridLayout * otherLayout = new QGridLayout(otherBox); + + RComboBox * cbDecimateTrace; + SetUpComboBoxBit(cbDecimateTrace, "Decimate Trace : ", otherLayout, 0, 0, Register::DPP::Bit_DPPAlgorithmControl::ListTraceDecimation, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::TraceDecimation); + + RComboBox * cbDecimateGain; + SetUpComboBoxBit(cbDecimateGain, "Decimate Gain : ", otherLayout, 0, 2, Register::DPP::Bit_DPPAlgorithmControl::ListDecimationGain, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::TraceDeciGain); + + RComboBox * cbTrigMode; + SetUpComboBoxBit(cbTrigMode, "Trig Mode : ", otherLayout, 1, 0, Register::DPP::Bit_DPPAlgorithmControl::ListTrigMode, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::TriggerMode); + + QCheckBox * chkDisableSelfTrigger; + SetUpCheckBox(chkDisableSelfTrigger, "Disable Self Trigger ", otherLayout, 1, 2, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::DisableSelfTrigger); + + QCheckBox * chkEnableRollOver; + SetUpCheckBox(chkEnableRollOver, "Enable Roll-Over Event", otherLayout, 2, 0, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::EnableRollOverFlag); + + QCheckBox * chkEnablePileUp; + SetUpCheckBox(chkEnablePileUp, "Allow Pile-up Event", otherLayout, 2, 2, Register::DPP::DPPAlgorithmControl, Register::DPP::Bit_DPPAlgorithmControl::EnablePileUpFlag); + + RComboBox * cbShapedTrigger; + SetUpComboBoxBit(cbShapedTrigger, "Local Shaped Trig. [G] : ", otherLayout, 3, 0, Register::DPP::PHA::Bit_DPPAlgorithmControl2::ListLocalShapeTrigMode, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode); + + RComboBox * cbTriggerValid; + SetUpComboBoxBit(cbTriggerValid, "Local Trig. Valid. [G] : ", otherLayout, 3, 2, Register::DPP::PHA::Bit_DPPAlgorithmControl2::ListLocalTrigValidMode, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::LocalTrigValidMode); + + RComboBox * cbExtra2Option; + SetUpComboBoxBit(cbExtra2Option, "Extra2 Option [G] : ", otherLayout, 4, 0, Register::DPP::PHA::Bit_DPPAlgorithmControl2::ListExtra2, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::Extra2Option); + + RComboBox * cbVetoSource; + SetUpComboBoxBit(cbVetoSource, "Veto Source [G] : ", otherLayout, 4, 2, Register::DPP::PHA::Bit_DPPAlgorithmControl2::ListVetoSource, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::VetoSource); + + RComboBox * cbTrigCount; + SetUpComboBoxBit(cbTrigCount, "Trig. Counter Flag [G] : ", otherLayout, 5, 0, Register::DPP::PHA::Bit_DPPAlgorithmControl2::ListTrigCounter, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::TriggerCounterFlag); + + RSpinBox * sbNumEventAgg; + SetUpSpinBox(sbNumEventAgg, "Events per Agg. [G] : ", otherLayout, 5, 2, Register::DPP::NumberEventsPerAggregate_G); + + QCheckBox * chkTagCorrelation; + SetUpCheckBox(chkTagCorrelation, "Tag Correlated events [G]", otherLayout, 6, 0, Register::DPP::PHA::DPPAlgorithmControl2_G, Register::DPP::PHA::Bit_DPPAlgorithmControl2::TagCorrelatedEvents); + + //TODO VETO width + + } + +} void DigiSettingsPanel::SetUpPSDBoard(){ @@ -685,8 +845,6 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ enableSignalSlot = true; - printf("============== end of %s \n", __func__); - } void DigiSettingsPanel::ReadSettingsFromBoard(){ diff --git a/DigiSettingsPanel.h b/DigiSettingsPanel.h index 329c446..2f99646 100644 --- a/DigiSettingsPanel.h +++ b/DigiSettingsPanel.h @@ -38,8 +38,11 @@ private: void CleanUpGroupBox(QGroupBox * & gBox); void SetUpPHABoard(); + void SetUpPHAChannel(); + void SetUpPSDBoard(); + Digitizer ** digi; unsigned int nDigi; unsigned short ID; @@ -111,6 +114,8 @@ private: RComboBox * cbTRGOUTLogic[MaxNDigitizer]; RComboBox * cbTRGOUTUseOtherTriggers[MaxNDigitizer]; // combine bit 30, 31 + /// ============================ Channel + QWidget * chAllSetting; //QPushButton * bnTriggerValidMask[MaxNDigitizer][MaxNChannels/2]; }; diff --git a/RegisterAddress.h b/RegisterAddress.h index 793c4cc..174415a 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -211,16 +211,16 @@ inline uint32_t Reg::CalAddress(unsigned int index){ const std::pair DigiProbel1 = {4, 20} ; const std::pair DigiProbel2 = {3, 26} ; - const std::vector> ListAnaProbe1 = {{"Input", 0}, + const std::vector> ListAnaProbe1_PHA = {{"Input", 0}, {"RC-CR", 1}, {"RC-CR2", 2}, {"Trapezoid", 3}}; - const std::vector> ListAnaProbe2 = {{"Input", 0}, + const std::vector> ListAnaProbe2_PHA = {{"Input", 0}, {"Threshold", 1}, {"Trap. - Baseline", 2}, {"Trap. Baseline", 3}}; - const std::vector> ListDigiProbe1 = {{"Peaking", 0}, + const std::vector> ListDigiProbe1_PHA = {{"Peaking", 0}, {"Armed", 1}, {"Peak Run", 2}, {"Pile Up", 3}, @@ -248,6 +248,36 @@ inline uint32_t Reg::CalAddress(unsigned int index){ const std::pair EnableRollOverFlag = {1, 26}; const std::pair EnablePileUpFlag = {1, 27}; + const std::vector> ListTraceDecimation = {{"Disabled", 0}, + {"2 samples", 1}, + {"4 samples", 2}, + {"8 samples", 3}}; + + const std::vector> ListDecimationGain = {{"x1", 0}, + {"x2", 1}, + {"x4", 2}, + {"x8", 3}}; + + const std::vector> ListPeakMean = {{"1 sample", 0}, + {"4 sample", 1}, + {"16 sample", 2}, + {"64 sample", 3}}; + + const std::vector> ListPolarity = {{"Positive", 0}, + {"Negative", 1}}; + + const std::vector> ListTrigMode = {{"Independent", 0}, + {"Coincident (Shape Trig.)", 1}, + {"Anti-Coincident (Shape Trig.)", 3}}; + + const std::vector> ListBaselineAvg = {{"Not Used", 0}, + {"16 samples", 1}, + {"64 samples", 2}, + {"256 samples", 3}, + {"1024 samples", 4}, + {"4096 samples", 5}, + {"16384 samples", 6}}; + } namespace Bit_AcquistionControl { @@ -434,6 +464,45 @@ inline uint32_t Reg::CalAddress(unsigned int index){ const Reg ShapedTriggerWidth ("ShapedTriggerWidth" , 0x1084, RW::ReadWrite, false, 0x3FF, 4); /// R/W not sure const Reg DPPAlgorithmControl2_G ("DPPAlgorithmControl2_G" , 0x10A0, RW::ReadWrite, true, {}); /// R/W OK const Reg FineGain ("FineGain" , 0x10C4, RW::ReadWrite, false, {}); /// R/W OK + + namespace Bit_DPPAlgorithmControl2 { + const std::pair LocalShapeTriggerMode = {3, 0} ; + const std::pair LocalTrigValidMode = {3, 4} ; + const std::pair Extra2Option = {3, 8} ; + const std::pair VetoSource = {2, 14} ; + const std::pair TriggerCounterFlag = {2, 16} ; + const std::pair ActivebaselineCalulation = {1, 18} ; + const std::pair TagCorrelatedEvents = {1, 19} ; + const std::pair EnableActiveBaselineRestoration = {1, 29} ; + + const std::vector> ListLocalShapeTrigMode = {{"Disabled", 0}, + {"AND", 4}, + {"The even Channel", 5}, + {"The odd Channel", 6}, + {"OR", 7}}; + + const std::vector> ListLocalTrigValidMode = {{"Disabled", 0}, + {"Crossed", 4}, + {"Equal", 5}, + {"AND", 6}, + {"OR", 7}}; + + const std::vector> ListExtra2 = {{"Extended timeStamp + baseline * 4", 0}, + {"Extended timeStamp + Fine timestamp", 2}, + {"Lost Trig. Count + Total Trig. Count", 4}, + {"Event Before 0-xing + After 0-xing", 5}}; + + const std::vector> ListVetoSource = {{"Disabled", 0}, + {"Common (Global Trig. Mask)", 1}, + {"Difference (Trig. Mask)", 2}, + {"Negative Saturation", 3}}; + + const std::vector> ListTrigCounter = {{"1024", 0}, + {"128", 1}, + {"8192", 2}}; + + } + } namespace PSD {