From 58cb5705423521667782175c85595d022bab4b64 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Wed, 28 Sep 2022 16:45:59 -0400 Subject: [PATCH] can plot trace at FSUDAQ --- ClassDigitizer.cpp | 6 ++-- FSUDAQ.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++---- FSUDAQ.h | 7 +++-- boardSetting.cpp | 4 +-- 4 files changed, 79 insertions(+), 12 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 27aa67d..1a958f0 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -334,7 +334,7 @@ void Digitizer::ReadData(){ ret = CAEN_DGTZ_ReadData(handle, CAEN_DGTZ_SLAVE_TERMINATED_READOUT_MBLT, data->buffer, &(data->nByte)); uint32_t EventSize = ReadRegister(Register::DPP::EventSize); // Is it as same as data->nByte? - //printf("Read Buffer size %d byte, Event Size : %d byte \n", data->nByte, EventSize); + printf("Read Buffer size %d byte, Event Size : %d byte \n", data->nByte, EventSize); if (ret || data->nByte == 0) { ErrorMsg(__func__); @@ -582,8 +582,8 @@ 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); + ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 250); + ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x84F8115); //TODO change to write register ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 9919c67..688af92 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -114,10 +114,11 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,10)); ///================= Log massage TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame); - fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,0,5) ); + fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsExpandX, 10,10,10,10) ); - teLog = new TGTextEdit(groupLog, w, 100); - groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsNormal, 0,0,10,0)); + teLog = new TGTextEdit(groupLog, w, 100); groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsExpandX, 2,2,10,0) ); + + /// Set a name to the main frame fMain->SetWindowName("FSU DAQ"); /// Map all subwindows of main frame @@ -146,6 +147,12 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { //HandleMenu(M_CH_SETTING_PHA); //HandleMenu(M_CH_SETTING_PSD); + gAnaTrace1 = NULL; + gAnaTrace2 = NULL; + gDigiTrace1 = NULL; + gDigiTrace2 = NULL; + + } MainWindow::~MainWindow() { delete fMenuBar; @@ -168,8 +175,12 @@ MainWindow::~MainWindow() { // //delete saveDataThread; //delete fillHistThread; - // - //delete gTrace; + + delete gAnaTrace1; + delete gAnaTrace2; + delete gDigiTrace1; + delete gDigiTrace2; + /// Clean up used widgets: frames, buttons, layout hints fMain->Cleanup(); @@ -367,6 +378,59 @@ void MainWindow::LogMsg(char * msg){ void MainWindow::PlotTrace(){ printf("=== %s\n", __func__); + Data * data = digi[0]->GetData(); + data->AllocateMemory(); + data->DPPType = digi[0]->GetDPPType(); + + int ch2ns = (int) digi[0]->GetCh2ns(); + + digi[0]->StartACQ(); + + int count = 0; + + while(count < 10){ + //sleep(1); + usleep(500*1000); /// wait half sec + digi[0]->ReadData(); + + if( data->nByte > 0 ){ + data->DecodeBuffer(1); + + data->PrintStat(); + + delete gAnaTrace1; gAnaTrace1 = new TGraph(); + delete gDigiTrace1; gDigiTrace1 = new TGraph(); + + int traceLength = (data->Waveform1[0][0]).size(); + + printf("0----------%d \n", traceLength); + + if( traceLength == 0 ) { + LogMsg("no trace"); + }else{ + for( int i = 0; i < traceLength ; i++) { + //printf("%d, ", (data->Waveform1[0][0])[i]); + gAnaTrace1->SetPoint(i, i*ch2ns, (data->Waveform1[0][0])[i]); + gDigiTrace1->SetPoint(i, i*ch2ns, 2000*(data->DigiWaveform1[0][0])[i] + 2000); + + } + } + data->ClearData(); + + fEcanvas->GetCanvas()->cd(); + gAnaTrace1->Draw("APL"); + gDigiTrace1->Draw("L"); + fEcanvas->GetCanvas()->Update(); + break; + + } + + count++; + + }; + digi[0]->StopACQ(); + if( count == 10 ) LogMsg("Plot Trace TimeOut, please check setting"); + } //############################################ diff --git a/FSUDAQ.h b/FSUDAQ.h index b302d1e..dd6eb48 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -69,8 +69,11 @@ private: //static TH1F * hEnergy[MAXMOD][MAXCH]; //static TH1F * hChannel[MAXMOD]; //static bool isEnergyHistFilled; - //TGraph * gTrace; - // + + TGraph * gAnaTrace1; /// analogy trace 1 + TGraph * gAnaTrace2; /// analogy trace 2 + TGraph * gDigiTrace1; /// digital trace 1 + TGraph * gDigiTrace2; /// digital trace 1 //TGTextEditor * configEditor; diff --git a/boardSetting.cpp b/boardSetting.cpp index 57ac9d0..eb18d21 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -917,7 +917,7 @@ void BoardSetting::ChangeBoard(){ cbDP1->AddEntry("Armed (Triggered)", 1); cbDP1->AddEntry("Peak Run", 2); cbDP1->AddEntry("Pile-Up", 3); - cbDP1->AddEntry("Peaking", 4); + ///cbDP1->AddEntry("Peaking", 4); Duplicated? cbDP1->AddEntry("TRG Validation Win.", 5); cbDP1->AddEntry("Baseline freeze", 6); cbDP1->AddEntry("TRG holdoff", 7); @@ -1080,7 +1080,7 @@ void BoardSetting::SetBoardConfiguration(){ uint32_t bit = (3 << 18); /// timestamp and energy recording if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ) { - bit += (18 << 3) ; /// Reserved must be 0010010 for bit[10:3] + bit += (34 << 3) ; /// Reserved must be 0010010 for bit[10:3] if( bAutoDataFlush->GetState() == kButtonDown ) { bit += 1;}; if( bDecimateWF->GetState() == kButtonDown ) bit += (1 << 1); if( bWFRecord->GetState() == kButtonDown ) bit += ( 1 << 16);