730 lines
38 KiB
C++
730 lines
38 KiB
C++
#include <TApplication.h>
|
|
#include <TGClient.h>
|
|
#include <TCanvas.h>
|
|
#include <TF1.h>
|
|
#include <TRandom.h>
|
|
#include <TGButton.h>
|
|
#include <TRootEmbeddedCanvas.h>
|
|
#include <TGTableContainer.h>
|
|
#include <TGFileDialog.h>
|
|
|
|
#include "channelSettingPHA.h"
|
|
|
|
ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi, int boardID){
|
|
|
|
this->digi = digi;
|
|
this->nDigi = nDigi;
|
|
|
|
Pixel_t red, green;
|
|
gClient->GetColorByName("red", red);
|
|
gClient->GetColorByName("green", green);
|
|
|
|
fMain = new TGMainFrame(p,w,h);
|
|
fMain->SetWindowName("Channel Settings PHA");
|
|
fMain->Connect("CloseWindow()", "ChannelSettingPHA", this, "CloseWindow()");
|
|
|
|
TGLayoutHints * layoutHintsR = new TGLayoutHints(kLHintsRight, 5,5,3,2); /// left, right, top, bottom
|
|
TGLayoutHints * layoutHints = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5,5,0,0); /// left, right, top, bottom
|
|
|
|
TGVerticalFrame * vframe = new TGVerticalFrame(fMain);
|
|
fMain->AddFrame(vframe, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
|
|
|
|
TGHorizontalFrame *hframe0 = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframe0, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
|
|
|
|
///==========Board choose
|
|
TGLabel * lb0 = new TGLabel(hframe0, "Module ID :"); hframe0->AddFrame(lb0, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
|
|
boardIDEntry = new TGNumberEntry(hframe0, boardID, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hframe0->AddFrame(boardIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
|
|
boardIDEntry->SetWidth(50);
|
|
boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nDigi);
|
|
boardIDEntry->Connect("Modified()", "ChannelSettingPHA", this, "ChangeBoard()");
|
|
if( nDigi <= 1 ) boardIDEntry->SetState(false);
|
|
this->presentBoardID = boardID;
|
|
|
|
NChannel = 16;
|
|
if( digi != NULL ) NChannel = digi[boardID]->GetNChannel();
|
|
|
|
TGLabel * lba = new TGLabel(hframe0, Form("Serial : %03d", digi == NULL ? -1 : digi[boardID]->GetSerialNumber())); hframe0->AddFrame(lba, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
|
|
|
|
TGLabel * lb1 = new TGLabel(hframe0, "Channel :"); hframe0->AddFrame(lb1, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
|
|
chIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); hframe0->AddFrame(chIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
|
|
chIDEntry->SetWidth(50);
|
|
chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, -1, NChannel-1);
|
|
chIDEntry->SetNumber(0, false);
|
|
chIDEntry->Connect("Modified()", "ChannelSettingPHA", this, "ChangeCh()");
|
|
|
|
|
|
TGTextButton* bSetAllChannels = new TGTextButton(hframe0, "Set All Channels", 1); hframe0->AddFrame(bSetAllChannels, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
|
|
bSetAllChannels->SetState(kButtonUp);
|
|
bSetAllChannels->Connect("Clicked()", "ChannelSettingPHA", this, "SetAllChannels()");
|
|
|
|
///const uint32_t ChannelADCTemperature = 0x10A8; /// R
|
|
TGLabel * lbTemp = new TGLabel(hframe0, "Temperature [C] :"); hframe0->AddFrame(lbTemp, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
|
|
eTemp = new TGTextEntry(hframe0, new TGTextBuffer(1)); hframe0->AddFrame(eTemp, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5,5,3,4));
|
|
eTemp->SetEnabled(false);
|
|
eTemp->Resize(50,20);
|
|
|
|
int ch = chIDEntry->GetNumber();
|
|
int width = 80;
|
|
|
|
TGHorizontalFrame *hframe1 = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframe1, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
|
|
|
|
{///================== Input Setting
|
|
TGGroupFrame * gfInput = new TGGroupFrame(hframe1, "Input / Misc.", kHorizontalFrame); hframe1->AddFrame(gfInput, new TGLayoutHints(kLHintsExpandY));
|
|
TGHorizontalFrame * hfInput = new TGHorizontalFrame(gfInput); gfInput->AddFrame(hfInput);
|
|
|
|
TGVerticalFrame * vfInput1 = new TGVerticalFrame(hfInput); hfInput->AddFrame(vfInput1);
|
|
TGVerticalFrame * vfInput2 = new TGVerticalFrame(hfInput); hfInput->AddFrame(vfInput2);
|
|
|
|
///----------- on/off
|
|
TGLabel * lbOnOff = new TGLabel(vfInput1, "On/Off"); vfInput1->AddFrame(lbOnOff, layoutHintsR);
|
|
cbOnOff = new TGComboBox(vfInput2); vfInput2->AddFrame(cbOnOff, layoutHints);
|
|
cbOnOff->AddEntry("ON", 1);
|
|
cbOnOff->AddEntry("off", 0);
|
|
cbOnOff->Resize(width, 20);
|
|
cbOnOff->Connect("Selected(Int_t, Int_t)", "ChannelSettingPHA", this, "SetChannelMask()");
|
|
|
|
///----------- Polarity
|
|
TGLabel * lbPol = new TGLabel(vfInput1, "Polarity");vfInput1->AddFrame(lbPol, layoutHintsR);
|
|
cbPolarity = new TGComboBox(vfInput2); vfInput2->AddFrame(cbPolarity, layoutHints);
|
|
cbPolarity->AddEntry("Positive +", 1);
|
|
cbPolarity->AddEntry("Negative -", 0);
|
|
cbPolarity->Resize(width, 20);
|
|
cbPolarity->Connect("Selected(Int_t, Int_t)", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
///---------- Input Dynamic Range
|
|
TGLabel * lbInputDynamicRange = new TGLabel(vfInput1, "Input Range");vfInput1->AddFrame(lbInputDynamicRange, layoutHintsR);
|
|
cbInputDynamicRange = new TGComboBox(vfInput2); vfInput2->AddFrame(cbInputDynamicRange, layoutHints);
|
|
cbInputDynamicRange->AddEntry("2.0 Vpp", 0);
|
|
cbInputDynamicRange->AddEntry("0.5 Vpp", 1);
|
|
cbInputDynamicRange->Resize(width, 20);
|
|
cbInputDynamicRange->Connect("Selected(Int_t, Int_t)", "ChannelSettingPHA", this, "SetInputDynamicRange()");
|
|
|
|
///---------- Record Length
|
|
TGLabel * lbRecordLength = new TGLabel(vfInput1, "Record Length [ns]"); vfInput1->AddFrame(lbRecordLength, layoutHintsR);
|
|
numRecordLength = new TGNumberEntry(vfInput2, 20000, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numRecordLength, layoutHints);
|
|
numRecordLength->Resize(width, 20);
|
|
numRecordLength->Connect("Modified()", "ChannelSettingPHA", this, "SetRecordLength()");
|
|
|
|
///const uint32_t PreTrigger = 0x1038; /// R/W
|
|
TGLabel * lbPreTrigger = new TGLabel(vfInput1, "Pre trigger [ns]"); vfInput1->AddFrame(lbPreTrigger, layoutHintsR);
|
|
numPreTrigger = new TGNumberEntry(vfInput2, 2000, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numPreTrigger, layoutHints);
|
|
numPreTrigger->Resize(width, 20);
|
|
numPreTrigger->Connect("Modified()", "ChannelSettingPHA", this, "SetPreTrigger()");
|
|
|
|
///const uint32_t NumberEventsPerAggregate_G = 0x1034; /// R/W,
|
|
TGLabel * lbEventAgg = new TGLabel(vfInput1, "Events / Aggregate"); vfInput1->AddFrame(lbEventAgg, layoutHintsR);
|
|
numEventAgg = new TGNumberEntry(vfInput2, 512, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numEventAgg, layoutHints);
|
|
numEventAgg->Resize(width, 20);
|
|
numEventAgg->Connect("Modified()", "ChannelSettingPHA", this, "SetEventAggregate()");
|
|
|
|
///const uint32_t ChannelDCOffset = 0x1098; /// R/W
|
|
TGLabel * lbDCOffset = new TGLabel(vfInput1, "DC offset [%]"); vfInput1->AddFrame(lbDCOffset, layoutHintsR);
|
|
numDCOffset = new TGNumberEntry(vfInput2, 20, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numDCOffset, layoutHints);
|
|
numDCOffset->Resize(width, 20);
|
|
numDCOffset->Connect("Modified()", "ChannelSettingPHA", this, "SetDCOffset()");
|
|
|
|
///const uint32_t ShapedTriggerWidth = 0x1084; /// R/W not sure
|
|
///const uint32_t VetoWidth = 0x10D4; /// R/W
|
|
///const uint32_t FineGain = 0x10C4; /// R/W OK
|
|
|
|
}
|
|
|
|
{///================== Trigger Settings
|
|
TGGroupFrame * gfTrigger = new TGGroupFrame(hframe1, "Trigger", kHorizontalFrame); hframe1->AddFrame(gfTrigger, new TGLayoutHints(kLHintsExpandY));
|
|
TGHorizontalFrame * hfTrigger = new TGHorizontalFrame(gfTrigger); gfTrigger->AddFrame(hfTrigger);
|
|
|
|
TGVerticalFrame * vfTrigger1 = new TGVerticalFrame(hfTrigger); hfTrigger->AddFrame(vfTrigger1);
|
|
TGVerticalFrame * vfTrigger2 = new TGVerticalFrame(hfTrigger); hfTrigger->AddFrame(vfTrigger2);
|
|
|
|
///const uint32_t TriggerThreshold = 0x106C; /// R/W
|
|
TGLabel * lbTriggerThreshold = new TGLabel(vfTrigger1, "Trigger Threshold [LSB]"); vfTrigger1->AddFrame(lbTriggerThreshold, layoutHintsR);
|
|
numTriggerThreshold = new TGNumberEntry(vfTrigger2, 100, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrigger2->AddFrame(numTriggerThreshold, layoutHints);
|
|
numTriggerThreshold->Resize(width, 20);
|
|
numTriggerThreshold->Connect("Modified()", "ChannelSettingPHA", this, "SetTriggerThreshold()");
|
|
|
|
///const uint32_t TriggerHoldOffWidth = 0x1074; /// R/W
|
|
TGLabel * lbTriggerHoldOff = new TGLabel(vfTrigger1, "Trigger Holdoff [ns]"); vfTrigger1->AddFrame(lbTriggerHoldOff, layoutHintsR);
|
|
numTriggerHoldOff = new TGNumberEntry(vfTrigger2, 20000, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrigger2->AddFrame(numTriggerHoldOff, layoutHints);
|
|
numTriggerHoldOff->Resize(width, 20);
|
|
numTriggerHoldOff->Connect("Modified()", "ChannelSettingPHA", this, "SetTriggerHoldOff()");
|
|
|
|
///const uint32_t RCCR2SmoothingFactor = 0x1054; /// R/W Trigger Filter smoothing, triggerSmoothingFactor
|
|
TGLabel * lbTriggerSmoothing = new TGLabel(vfTrigger1, "Trigger Smoothing"); vfTrigger1->AddFrame(lbTriggerSmoothing, layoutHintsR);
|
|
cbTriggerSmoothing = new TGComboBox(vfTrigger2); vfTrigger2->AddFrame(cbTriggerSmoothing, layoutHints);
|
|
cbTriggerSmoothing->AddEntry("disable", 0);
|
|
cbTriggerSmoothing->AddEntry("2 samples", 1);
|
|
cbTriggerSmoothing->AddEntry("4 samples", 2);
|
|
cbTriggerSmoothing->AddEntry("8 samples", 4);
|
|
cbTriggerSmoothing->AddEntry("16 samples", 8);
|
|
cbTriggerSmoothing->AddEntry("32 samples", 16);
|
|
cbTriggerSmoothing->AddEntry("64 samples", 32);
|
|
cbTriggerSmoothing->AddEntry("128 samples", 0x3F);
|
|
cbTriggerSmoothing->Resize(width, 20);
|
|
cbTriggerSmoothing->Connect("Changed()", "ChannelSettingPHA", this, "SetTriggerSmoothing()");
|
|
|
|
///const uint32_t InputRiseTime = 0x1058; /// R/W OK
|
|
TGLabel * lbInputRiseTime = new TGLabel(vfTrigger1, "Input rise time [ns]"); vfTrigger1->AddFrame(lbInputRiseTime, layoutHintsR);
|
|
numInputRiseTime = new TGNumberEntry(vfTrigger2, 96, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrigger2->AddFrame(numInputRiseTime, layoutHints);
|
|
numInputRiseTime->Resize(width, 20);
|
|
numInputRiseTime->Connect("Modified()", "ChannelSettingPHA", this, "SetInputRiseTime()");
|
|
|
|
///const uint32_t RiseTimeValidationWindow = 0x1070; /// R/W OK
|
|
TGLabel * lbRiseTimeValidWin = new TGLabel(vfTrigger1, "Rise Time Val. Win. [ns]"); vfTrigger1->AddFrame(lbRiseTimeValidWin, layoutHintsR);
|
|
numRiseTimeValidWin = new TGNumberEntry(vfTrigger2, 20, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrigger2->AddFrame(numRiseTimeValidWin, layoutHints);
|
|
numRiseTimeValidWin->Resize(width, 20);
|
|
numRiseTimeValidWin->Connect("Modified()", "ChannelSettingPHA", this, "SetRiseTimeValidWin()");
|
|
|
|
/// DPP1 bit[19:18]
|
|
TGLabel * lbTriggerMode = new TGLabel(vfTrigger1, "Trigger Mode"); vfTrigger1->AddFrame(lbTriggerMode, layoutHintsR);
|
|
cbTriggerMode = new TGComboBox(vfTrigger2); vfTrigger2->AddFrame(cbTriggerMode, layoutHints);
|
|
cbTriggerMode->AddEntry("Normal", 0);
|
|
cbTriggerMode->AddEntry("Coin.", 1);
|
|
cbTriggerMode->AddEntry("Anti-Coin.", 3);
|
|
cbTriggerMode->Resize(width, 20);
|
|
cbTriggerMode->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
}
|
|
|
|
{///================== Trapezoid Settings
|
|
TGGroupFrame * gfTrap = new TGGroupFrame(hframe1, "Trapazoid", kHorizontalFrame); hframe1->AddFrame(gfTrap, new TGLayoutHints(kLHintsExpandY));
|
|
TGHorizontalFrame * hfTrap = new TGHorizontalFrame(gfTrap); gfTrap->AddFrame(hfTrap);
|
|
|
|
TGVerticalFrame * vfTrap1 = new TGVerticalFrame(hfTrap); hfTrap->AddFrame(vfTrap1);
|
|
TGVerticalFrame * vfTrap2 = new TGVerticalFrame(hfTrap); hfTrap->AddFrame(vfTrap2);
|
|
|
|
///const uint32_t TrapezoidRiseTime = 0x105C; /// R/W OK
|
|
TGLabel * lbTrapRiseTime = new TGLabel(vfTrap1, "Rise time [ns]"); vfTrap1->AddFrame(lbTrapRiseTime, layoutHintsR);
|
|
numTrapRiseTime = new TGNumberEntry(vfTrap2, 96, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrap2->AddFrame(numTrapRiseTime, layoutHints);
|
|
numTrapRiseTime->Resize(width, 20);
|
|
numTrapRiseTime->Connect("Modified()", "ChannelSettingPHA", this, "SetTrapRiseTime()");
|
|
|
|
///const uint32_t TrapezoidFlatTop = 0x1060; /// R/W OK
|
|
TGLabel * lbTrapFlatTop = new TGLabel(vfTrap1, "Flat Top [ns]"); vfTrap1->AddFrame(lbTrapFlatTop, layoutHintsR);
|
|
numTrapFlatTop = new TGNumberEntry(vfTrap2, 96, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrap2->AddFrame(numTrapFlatTop, layoutHints);
|
|
numTrapFlatTop->Resize(width, 20);
|
|
numTrapFlatTop->Connect("Modified()", "ChannelSettingPHA", this, "SetTrapFlatTop()");
|
|
|
|
///const uint32_t DecayTime = 0x1068; /// R/W OK
|
|
TGLabel * lbDecay = new TGLabel(vfTrap1, "Decay [ns]"); vfTrap1->AddFrame(lbDecay, layoutHintsR);
|
|
numDecay = new TGNumberEntry(vfTrap2, 96, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrap2->AddFrame(numDecay, layoutHints);
|
|
numDecay->Resize(width, 20);
|
|
numDecay->Connect("Modified()", "ChannelSettingPHA", this, "SetDecay()");
|
|
|
|
///const uint32_t PeakingTime = 0x1064; /// R/W OK
|
|
TGLabel * lbPeaking = new TGLabel(vfTrap1, "Peaking [ns]"); vfTrap1->AddFrame(lbPeaking, layoutHintsR);
|
|
numPeaking = new TGNumberEntry(vfTrap2, 96, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrap2->AddFrame(numPeaking, layoutHints);
|
|
numPeaking->Resize(width, 20);
|
|
numPeaking->Connect("Modified()", "ChannelSettingPHA", this, "SetPeaking()");
|
|
|
|
///const uint32_t PeakHoldOff = 0x1078; /// R/W OK
|
|
TGLabel * lbPeakHoldOff = new TGLabel(vfTrap1, "Peaking Holdoff [ns]"); vfTrap1->AddFrame(lbPeakHoldOff, layoutHintsR);
|
|
numPeakHoldOff = new TGNumberEntry(vfTrap2, 96, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfTrap2->AddFrame(numPeakHoldOff, layoutHints);
|
|
numPeakHoldOff->Resize(width, 20);
|
|
numPeakHoldOff->Connect("Modified()", "ChannelSettingPHA", this, "SetPeakHoldOff()");
|
|
|
|
/// DPP1 bit[13:12]
|
|
TGLabel * lbPeakMean = new TGLabel(vfTrap1, "Peak Mean"); vfTrap1->AddFrame(lbPeakMean, layoutHintsR);
|
|
cbPeakMean = new TGComboBox(vfTrap2); vfTrap2->AddFrame(cbPeakMean, layoutHints);
|
|
cbPeakMean->AddEntry("1 sample", 0);
|
|
cbPeakMean->AddEntry("4 samples", 1);
|
|
cbPeakMean->AddEntry("16 samples", 2);
|
|
cbPeakMean->AddEntry("64 samples", 3);
|
|
cbPeakMean->Resize(width, 20);
|
|
cbPeakMean->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
/// DPP1 bit[22:20]
|
|
TGLabel * lbBaseLineAvg = new TGLabel(vfTrap1, "Baseline avg."); vfTrap1->AddFrame(lbBaseLineAvg, layoutHintsR);
|
|
cbBaseLineAvg = new TGComboBox(vfTrap2); vfTrap2->AddFrame(cbBaseLineAvg, layoutHints);
|
|
cbBaseLineAvg->AddEntry("no baseline", 0);
|
|
cbBaseLineAvg->AddEntry("16 sp.", 1);
|
|
cbBaseLineAvg->AddEntry("64 sp.", 2);
|
|
cbBaseLineAvg->AddEntry("256 sp.", 3);
|
|
cbBaseLineAvg->AddEntry("1024 sp.", 4);
|
|
cbBaseLineAvg->AddEntry("4096 sp.", 5);
|
|
cbBaseLineAvg->AddEntry("16384 sp.", 6);
|
|
cbBaseLineAvg->Resize(width, 20);
|
|
cbBaseLineAvg->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
}
|
|
|
|
TGHorizontalFrame *hframe2 = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframe2, new TGLayoutHints(kLHintsExpandX, 2,2,2,2));
|
|
|
|
{///================== const uint32_t DPPAlgorithmControl = 0x1080; /// R/W
|
|
TGGroupFrame * gfDPPCtrl = new TGGroupFrame(hframe2, "DPP Algorithm Control 1 & 2", kHorizontalFrame); hframe2->AddFrame(gfDPPCtrl, new TGLayoutHints(kLHintsExpandX));
|
|
|
|
TGVerticalFrame * vfDPPCtrl = new TGVerticalFrame(gfDPPCtrl); gfDPPCtrl->AddFrame(vfDPPCtrl, new TGLayoutHints(kLHintsExpandX));
|
|
|
|
TGHorizontalFrame * hfDPPCtrl1 = new TGHorizontalFrame(vfDPPCtrl); vfDPPCtrl->AddFrame(hfDPPCtrl1, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 0));
|
|
|
|
TGVerticalFrame * vfDPPCtrl11 = new TGVerticalFrame(hfDPPCtrl1); hfDPPCtrl1->AddFrame(vfDPPCtrl11, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 0));
|
|
TGVerticalFrame * vfDPPCtrl12 = new TGVerticalFrame(hfDPPCtrl1); hfDPPCtrl1->AddFrame(vfDPPCtrl12);
|
|
|
|
TGLayoutHints * haha = new TGLayoutHints(kLHintsRight, 5, 5, 3, 2);
|
|
|
|
TGLabel * lbTrapScale = new TGLabel(vfDPPCtrl11, "Trap. Scaling [bit] :"); vfDPPCtrl11->AddFrame(lbTrapScale, haha);
|
|
numTrapScale = new TGNumberEntry(vfDPPCtrl12, 14, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative ); vfDPPCtrl12->AddFrame(numTrapScale);
|
|
numTrapScale->Resize(width, 20);
|
|
|
|
TGLabel * lbDecimation = new TGLabel(vfDPPCtrl11, "Decimation :"); vfDPPCtrl11->AddFrame(lbDecimation, haha);
|
|
cbDecimation = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbDecimation);
|
|
cbDecimation->AddEntry("Disable", 0);
|
|
cbDecimation->AddEntry("2 samples", 1);
|
|
cbDecimation->AddEntry("4 samples", 2);
|
|
cbDecimation->AddEntry("8 samples", 3);
|
|
cbDecimation->Resize(width, 20);
|
|
cbDecimation->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
TGLabel * lbDecimationGain = new TGLabel(vfDPPCtrl11, "Decimation Gain :"); vfDPPCtrl11->AddFrame(lbDecimationGain, haha);
|
|
cbDecimationGain = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbDecimationGain);
|
|
cbDecimationGain->AddEntry("x 1", 0);
|
|
cbDecimationGain->AddEntry("x 2", 1);
|
|
cbDecimationGain->AddEntry("x 4", 2);
|
|
cbDecimationGain->AddEntry("x 8", 3);
|
|
cbDecimationGain->Resize(width, 20);
|
|
cbDecimationGain->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
TGLabel * lbRollOver = new TGLabel(vfDPPCtrl11, "Roll-Over Flag :"); vfDPPCtrl11->AddFrame(lbRollOver, haha);
|
|
cbRollOver = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbRollOver);
|
|
cbRollOver->AddEntry("Disabled", 0);
|
|
cbRollOver->AddEntry("Enabled", 1);
|
|
cbRollOver->Resize(width, 20);
|
|
cbRollOver->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
TGLabel * lbPileUp = new TGLabel(vfDPPCtrl11, "Pile-Up Flag :"); vfDPPCtrl11->AddFrame(lbPileUp, haha);
|
|
cbPileUp = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbPileUp);
|
|
cbPileUp->AddEntry("Disabled", 0);
|
|
cbPileUp->AddEntry("Enabled", 1);
|
|
cbPileUp->Resize(width, 20);
|
|
cbPileUp->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
TGVerticalFrame * vfDPPCtrl21 = new TGVerticalFrame(hfDPPCtrl1); hfDPPCtrl1->AddFrame(vfDPPCtrl21, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 0));
|
|
TGVerticalFrame * vfDPPCtrl22 = new TGVerticalFrame(hfDPPCtrl1); hfDPPCtrl1->AddFrame(vfDPPCtrl22, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 0));
|
|
|
|
TGLabel * lbLocalShapedTrigger = new TGLabel(vfDPPCtrl21, "Local Shaped Trigger :"); vfDPPCtrl21->AddFrame(lbLocalShapedTrigger, haha);
|
|
cbLocalShapedTrigger = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbLocalShapedTrigger);
|
|
cbLocalShapedTrigger->AddEntry("Disabled", -3);
|
|
cbLocalShapedTrigger->AddEntry("AND", 0);
|
|
cbLocalShapedTrigger->AddEntry("Even Channel", 1);
|
|
cbLocalShapedTrigger->AddEntry("Odd Channel", 2);
|
|
cbLocalShapedTrigger->AddEntry("OR", 3);
|
|
cbLocalShapedTrigger->Resize(width, 20);
|
|
cbLocalShapedTrigger->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
TGLabel * lbLocalTriggerValid = new TGLabel(vfDPPCtrl21, "Local Trigger Valid. :"); vfDPPCtrl21->AddFrame(lbLocalTriggerValid, haha);
|
|
cbLocalTriggerValid = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbLocalTriggerValid);
|
|
cbLocalTriggerValid->AddEntry("Disabled", -3);
|
|
cbLocalTriggerValid->AddEntry("crossed", 0);
|
|
cbLocalTriggerValid->AddEntry("val0 = val1 from mother-board mask", 1);
|
|
cbLocalTriggerValid->AddEntry("AND", 3);
|
|
cbLocalTriggerValid->AddEntry("OR", 4);
|
|
cbLocalTriggerValid->Resize(100, 20);
|
|
cbLocalTriggerValid->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
TGLabel * lbVetoSource = new TGLabel(vfDPPCtrl21, "Veto Source :"); vfDPPCtrl21->AddFrame(lbVetoSource, haha);
|
|
cbVetoSource = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbVetoSource);
|
|
cbVetoSource->AddEntry("Disabled", 0);
|
|
cbVetoSource->AddEntry("common to all channels", 1);
|
|
cbVetoSource->AddEntry("individually set for paired channel", 2);
|
|
cbVetoSource->AddEntry("negative saturation", 3);
|
|
cbVetoSource->Resize(width, 20);
|
|
cbVetoSource->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
TGLabel * lbTriggerCounterRate = new TGLabel(vfDPPCtrl21, "Trigger Counter Rate :"); vfDPPCtrl21->AddFrame(lbTriggerCounterRate, haha);
|
|
cbTriggerCounterRate = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbTriggerCounterRate);
|
|
cbTriggerCounterRate->AddEntry("1024", 0);
|
|
cbTriggerCounterRate->AddEntry(" 128", 1);
|
|
cbTriggerCounterRate->AddEntry("8192", 2);
|
|
cbTriggerCounterRate->Resize(width, 20);
|
|
cbTriggerCounterRate->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
TGLabel * lbBaselineCal = new TGLabel(vfDPPCtrl21, "Active Baseline Cal. :"); vfDPPCtrl21->AddFrame(lbBaselineCal, haha);
|
|
cbBaselineCal = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbBaselineCal);
|
|
cbBaselineCal->AddEntry("Enabled", 0);
|
|
cbBaselineCal->AddEntry("Disabled", 1);
|
|
cbBaselineCal->Resize(width, 20);
|
|
cbBaselineCal->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
TGLabel * lbTagCorrelatedEvent = new TGLabel(vfDPPCtrl21, "Tag correlated events :"); vfDPPCtrl21->AddFrame(lbTagCorrelatedEvent, haha);
|
|
cbTagCorrelatedEvent = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbTagCorrelatedEvent);
|
|
cbTagCorrelatedEvent->AddEntry("Disabled", 0);
|
|
cbTagCorrelatedEvent->AddEntry("Enabled", 1);
|
|
cbTagCorrelatedEvent->Resize(width, 20);
|
|
cbTagCorrelatedEvent->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
TGLabel * lbBaselineOptimize = new TGLabel(vfDPPCtrl11, "Baseline Optimaization :"); vfDPPCtrl11->AddFrame(lbBaselineOptimize, haha);
|
|
cbBaselineOptimize = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbBaselineOptimize);
|
|
cbBaselineOptimize->AddEntry("Disabled", 0);
|
|
cbBaselineOptimize->AddEntry("Enabled", 1);
|
|
cbBaselineOptimize->Resize(width, 20);
|
|
cbBaselineOptimize->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
|
|
TGHorizontalFrame * hfDPPCtrl2 = new TGHorizontalFrame(vfDPPCtrl); vfDPPCtrl->AddFrame(hfDPPCtrl2, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 0));
|
|
|
|
TGVerticalFrame * vfDPPCtrl_a = new TGVerticalFrame(hfDPPCtrl2); hfDPPCtrl2->AddFrame(vfDPPCtrl_a);
|
|
TGVerticalFrame * vfDPPCtrl_b = new TGVerticalFrame(hfDPPCtrl2); hfDPPCtrl2->AddFrame(vfDPPCtrl_b, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 0));
|
|
|
|
|
|
TGLabel * lbDisableSelfTrigger = new TGLabel(vfDPPCtrl_a, "Self Trigger :"); vfDPPCtrl_a->AddFrame(lbDisableSelfTrigger, haha);
|
|
cbDisableSelfTrigger = new TGComboBox(vfDPPCtrl_b); vfDPPCtrl_b->AddFrame(cbDisableSelfTrigger);
|
|
cbDisableSelfTrigger->AddEntry("used to acquire and propagate to trigger logic", 0);
|
|
cbDisableSelfTrigger->AddEntry("only propagate to trigger logic", 1);
|
|
cbDisableSelfTrigger->Resize(300, 20);
|
|
cbLocalShapedTrigger->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
|
|
|
TGLabel * lbExtra2WordOption = new TGLabel(vfDPPCtrl_a, "Extras 2 Word Option :"); vfDPPCtrl_a->AddFrame(lbExtra2WordOption, haha);
|
|
cbExtra2WordOption = new TGComboBox(vfDPPCtrl_b); vfDPPCtrl_b->AddFrame(cbExtra2WordOption);
|
|
cbExtra2WordOption->AddEntry("[31:16] Extended Time Stamp [15:0] Baseline * 4", 0);
|
|
cbExtra2WordOption->AddEntry("[31:16] Extended Time Stamp [15:0] Fine Time Stamp", 2);
|
|
cbExtra2WordOption->AddEntry("[31:16] Lost Trigger Counter [15:0] Total Trigger Counter", 4);
|
|
cbExtra2WordOption->AddEntry("[31:16] Event Before Zero Crossing [15:0] Event After Zero Crossing", 5);
|
|
cbExtra2WordOption->Resize(400, 20);
|
|
cbExtra2WordOption->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
|
|
|
|
}
|
|
|
|
{///================== Commands Buttons
|
|
TGGroupFrame * gfCmd = new TGGroupFrame(hframe2, "Commands", kHorizontalFrame); hframe2->AddFrame(gfCmd);
|
|
TGVerticalFrame * vfCmd = new TGVerticalFrame(gfCmd); gfCmd->AddFrame(vfCmd, new TGLayoutHints(kLHintsExpandX));
|
|
|
|
TGTextButton * bReadSetting = new TGTextButton(vfCmd, "Read Settings"); vfCmd->AddFrame(bReadSetting, new TGLayoutHints(kLHintsExpandX, 5,5,3,4));
|
|
bReadSetting->Connect("Clicked()", "ChannelSettingPHA", this, "ChangeCh()");
|
|
|
|
TGTextButton * bReadTrace = new TGTextButton(vfCmd, "Read Trace"); vfCmd->AddFrame(bReadTrace, new TGLayoutHints(kLHintsExpandX, 5,5,3,4));
|
|
bReadTrace->Connect("Clicked()", "ChannelSettingPHA", this, "ReadTrace()");
|
|
|
|
}
|
|
|
|
{///=================== Comment
|
|
TGHorizontalFrame * hfOther = new TGHorizontalFrame(vframe); vframe->AddFrame(hfOther, new TGLayoutHints(kLHintsNormal, 5, 5, 10, 0));
|
|
|
|
|
|
///const uint32_t ShapedTriggerWidth = 0x1084; /// R/W not sure
|
|
///const uint32_t VetoWidth = 0x10D4; /// R/W
|
|
///const uint32_t FineGain = 0x10C4; /// R/W OK
|
|
|
|
TGLabel * lbOther = new TGLabel(hfOther, "Shaped Trigger Width (0x1n84), Veto Width (0x1nD4), and Fine Gain (0x1nC4) are not implemented."); hfOther->AddFrame(lbOther);
|
|
|
|
}
|
|
|
|
fMain->MapSubwindows();
|
|
fMain->Resize(fMain->GetDefaultSize());
|
|
fMain->MapWindow();
|
|
|
|
ch2ns = 4;
|
|
|
|
isOpened = true;
|
|
|
|
ChangeBoard();
|
|
|
|
}
|
|
ChannelSettingPHA::~ChannelSettingPHA(){
|
|
|
|
printf("close ChannelSettingPHA window\n");
|
|
|
|
isOpened = false;
|
|
|
|
delete boardIDEntry;
|
|
|
|
delete cbOnOff;
|
|
delete cbInputDynamicRange;
|
|
delete cbPolarity;
|
|
|
|
/// fMain must be delete last;
|
|
fMain->Cleanup();
|
|
delete fMain;
|
|
|
|
}
|
|
|
|
void ChannelSettingPHA::LogMsg(TString msg){
|
|
Emit("LogMsg(char*)", msg.Data());
|
|
}
|
|
|
|
void ChannelSettingPHA::ChangeBoard(){
|
|
if ( digi == NULL ) return;
|
|
|
|
int boardID = boardIDEntry->GetNumber();
|
|
|
|
if( digi[boardID]->GetDPPType() != V1730_DPP_PHA_CODE){
|
|
|
|
if( boardID > presentBoardID ) {
|
|
|
|
for( int i = boardID +1 ; i < nDigi; i++){
|
|
if( digi[i]->GetDPPType() == V1730_DPP_PHA_CODE ){
|
|
boardID = i;
|
|
boardIDEntry->SetNumber(i, false);
|
|
break;
|
|
}
|
|
if( i = nDigi -1 ) return;
|
|
}
|
|
|
|
}else{
|
|
|
|
for( int i = boardID - 1 ; i >= 0; i--){
|
|
if( digi[i]->GetDPPType() == V1730_DPP_PHA_CODE ){
|
|
boardID = i;
|
|
boardIDEntry->SetNumber(i, false);
|
|
break;
|
|
}
|
|
if( i = nDigi -1 ) return;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
ch2ns = (unsigned short) digi[boardID]->GetCh2ns();
|
|
ChangeCh();
|
|
|
|
}
|
|
|
|
void ChannelSettingPHA::ChangeCh(){
|
|
|
|
if ( digi == NULL ) return;
|
|
|
|
int boardID = boardIDEntry->GetNumber();
|
|
int ch = chIDEntry->GetNumber();
|
|
|
|
if( ch < 0 ) {
|
|
printf("All channels mode.\n");
|
|
return;
|
|
}
|
|
|
|
LogMsg(Form("Read Channel %d Setting", (int)chIDEntry->GetNumber()));
|
|
|
|
cbOnOff->Select( (digi[boardID]->GetChannelMask() >> ch) & 0x1, false); /// don't emit signal
|
|
cbInputDynamicRange->Select( digi[boardID]->ReadRegister(Register::DPP::InputDynamicRange, ch), false);
|
|
numRecordLength->SetNumber( digi[boardID]->ReadRegister(Register::DPP::RecordLength_G, ch) * 8 * ch2ns, false);
|
|
numPreTrigger->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PreTrigger, ch) * 4 * ch2ns, false);
|
|
numEventAgg->SetNumber( digi[boardID]->ReadRegister(Register::DPP::NumberEventsPerAggregate_G, ch), false);
|
|
|
|
uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::ChannelDCOffset, ch);
|
|
numDCOffset->SetNumber( 1.0 - temp * 1.0/0xFFFF , false);
|
|
|
|
eTemp->SetText(Form("%d C", digi[boardID]->ReadRegister(Register::DPP::ChannelADCTemperature_R, ch)), false);
|
|
|
|
numTriggerThreshold->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TriggerThreshold, ch), false);
|
|
numTriggerHoldOff ->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TriggerHoldOffWidth, ch) * 4 * ch2ns, false);
|
|
cbTriggerSmoothing ->Select( digi[boardID]->ReadRegister(Register::DPP::PHA::RCCR2SmoothingFactor, ch), false);
|
|
numInputRiseTime ->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::InputRiseTime, ch) * 4 * ch2ns, false);
|
|
numRiseTimeValidWin->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::RiseTimeValidationWindow, ch) * ch2ns, false);
|
|
|
|
numTrapRiseTime->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TrapezoidRiseTime, ch) * 4 * ch2ns, false);
|
|
numTrapFlatTop->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TrapezoidFlatTop, ch) * 4 * ch2ns, false);
|
|
numDecay->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::DecayTime, ch) * 4 * ch2ns, false);
|
|
numPeaking->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::PeakingTime, ch) * 4 * ch2ns, false);
|
|
numPeakHoldOff->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::PeakHoldOff, ch) * 4 * ch2ns, false);
|
|
|
|
temp = digi[boardID]->ReadRegister(Register::DPP::DPPAlgorithmControl, ch);
|
|
numTrapScale->SetNumber( temp & 0x3F, false );
|
|
cbDecimation->Select( ( (temp >> 8) & 0x3), false);
|
|
cbDecimationGain->Select( ( (temp >> 10) & 0x3), false);
|
|
cbPeakMean->Select( ( (temp >> 12) & 0x3), false);
|
|
cbPolarity->Select( ( (temp >> 16) & 0x1), false);
|
|
cbTriggerMode->Select( ( (temp >> 18) & 0x3), false);
|
|
cbBaseLineAvg->Select( ( (temp >> 20) & 0x7), false);
|
|
cbDisableSelfTrigger->Select( ( (temp >> 24) & 0x1), false);
|
|
cbRollOver->Select( ( (temp >> 26) & 0x1), false);
|
|
cbPileUp->Select( ( (temp >> 27) & 0x1), false);
|
|
|
|
temp = digi[boardID]->ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, ch);
|
|
if( (((temp >> 2)) & 0x1 ) == 1 ){
|
|
cbLocalShapedTrigger->Select( (temp & 0x3), false);
|
|
}else{
|
|
cbLocalShapedTrigger->Select( -3, false);
|
|
}
|
|
if( ((temp >> 6) & 0x1 ) == 1 ){
|
|
cbLocalTriggerValid->Select( ((temp >> 4) & 0x3), false);
|
|
}else{
|
|
cbLocalTriggerValid->Select(-3, false);
|
|
}
|
|
cbVetoSource->Select( ( (temp >> 14) & 0x3), false);
|
|
cbTriggerCounterRate->Select( ( (temp >> 16) & 0x3), false);
|
|
cbBaselineCal->Select( ( (temp >> 18) & 0x1), false);
|
|
cbTagCorrelatedEvent->Select( ( (temp >> 19) & 0x1), false);
|
|
cbBaselineOptimize->Select( ( (temp >> 29) & 0x1), false);
|
|
cbExtra2WordOption->Select( ( (temp >> 8) & 0x7), false);
|
|
|
|
|
|
}
|
|
|
|
void ChannelSettingPHA::SetAllChannels(){
|
|
printf("=== %s\n", __func__);
|
|
|
|
if ( digi == NULL ) return;
|
|
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
|
|
//TODO other register
|
|
|
|
uint32_t bit = 0;
|
|
bit += numTrapScale->GetNumber();
|
|
bit += ((cbDecimation->GetSelected() & 0x3) << 8) ;
|
|
bit += ((cbDecimationGain->GetSelected() & 0x3) << 10);
|
|
bit += ((cbPeakMean->GetSelected() & 0x3) << 12);
|
|
bit += ((cbPolarity->GetSelected() & 0x3) << 16);
|
|
bit += ((cbTriggerMode->GetSelected() & 0x3) << 18);
|
|
bit += ((cbBaseLineAvg->GetSelected() & 0x7) << 20);
|
|
bit += ((cbDisableSelfTrigger->GetSelected() & 0x1) << 24);
|
|
bit += ((cbRollOver->GetSelected() & 0x1) << 26);
|
|
bit += ((cbPileUp->GetSelected() & 0x1) << 27);
|
|
|
|
printf(" DPP1 bit: 0x%x\n", bit);
|
|
digi[boardID]->WriteRegister(Register::DPP::DPPAlgorithmControl, bit, -1);
|
|
|
|
bit = 0;
|
|
if( cbLocalShapedTrigger->GetSelected() >= 0 ){
|
|
bit += cbLocalShapedTrigger->GetSelected();
|
|
bit += ( 1 << 2);
|
|
}
|
|
if( cbLocalTriggerValid->GetSelected() >= 0 ){
|
|
bit += ((cbLocalTriggerValid->GetSelected() << 4) & 0x3);
|
|
bit += ( 1 << 6);
|
|
}
|
|
bit += ((cbExtra2WordOption->GetSelected() & 0x7) << 8 );
|
|
bit += ((cbVetoSource->GetSelected() & 0x3) << 14 );
|
|
bit += ((cbTriggerCounterRate->GetSelected() & 0x3) << 16 );
|
|
bit += ((cbBaselineCal->GetSelected() & 0x1) << 18 );
|
|
bit += ((cbTagCorrelatedEvent->GetSelected() & 0x1) << 19 );
|
|
bit += ((cbBaselineOptimize->GetSelected() & 0x1) << 29 );
|
|
|
|
printf(" DPP2 bit: 0x%x\n", bit);
|
|
digi[boardID]->WriteRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, -1);
|
|
|
|
}
|
|
|
|
void ChannelSettingPHA::SetChannelMask(){
|
|
printf("=== %s\n", __func__);
|
|
if ( digi == NULL ) return;
|
|
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
unsigned short val = cbOnOff->GetSelected();
|
|
|
|
uint32_t bitMask = (1 << ch);
|
|
uint32_t chMask = ((digi[boardID]->GetChannelMask() & ~bitMask) | ( val << ch) );
|
|
|
|
printf("mask : 0x%x \n", chMask);
|
|
digi[boardID]->SetChannelMask(chMask);
|
|
|
|
}
|
|
|
|
void ChannelSettingPHA::SetDPPAlgorithm1(){
|
|
printf("=== %s\n", __func__);
|
|
if ( digi == NULL ) return;
|
|
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
unsigned short ch2ns = digi[boardID]->GetCh2ns();
|
|
|
|
uint32_t bit = 0;
|
|
bit += numTrapScale->GetNumber();
|
|
bit += ((cbDecimation->GetSelected() & 0x3) << 8) ;
|
|
bit += ((cbDecimationGain->GetSelected() & 0x3) << 10);
|
|
bit += ((cbPeakMean->GetSelected() & 0x3) << 12);
|
|
bit += ((cbPolarity->GetSelected() & 0x3) << 16);
|
|
bit += ((cbTriggerMode->GetSelected() & 0x3) << 18);
|
|
bit += ((cbBaseLineAvg->GetSelected() & 0x7) << 20);
|
|
bit += ((cbDisableSelfTrigger->GetSelected() & 0x1) << 24);
|
|
bit += ((cbRollOver->GetSelected() & 0x1) << 26);
|
|
bit += ((cbPileUp->GetSelected() & 0x1) << 27);
|
|
|
|
printf(" DPP1 bit: 0x%x\n", bit);
|
|
digi[boardID]->WriteRegister(Register::DPP::DPPAlgorithmControl, bit, ch);
|
|
|
|
}
|
|
|
|
void ChannelSettingPHA::SetDPPAlgorithm2(){
|
|
printf("=== %s\n", __func__);
|
|
if ( digi == NULL ) return;
|
|
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
|
|
uint32_t bit = 0;
|
|
|
|
if( cbLocalShapedTrigger->GetSelected() >= 0 ){
|
|
bit += cbLocalShapedTrigger->GetSelected();
|
|
bit += ( 1 << 2);
|
|
}
|
|
if( cbLocalTriggerValid->GetSelected() >= 0 ){
|
|
bit += ((cbLocalTriggerValid->GetSelected() & 0x3) << 4);
|
|
bit += ( 1 << 6);
|
|
}
|
|
bit += ((cbExtra2WordOption->GetSelected() & 0x7) << 8 );
|
|
bit += ((cbVetoSource->GetSelected() & 0x3) << 14 );
|
|
bit += ((cbTriggerCounterRate->GetSelected() & 0x3) << 16 );
|
|
bit += ((cbBaselineCal->GetSelected() & 0x1) << 18 );
|
|
bit += ((cbTagCorrelatedEvent->GetSelected() & 0x1) << 19 );
|
|
bit += ((cbBaselineOptimize->GetSelected() & 0x1) << 29 );
|
|
|
|
printf(" DPP2 bit: 0x%x\n", bit);
|
|
digi[boardID]->WriteRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, ch);
|
|
|
|
}
|
|
|
|
void ChannelSettingPHA::SetInputDynamicRange(){
|
|
printf("=== %s\n", __func__);
|
|
if ( digi == NULL ) return;
|
|
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
digi[boardID]->WriteRegister(Register::DPP::InputDynamicRange, cbInputDynamicRange->GetSelected(), ch);
|
|
}
|
|
|
|
|
|
void ChannelSettingPHA::ChangeAStep(TGNumberEntry * numEntry, unsigned short stepSize, uint32_t address){
|
|
|
|
unsigned int temp = numEntry->GetNumber();
|
|
unsigned int res = temp % (stepSize * ch2ns);
|
|
temp = temp - res + ( ( res < (stepSize * ch2ns/2) ) ? (stepSize * ch2ns ) : 0 );
|
|
numEntry->SetNumber(temp, false);
|
|
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
|
|
if( digi != NULL ) digi[boardID]->WriteRegister(address, temp / stepSize / ch2ns , ch);
|
|
}
|
|
|
|
void ChannelSettingPHA::SetRecordLength() {printf("=== %s\n", __func__); ChangeAStep(numRecordLength, 8, Register::DPP::RecordLength_G); }
|
|
void ChannelSettingPHA::SetPreTrigger() {printf("=== %s\n", __func__); ChangeAStep(numPreTrigger, 4, Register::DPP::PreTrigger);}
|
|
void ChannelSettingPHA::SetEventAggregate() {printf("=== %s\n", __func__); ChangeAStep(numEventAgg, 1, Register::DPP::NumberEventsPerAggregate_G);}
|
|
void ChannelSettingPHA::SetTriggerThreshold(){printf("=== %s\n", __func__); ChangeAStep(numTriggerThreshold, 1, Register::DPP::PHA::TriggerThreshold); }
|
|
void ChannelSettingPHA::SetTriggerHoldOff() {printf("=== %s\n", __func__); ChangeAStep(numTriggerHoldOff, 4, Register::DPP::PHA::TriggerHoldOffWidth);}
|
|
void ChannelSettingPHA::SetInputRiseTime() {printf("=== %s\n", __func__); ChangeAStep(numInputRiseTime, 4, Register::DPP::PHA::InputRiseTime);}
|
|
void ChannelSettingPHA::SetRiseTimeValidWin(){printf("=== %s\n", __func__); ChangeAStep(numRiseTimeValidWin, 1, Register::DPP::PHA::RiseTimeValidationWindow);}
|
|
void ChannelSettingPHA::SetTrapRiseTime() {printf("=== %s\n", __func__); ChangeAStep(numTrapRiseTime, 4, Register::DPP::PHA::TrapezoidRiseTime);}
|
|
void ChannelSettingPHA::SetTrapFlatTop() {printf("=== %s\n", __func__); ChangeAStep(numTrapFlatTop, 4, Register::DPP::PHA::TrapezoidFlatTop);}
|
|
void ChannelSettingPHA::SetDecay() {printf("=== %s\n", __func__); ChangeAStep(numDecay, 4, Register::DPP::PHA::DecayTime);}
|
|
void ChannelSettingPHA::SetPeaking() {printf("=== %s\n", __func__); ChangeAStep(numPeaking, 4, Register::DPP::PHA::PeakingTime);}
|
|
void ChannelSettingPHA::SetPeakHoldOff() {printf("=== %s\n", __func__); ChangeAStep(numPeakHoldOff, 4, Register::DPP::PHA::PeakHoldOff);}
|
|
|
|
void ChannelSettingPHA::SetDCOffset(){
|
|
printf("=== %s\n", __func__);
|
|
if ( digi == NULL ) return;
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
double temp = numDCOffset->GetNumber();
|
|
uint32_t bit = uint32_t((1.0 - temp) * 0xFFFF);
|
|
printf("%.2f = 0x%x \n", temp, bit);
|
|
if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::ChannelDCOffset, bit , ch);
|
|
}
|
|
|
|
void ChannelSettingPHA::SetTriggerSmoothing(){
|
|
printf("=== %s\n", __func__);
|
|
if ( digi == NULL ) return;
|
|
short boardID = boardIDEntry->GetNumber();
|
|
short ch = chIDEntry->GetNumber();
|
|
if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor, (unsigned int)cbTriggerSmoothing->GetSelected() , ch);
|
|
}
|
|
|
|
void ChannelSettingPHA::ReadTrace(){
|
|
printf("=== %s\n", __func__);
|
|
///Send plot trace to MainWindows
|
|
SendPlotTraceCmd();
|
|
}
|
|
|
|
void ChannelSettingPHA::SendPlotTraceCmd(){
|
|
printf("=== %s\n", __func__);
|
|
Emit("SendPlotTraceCmd()");
|
|
}
|