going to retire DigitizerPHA and DigitizerPSD, since direct access register. tested for 1 digitizer with PHA, seems OK. going to plot tarce and other stuff

This commit is contained in:
carina@hades 2022-09-27 17:58:14 -04:00
parent 8c7709daeb
commit 7fee55a094
11 changed files with 286 additions and 103 deletions

View File

@ -52,6 +52,7 @@ class Data{
void SaveBuffer(const char * fileName);
void PrintBuffer(); //Incorrect
void DecodeBuffer(int verbose = 0);
void DecodeBuffer(char * buffer, int verbose = 0); // for outside data
@ -159,6 +160,16 @@ inline void Data::PrintStat(){
}
inline void Data::PrintBuffer(){
unsigned int length = sizeof(buffer);
for( int i = 0; i < length; i++){
printf("%3d | 0x%08x \n", i, buffer[i]);
}
}
inline void Data::DecodeBuffer(char * buffer, int verbose){
this->buffer = buffer;
DecodeBuffer(verbose);

View File

@ -262,9 +262,6 @@ int Digitizer::ProgramBoard(){
/// Set Extras 2 to enable, this override Accusition mode, focring list mode
ret |= CAEN_DGTZ_WriteRegister(handle, Register::BoardConfiguration , 0x00E8114 );
/// Set how many events to accumulate in the board memory before being available for readout
SetEventAggregation(0); /// when zero, digitizer auto set
/// Set the digitizer acquisition mode (CAEN_DGTZ_SW_CONTROLLED or CAEN_DGTZ_S_IN_CONTROLLED)
ret |= CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, AcqMode, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime);
@ -280,6 +277,11 @@ int Digitizer::ProgramBoard(){
ret |= CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
/// Set how many events to accumulate in the board memory before being available for readout
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 100);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxAggregatePerBlockTransfer, 50);
ErrorMsg(__func__);
return ret;
@ -569,6 +571,58 @@ void Digitizer::PrintACQStatue(){
}
//=====================================================
int Digitizer::ProgramPHABoard(){
ret = CAEN_DGTZ_Reset(handle);
printf("======== program board PHA\n");
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 625);
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x4E8115);
//TODO change to write register
ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
ret |= CAEN_DGTZ_SetIOLevel(handle, CAEN_DGTZ_IOLevel_NIM);
ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY);
ret = CAEN_DGTZ_SetChannelEnableMask(handle, 0xFFFF);
//ret = CAEN_DGTZ_SetNumEventsPerAggregate(handle, 0);
ret = CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
if( ret != 0 ) { printf("==== set board error.\n"); return 0;}
printf("======== program Channels PHA\n");
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::DecayTime + 0x7000 , 5000 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::TrapezoidFlatTop + 0x7000 , 0x62 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::TrapezoidRiseTime + 0x7000 , 6 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::PeakingTime + 0x7000 , 6 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::RCCR2SmoothingFactor + 0x7000 , 4 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::InputRiseTime + 0x7000 , 6 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::TriggerThreshold + 0x7000 , 1000 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::PeakHoldOff + 0x7000 , 0x3E );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::TriggerHoldOffWidth + 0x7000 , 0x3E );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::RiseTimeValidationWindow + 0x7000 , 0x0 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::ChannelDCOffset + 0x7000 , 0xEEEE );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PreTrigger + 0x7000 , 124 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::InputDynamicRange + 0x7000 , 0x0 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 100);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxAggregatePerBlockTransfer, 40);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f);
if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
printf("End of program board and channels\n");
return ret;
}
//========================================== setting file IO
void Digitizer::OpenSettingBinary(string fileName){
settingFile = NULL;
@ -724,3 +778,6 @@ void Digitizer::SaveSettingEditByte(unsigned int value, uint32_t filePos){
void Digitizer::SaveSettingEditByteByRegister(uint32_t registerAddress, int ch){
SaveSettingEditByte( ReadRegister(registerAddress, ch), registerAddress);
}

View File

@ -107,6 +107,8 @@ class Digitizer{
unsigned int CalByteForBuffer();
int ProgramPHABoard();
///================ Setting
void OpenSettingBinary(string fileName);
//TODO void LoadSettingBinary(string fileName);
@ -115,6 +117,7 @@ class Digitizer{
void SaveSettingEditByteByRegister(uint32_t registerAddress, int ch = -1);
unsigned long ReadSettingBinary(uint32_t filePos, int ch = -1); /// read from setting binary
virtual int ProgramBoard();
protected:
@ -150,7 +153,6 @@ class Digitizer{
bool settingFileExist;
///==========
virtual int ProgramBoard();
void ErrorMsg(string header = "");
};

View File

@ -247,14 +247,14 @@ void MainWindow::HandleMenu(Int_t id){
void MainWindow::OpenDigitizers(){
LogMsg("============= detect digitizers \n");
LogMsg("============= detect digitizers");
DPPType.clear();
portID.clear();
boardID.clear();
nDigi = 0;
Digitizer * dig = new Digitizer();
LogMsg("Finding Digitizer for 4 ports and 3 boards for each port...");
for( int port = 0; port < 4 ; port ++){
for( int board = 0; board < 3 ; board ++){
dig->OpenDigitizer(board, port);
@ -271,7 +271,7 @@ void MainWindow::OpenDigitizers(){
}
}
LogMsg(Form("========== found %d digitizer", nDigi));
LogMsg(Form("========== found %d digitizer(s)", nDigi));
for( int i = 0 ; i < nDigi ; i++){
LogMsg(Form("port: %d, board: %d, DPP Type : %d", portID[i], boardID[i], DPPType[i]));
}
@ -280,7 +280,7 @@ void MainWindow::OpenDigitizers(){
if( nDigi > 0 ) {
LogMsg(Form("============= Connect %d digitizers...", nDigi));
LogMsg(Form("============= Connect %d digitizer(s)...", nDigi));
digi = new Digitizer * [nDigi];
@ -335,6 +335,7 @@ void MainWindow::OpenChannelSetting(Int_t boardID){
if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){
channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, boardID);
channelSettingPHA->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)");
channelSettingPHA->Connect("SendPlotTraceCmd()", "MainWindow", this, "PlotTrace()");
}
if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ){
@ -361,6 +362,11 @@ void MainWindow::LogMsg(char * msg){
teLog->LineDown();
teLog->ShowBottom();
}
void MainWindow::PlotTrace(){
}
//############################################

View File

@ -94,6 +94,8 @@ public:
//void ChangeMod();
//void ChangeChannel();
void PlotTrace();
void OpenChannelSetting(Int_t);
void LogMsg(char * );
void GoodBye();

View File

@ -189,16 +189,19 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
txtEventReady = new TGTextEntry(vReadoutStatus, new TGTextBuffer(1)); vReadoutStatus->AddFrame(txtEventReady, new TGLayoutHints(kLHintsRight, 5,5,0,0));
txtEventReady->SetEnabled(false);
txtEventReady->SetText( "Event Ready" );
txtEventReady->Resize(150,20);
txtEventReady->SetTextColor(blue);
txtBusError = new TGTextEntry(vReadoutStatus, new TGTextBuffer(1)); vReadoutStatus->AddFrame(txtBusError, new TGLayoutHints(kLHintsRight, 5,5,0,0));
txtBusError->SetEnabled(false);
txtBusError->SetText( "no Bus Error" );
txtBusError->Resize(150,20);
txtBusError->SetTextColor(blue);
txtVMEFIFO = new TGTextEntry(vReadoutStatus, new TGTextBuffer(1)); vReadoutStatus->AddFrame(txtVMEFIFO, new TGLayoutHints(kLHintsRight, 5,5,0,0));
txtVMEFIFO->SetEnabled(false);
txtVMEFIFO->SetText( "VME FIFO EMPTY" );
txtVMEFIFO->Resize(150,20);
txtVMEFIFO->SetTextColor(blue);
}
@ -206,14 +209,17 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
//hRow0->ChangeOptions((hRow0->GetOptions() | kFixedHeight));
//hRow0->
TGTextButton * bOpenChannelSetting = new TGTextButton(hRow0, "Open Channel Setting"); hRow0->AddFrame(bOpenChannelSetting, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
bOpenChannelSetting->SetHeight(40);
bOpenChannelSetting->Connect("Clicked()", "BoardSetting", this, "OpenChannelSetting()");
TGTextButton * bProgramDefaultBoard = new TGTextButton(hRow0, "Program Default Board"); hRow0->AddFrame(bProgramDefaultBoard, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
bProgramDefaultBoard->Connect("Clicked()", "BoardSetting", this, "ProgramBoard()");
TGTextButton * bUpdateStatus = new TGTextButton(hRow0, "Update Status & Settings"); hRow0->AddFrame(bUpdateStatus, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
bUpdateStatus->SetHeight(40);
TGTextButton * bUpdateStatus = new TGTextButton(hRow0, "Update Status and Settings"); hRow0->AddFrame(bUpdateStatus, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
bUpdateStatus->Connect("Clicked()", "BoardSetting", this, "ChangeBoard()");
TGTextButton * bOpenChannelSetting = new TGTextButton(hRow0, "Open Channel Setting"); hRow0->AddFrame(bOpenChannelSetting, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
bOpenChannelSetting->Connect("Clicked()", "BoardSetting", this, "OpenChannelSetting()");
TGTextButton * bReadData = new TGTextButton(hRow0, "Read Data"); hRow0->AddFrame(bReadData, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
bReadData->Connect("Clicked()", "BoardSetting", this, "ReadData()");
TGHorizontalFrame * hRow1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hRow1, new TGLayoutHints( kLHintsExpandX));
@ -277,6 +283,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
TGLabel * lbAP2 = new TGLabel(vBdCfg_Probe_Label, "Ana. Prb. 2"); vBdCfg_Probe_Label->AddFrame(lbAP2, kaka);
cbAP2 = new TGComboBox(vBdCfg_Probe_CBox, "Ana. Pb. 2", 1); vBdCfg_Probe_CBox->AddFrame(cbAP2);
cbAP2->EnableTextInput(false);
cbAP2->AddEntry("N/A", -3);
cbAP2->AddEntry("Input", 0);
cbAP2->AddEntry("Threshold", 1);
cbAP2->AddEntry("Trapezoid - Baseline", 2);
@ -307,6 +314,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
TGLabel * lbDP2 = new TGLabel(vBdCfg_Probe_Label, "Digi. Prb. 2"); vBdCfg_Probe_Label->AddFrame(lbDP2, kaka);
cbDP2 = new TGComboBox(vBdCfg_Probe_CBox, "Digital. Pb.", 1); vBdCfg_Probe_CBox->AddFrame(cbDP2);
cbDP2->EnableTextInput(false);
cbDP2->AddEntry("N/A", -3);
cbDP2->AddEntry("Trigger", 0);
cbDP2->Resize(150, 20);
cbDP2->Connect("Changed()", "BoardSetting", this, "SetBoardConfiguration()");
@ -333,7 +341,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
cbAggOrg->Connect("Changed()", "BoardSetting", this, "SetAggregateOrganization()");
TGLabel * lbAggBLT = new TGLabel(vBdCfga_label, "MAx. Aggregate pre Readout"); vBdCfga_label->AddFrame(lbAggBLT, kaka);
numAggBLT = new TGNumberEntry(vBdCfga_CBox, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vBdCfga_CBox->AddFrame(numAggBLT);
numAggBLT = new TGNumberEntry(vBdCfga_CBox, 50, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vBdCfga_CBox->AddFrame(numAggBLT);
numAggBLT->SetWidth(100);
numAggBLT->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 0x3FF);
numAggBLT->Connect("Modified()", "BoardSetting", this, "SetReadOutAggregate()");
@ -740,7 +748,7 @@ void BoardSetting::ReadStatus(){
}
if( (( temp >> 3 ) & 0x1 ) == 0 ){
txtVMEFIFO->SetText( "VME FIFO NOT EMPTY", false ); txtVMEFIFO->SetTextColor(red);
txtVMEFIFO->SetText( "VME FIFO NOT EMPTY", false ); txtVMEFIFO->SetTextColor(blue);
}else{
txtVMEFIFO->SetText( "VME FIFO EMPTY", false ); txtVMEFIFO->SetTextColor(red);
}
@ -870,9 +878,9 @@ void BoardSetting::ChangeBoard(){
tempBits = digi[boardID]->ReadRegister(Register::DPP::FrontPanelIOControl);
cbLEMOIO->Select( tempBits & 0x1 , false);
if( ((tempBits >> 1) & 0x1 ) == 0 ) {
cbTRGOUTmode->Select( 1 , false);
cbTRGOUTmode->Select( 2 , false);
}else{
cbTRGOUTmode->Select( (tempBits >> 14) & 0x3F , false);
cbTRGOUTmode->Select( (tempBits) & 0x3F000 , false);
}
cbTRGINCtrl->Select( (tempBits >> 10) & 0x1 , false);
cbTRGINMezzanines->Select( (tempBits >> 11) & 0x1 , false);
@ -898,6 +906,7 @@ void BoardSetting::ChangeBoard(){
cbAP2->SetEnabled(true);
cbAP2->RemoveAll();
cbAP2->AddEntry("N/A", -3);
cbAP2->AddEntry("Input", 0);
cbAP2->AddEntry("Threshold", 1);
cbAP2->AddEntry("Trapezoid - Baseline", 2);
@ -919,10 +928,11 @@ void BoardSetting::ChangeBoard(){
cbDP1->AddEntry("Memory full", 12);
cbDP2->RemoveAll();
cbDP2->AddEntry("N/A", -3);
cbDP2->AddEntry("Trigger", 0);
cbDP2->SetEnabled(false);
cbDP2->Select(-1, false);
cbDP2->Select(-3, false);
/// Board Configuration
//digi[boardID]->PrintRegister(Register::DPP::BoardConfiguration, "BoardConfiguration");
@ -934,16 +944,19 @@ void BoardSetting::ChangeBoard(){
bTrigPropa->SetState( ((tempBits >> 2) & 0x1) ? kButtonDown : kButtonUp, false );
bExtrac2->SetState( ((tempBits >> 17) & 0x1) ? kButtonDown : kButtonUp, false );
//TODO remove bDualTrace, when cbAP2 is not -1, DualTrace is on
if( (tempBits >> 11) & 0x1 ){
bDualTrace->SetState( kButtonDown , false );
cbAP2->SetEnabled(true);
cbAP2->Select( ((tempBits >> 14) & 0x3) , false);
}else{
bDualTrace->SetState( kButtonUp , false );
cbAP2->SetEnabled(false);
cbAP2->Select(-3, false);
}
cbAP1->Select( ((tempBits >> 12) & 0x3) , false);
cbAP2->Select( ((tempBits >> 14) & 0x3) , false);
cbDP1->Select( ((tempBits >> 20) & 0x7) , false);
}else if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ) {
@ -958,7 +971,7 @@ void BoardSetting::ChangeBoard(){
cbAP2->SetEnabled(false);
cbAP2->RemoveAll();
cbAP2->AddEntry("N/A", -1);
cbAP2->AddEntry("N/A", -3);
cbAP2->AddEntry("Baseline", 0);
cbAP2->AddEntry("CFD", 1);
@ -1041,7 +1054,12 @@ void BoardSetting::ResetSettingToDefault(){ /// same for PHA and PSD
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
digi[boardID]->Reset();
digi[boardID]->WriteRegister(Register::DPP::SoftwareReset, 1);
ChangeBoard();
}
void BoardSetting::ClearBuffer(){ /// same for PHA and PSD
@ -1050,6 +1068,8 @@ void BoardSetting::ClearBuffer(){ /// same for PHA and PSD
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
digi[boardID]->WriteRegister(Register::DPP::SoftwareClear, 1);
ReadStatus();
}
void BoardSetting::SetBoardConfiguration(){
@ -1061,8 +1081,7 @@ void BoardSetting::SetBoardConfiguration(){
if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ) {
bit += (18 << 3) ; /// Reserved must be 0010010 for bit[10:3]
printf("bit : 0x%x \n", bit);
if( bAutoDataFlush->GetState() == kButtonDown ) { bit += 1; printf("bit : 0x%x \n", bit);};
if( bAutoDataFlush->GetState() == kButtonDown ) { bit += 1;};
if( bDecimateWF->GetState() == kButtonDown ) bit += (1 << 1);
if( bWFRecord->GetState() == kButtonDown ) bit += ( 1 << 16);
if( bTrigPropa->GetState() == kButtonDown ) bit += ( 1 << 2);
@ -1072,9 +1091,12 @@ void BoardSetting::SetBoardConfiguration(){
cbAP2->SetEnabled(true);
}else{
cbAP2->SetEnabled(false);
cbAP2->Select(-3, false);
}
if( cbAP2->GetSelected() > 0 ) bit += (cbAP2->GetSelected() << 14);
bit += (cbAP1->GetSelected() << 12);
bit += (cbAP2->GetSelected() << 14);
bit += (cbDP1->GetSelected() << 20);
}
@ -1139,6 +1161,8 @@ void BoardSetting::SetACQControl(){ /// same for PHA and PSD
printf("bit : 0x%x \n", bit);
digi[boardID]->WriteRegister(Register::DPP::AcquisitionControl, bit );
ReadStatus();
}
@ -1147,6 +1171,9 @@ void BoardSetting::SendSoftwareTriggerSignal(){ /// same for PHA and PSD
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
digi[boardID]->WriteRegister(Register::DPP::SoftwareTrigger, 1 );
ReadStatus();
}
void BoardSetting::SendSoftwareClockSyncSignal(){ /// same for PHA and PSD
@ -1287,3 +1314,49 @@ void BoardSetting::SetReadOutControl(){ /// same for PHA and PSD
digi[boardID]->WriteRegister(Register::DPP::ReadoutControl, bit );
}
void BoardSetting::ReadData(){
printf("=== %s\n", __func__);
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::ReadoutStatus);
if( (temp & 0x1) == 0 ) {
printf("No data. \n");
return;
}
Data * data = digi[boardID]->GetData();
data->AllocateMemory();
data->DPPType = digi[boardID]->GetDPPType();
digi[boardID]->ReadData();
//data->PrintBuffer();
data->DecodeBuffer(2);
data->PrintStat();
//Fill Histogram
data->ClearData();
ReadStatus();
}
void BoardSetting::ProgramBoard(){
printf("=== %s\n", __func__);
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ){
digi[boardID]->ProgramBoard();
}
if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){
digi[boardID]->ProgramPHABoard();
}
ChangeBoard();
}

View File

@ -173,5 +173,8 @@ class BoardSetting{
///==== Others
void LogMsg(TString msg); // *SIGNAL*
void Haha(Int_t boardID); // *SIGNAL*
void ReadData();
void ProgramBoard();
};
#endif

View File

@ -32,6 +32,8 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
TGHorizontalFrame *hframe0 = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframe0, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
///==========Board choose
//TODO Serial Number
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);
@ -57,7 +59,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
///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(kLHintsRight, 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);
@ -244,8 +246,10 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
}
TGHorizontalFrame *hframe2 = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframe2, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
{///================== const uint32_t DPPAlgorithmControl = 0x1080; /// R/W
TGGroupFrame * gfDPPCtrl = new TGGroupFrame(vframe, "DPP Algorithm Control 1 & 2", kHorizontalFrame); vframe->AddFrame(gfDPPCtrl, new TGLayoutHints(kLHintsExpandX));
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));
@ -296,8 +300,8 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
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(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbLocalShapedTrigger);
cbLocalShapedTrigger->AddEntry("Disabled", -1);
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);
@ -307,7 +311,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
TGLabel * lbLocalTriggerValid = new TGLabel(vfDPPCtrl21, "Local Trigger Valid. :"); vfDPPCtrl21->AddFrame(lbLocalTriggerValid, haha);
cbLocalTriggerValid = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbLocalTriggerValid);
cbLocalTriggerValid->AddEntry("Disabled", -1);
cbLocalTriggerValid->AddEntry("Disabled", -3);
cbLocalTriggerValid->AddEntry("crossed", 0);
cbLocalTriggerValid->AddEntry("val0 = val1 from mother-board mask", 1);
cbLocalTriggerValid->AddEntry("AND", 3);
@ -347,7 +351,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
cbTagCorrelatedEvent->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm2()");
TGLabel * lbBaselineOptimize = new TGLabel(vfDPPCtrl11, "Baseline Optimaization :"); vfDPPCtrl11->AddFrame(lbBaselineOptimize, haha);
cbBaselineOptimize = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbBaselineOptimize);
cbBaselineOptimize = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbBaselineOptimize);
cbBaselineOptimize->AddEntry("Disabled", 0);
cbBaselineOptimize->AddEntry("Enabled", 1);
cbBaselineOptimize->Resize(width, 20);
@ -378,6 +382,17 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
}
{///================== Commands Buttons
TGGroupFrame * gfCmd = new TGGroupFrame(hframe2, "Commands", kHorizontalFrame); hframe2->AddFrame(gfCmd, new TGLayoutHints(kLHintsExpandX));
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()");
}
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
@ -450,8 +465,6 @@ void ChannelSettingPHA::ChangeBoard(){
void ChannelSettingPHA::ChangeCh(){
LogMsg(Form("========== Change to Channel %d", (int)chIDEntry->GetNumber()));
if ( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
@ -462,6 +475,8 @@ void ChannelSettingPHA::ChangeCh(){
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);
@ -498,16 +513,15 @@ void ChannelSettingPHA::ChangeCh(){
cbPileUp->Select( ( (temp >> 27) & 0x1), false);
temp = digi[boardID]->ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, ch);
if( (((temp >> 2)) & 0x1 ) == 1 ){
cbLocalShapedTrigger->Select( ( (temp >> 0) & 0x3), false);
cbLocalShapedTrigger->Select( (temp & 0x3), false);
}else{
cbLocalShapedTrigger->Select( -1, false);
cbLocalShapedTrigger->Select( -3, false);
}
if( (((temp >> 6)) & 0x1 ) == 1 ){
cbLocalTriggerValid->Select( ( (temp >> 4) & 0x3), false);
if( ((temp >> 6) & 0x1 ) == 1 ){
cbLocalTriggerValid->Select( ((temp >> 4) & 0x3), false);
}else{
cbLocalTriggerValid->Select( -1, false);
cbLocalTriggerValid->Select(-3, false);
}
cbVetoSource->Select( ( (temp >> 14) & 0x3), false);
cbTriggerCounterRate->Select( ( (temp >> 16) & 0x3), false);
@ -527,21 +541,24 @@ void ChannelSettingPHA::SetAllChannels(){
short boardID = boardIDEntry->GetNumber();
short ch = chIDEntry->GetNumber();
//TODO other register
uint32_t bit = 0;
bit += numTrapScale->GetNumber();
bit += ((cbDecimation->GetSelected() << 8) & 0x3);
bit += ((cbDecimationGain->GetSelected() << 10) & 0x3);
bit += ((cbPeakMean->GetSelected() << 12) & 0x3);
bit += ((cbPolarity->GetSelected() << 16) & 0x3);
bit += ((cbTriggerMode->GetSelected() << 18) & 0x3);
bit += ((cbBaseLineAvg->GetSelected() << 20) & 0x7);
bit += ((cbDisableSelfTrigger->GetSelected() << 24) & 0x1);
bit += ((cbRollOver->GetSelected() << 26) & 0x1);
bit += ((cbPileUp->GetSelected() << 27) & 0x1);
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);
@ -550,12 +567,12 @@ void ChannelSettingPHA::SetAllChannels(){
bit += ((cbLocalTriggerValid->GetSelected() << 4) & 0x3);
bit += ( 1 << 6);
}
bit += ((cbExtra2WordOption->GetSelected() << 8 ) & 0x7);
bit += ((cbVetoSource->GetSelected() << 14 ) & 0x3);
bit += ((cbTriggerCounterRate->GetSelected() << 16 ) & 0x3);
bit += ((cbBaselineCal->GetSelected() << 18 ) & 0x1);
bit += ((cbTagCorrelatedEvent->GetSelected() << 19 ) & 0x1);
bit += ((cbBaselineOptimize->GetSelected() << 29 ) & 0x1);
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);
@ -584,25 +601,19 @@ void ChannelSettingPHA::SetDPPAlgorithm1(){
short boardID = boardIDEntry->GetNumber();
short ch = chIDEntry->GetNumber();
unsigned short ch2ns = digi[boardID]->GetCh2ns();
digi[boardID]->WriteRegister(Register::DPP::InputDynamicRange, cbInputDynamicRange->GetSelected(), -1);
unsigned short temp = ((unsigned short)(numRecordLength->GetNumber())) / 8 / ch2ns;
digi[boardID]->WriteRegister(Register::DPP::RecordLength_G, temp , ch);
uint32_t bit = 0;
bit = bit + numTrapScale->GetNumber();
bit = bit + ((cbDecimation->GetSelected() << 8) & 0x3);
bit = bit + ((cbDecimationGain->GetSelected() << 10) & 0x3);
bit = bit + ((cbPeakMean->GetSelected() << 12) & 0x3);
bit = bit + ((cbPolarity->GetSelected() << 16) & 0x3);
bit = bit + ((cbTriggerMode->GetSelected() << 18) & 0x3);
bit = bit + ((cbBaseLineAvg->GetSelected() << 20) & 0x7);
bit = bit + ((cbDisableSelfTrigger->GetSelected() << 24) & 0x1);
bit = bit + ((cbRollOver->GetSelected() << 26) & 0x1);
bit = bit + ((cbPileUp->GetSelected() << 27) & 0x1);
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);
@ -623,15 +634,15 @@ void ChannelSettingPHA::SetDPPAlgorithm2(){
bit += ( 1 << 2);
}
if( cbLocalTriggerValid->GetSelected() >= 0 ){
bit += ((cbLocalTriggerValid->GetSelected() << 4) & 0x3);
bit += ((cbLocalTriggerValid->GetSelected() & 0x3) << 4);
bit += ( 1 << 6);
}
bit += ((cbExtra2WordOption->GetSelected() << 8 ) & 0x7);
bit += ((cbVetoSource->GetSelected() << 14 ) & 0x3);
bit += ((cbTriggerCounterRate->GetSelected() << 16 ) & 0x3);
bit += ((cbBaselineCal->GetSelected() << 18 ) & 0x1);
bit += ((cbTagCorrelatedEvent->GetSelected() << 19 ) & 0x1);
bit += ((cbBaselineOptimize->GetSelected() << 29 ) & 0x1);
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);
@ -693,4 +704,19 @@ void ChannelSettingPHA::SetTriggerSmoothing(){
if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor, (unsigned int)cbTriggerSmoothing->GetSelected() , ch);
}
void ChannelSettingPHA::ReadTrace(){
///Set Record Trace
///Set ChannelMask
///StartACQ
///Loop: check is there any data
///if data, Read data, DecodeData
///Send plot trace to MainWindows
Emit("SendPlotTraceCmd()");
}

View File

@ -110,7 +110,10 @@ class ChannelSettingPHA{
void SetPeaking();
void SetPeakHoldOff();
void ReadTrace();
void LogMsg(TString msg); // *SIGNAL*
void SendPlotTraceCmd(); // *SIGNAL*
};
#endif

View File

@ -353,7 +353,7 @@ ChannelSettingPSD::ChannelSettingPSD(const TGWindow *p, UInt_t w, UInt_t h, Digi
TGLabel * lbLocalShapedTrigger = new TGLabel(vfDPPCtrl21, "Local Shaped Trigger :"); vfDPPCtrl21->AddFrame(lbLocalShapedTrigger, haha);
cbLocalShapedTrigger = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbLocalShapedTrigger);
cbLocalShapedTrigger->AddEntry("Disabled", -1);
cbLocalShapedTrigger->AddEntry("Disabled", -3);
cbLocalShapedTrigger->AddEntry("AND", 0);
cbLocalShapedTrigger->AddEntry("Even Channel", 1);
cbLocalShapedTrigger->AddEntry("Odd Channel", 2);
@ -363,7 +363,7 @@ ChannelSettingPSD::ChannelSettingPSD(const TGWindow *p, UInt_t w, UInt_t h, Digi
TGLabel * lbLocalTriggerValid = new TGLabel(vfDPPCtrl21, "Local Trigger Valid. :"); vfDPPCtrl21->AddFrame(lbLocalTriggerValid, haha);
cbLocalTriggerValid = new TGComboBox(vfDPPCtrl22); vfDPPCtrl22->AddFrame(cbLocalTriggerValid);
cbLocalTriggerValid->AddEntry("Disabled", -1);
cbLocalTriggerValid->AddEntry("Disabled", -3);
cbLocalTriggerValid->AddEntry("Enable Add.", 0);
cbLocalTriggerValid->AddEntry("val0 = val1 from mother-board mask", 1);
cbLocalTriggerValid->AddEntry("AND", 3);
@ -564,12 +564,12 @@ void ChannelSettingPSD::ChangeCh(){
if( (((temp >> 2)) & 0x1 ) == 1 ){
cbLocalShapedTrigger->Select( ( (temp >> 0) & 0x3), false);
}else{
cbLocalShapedTrigger->Select( -1, false);
cbLocalShapedTrigger->Select( -3, false);
}
if( (((temp >> 6)) & 0x1 ) == 1 ){
cbLocalTriggerValid->Select( ( (temp >> 4) & 0x3), false);
}else{
cbLocalTriggerValid->Select( -1, false);
cbLocalTriggerValid->Select( -3, false);
}
cbVetoSource->Select( ( (temp >> 14) & 0x3), false);
cbTriggerCounterRate->Select( ( (temp >> 16) & 0x3), false);

View File

@ -9,47 +9,47 @@ int main(int argc, char* argv[]){
/**************/
const int nBoard = 3;
const int nBoard = 1;
Digitizer **dig = new Digitizer *[nBoard];
for( int i = 0 ; i < nBoard; i++){
int board = i % 3;
int port = i/3;
dig[i] = new Digitizer(board, port, false, true);
dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin");
//dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
//dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin");
dig[i]->OpenSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin");
}
/*
DigitizerPHA * pha = dynamic_cast<DigitizerPHA*> (dig[0]);
pha->ProgramBoard();
pha->PrintBoardConfiguration();
pha->PrintChannelSettingFromDigitizer(0);
pha->PrintChannelSettingFromDigitizer(15);
dig[0]->ProgramPHABoard();
pha->GetSetting(Setting::PHA::AnalogProbe1_board_2bit);
//DigitizerPHA * pha = dynamic_cast<DigitizerPHA*> (dig[0]);
//pha->ProgramBoard();
//pha->PrintBoardConfiguration();
//pha->PrintChannelSettingFromDigitizer(0);
//pha->PrintChannelSettingFromDigitizer(15);
remove("test.bin");
Data * data = pha->GetData();
Data * data = dig[0]->GetData();
data->AllocateMemory();
data->DPPType = dig[0]->GetDPPType();
pha->StartACQ();
dig[0]->StartACQ();
for( int p = 0; p < 100; p++){
for( int p = 0; p < 10; p++){
sleep(1);
pha->ReadData();
dig[0]->ReadData();
data->SaveBuffer("test.bin");
data->DecodeBuffer(1);
data->DecodeBuffer(2);
data->PrintStat();
data->ClearData();
}
pha->StopACQ();
dig[0]->StopACQ();
delete pha;
//delete [] dig;
//delete pha;
delete [] dig;
/*********************/