From 545aaec41905f648b72d2962f41aa1480a3c42d6 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Fri, 26 Aug 2022 17:18:43 -0400 Subject: [PATCH] improved ClassData and channelSetting --- ClassData.h | 195 ++++++++++++++++++++++++++++++++++++--------- ClassDigitizer.cpp | 1 - DigitizerPHA.cpp | 8 +- FSUDAQ.cpp | 30 +++---- FSUDAQ.h | 2 +- channelSetting.cpp | 69 +++++++++++----- channelSetting.h | 2 +- test.cpp | 38 +++++---- 8 files changed, 253 insertions(+), 92 deletions(-) diff --git a/ClassData.h b/ClassData.h index 416d638..44e588c 100644 --- a/ClassData.h +++ b/ClassData.h @@ -8,8 +8,12 @@ #include ///memset #include ///cout #include +#include #include "CAENDigitizerType.h" +#include "macro.h" + +#define MaxNData 10000 /// for timestamp 8 byte = 80kB class Data{ @@ -20,7 +24,17 @@ class Data{ char *buffer; /// readout buffer uint32_t AllocatedSize; uint32_t BufferSize; - ///uint32_t NumEvents[MaxNChannels]; + + unsigned short NumEvents[MaxNChannels]; + unsigned long long Timestamp[MaxNChannels][MaxNData]; + unsigned short Energy[MaxNChannels][MaxNData]; + unsigned short Energy2[MaxNChannels][MaxNData]; /// in PSD, Energy = Qshort, Energy2 = Qlong + + std::vector Waveform1[MaxNChannels][MaxNData]; + std::vector Waveform2[MaxNChannels][MaxNData]; + std::vector DigiWaveform1[MaxNChannels][MaxNData]; + std::vector DigiWaveform2[MaxNChannels][MaxNData]; + ///CAEN_DGTZ_DPP_PHA_Event_t *Events[MaxNChannels]; /// events buffer ///CAEN_DGTZ_DPP_PHA_Waveforms_t *Waveform[MaxNChannels]; /// waveforms buffer @@ -31,35 +45,47 @@ class Data{ void AllocateMemory(); void FreeMemory(); - void SaveBuffer(char * fileName); + void SetSaveWaveformToMemory(bool OnOff) { this->SaveWaveformToMemory = OnOff; } + + void ClearData(); + + void SaveBuffer(const char * fileName); void DecodeBuffer(int verbose = 0); void DecodeBuffer(char * buffer, int verbose = 0); + protected: + + unsigned int nw; + bool SaveWaveformToMemory; + + ///for temperary + std::vector tempWaveform1; + std::vector tempWaveform2; + std::vector tempDigiWaveform1; + std::vector tempDigiWaveform2; + unsigned int ReadBuffer(unsigned int nWord, int verbose = 0); - int DecodePHADualChannelBlock(unsigned int nWord, unsigned int ChannelMask, int verbose); - int DecodePSDDualChannelBlock(unsigned int nWord, unsigned int ChannelMask, int verbose); + int DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose); + int DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose); }; //========================================== inline Data::Data(){ - nByte = 0; + buffer = NULL; - AllocatedSize = 0; - BufferSize = 0; - ///for( int i = 0 ; i < MaxNChannels; i++){ - /// NumEvents[i] = 0; - /// Events[i] = NULL; - /// Waveform[i] = NULL; - ///} + ClearData(); + SaveWaveformToMemory = false; + nw = 0; } inline Data::~Data(){ - if( buffer != NULL ) delete buffer; + FreeMemory(); + ///if( buffer != NULL ) delete buffer; ///for( int i = 0 ; i < MaxNChannels; i++){ /// delete Events [i]; /// delete Waveform [i]; @@ -68,7 +94,7 @@ inline Data::~Data(){ inline void Data::AllocateMemory(){ - BufferSize = 100000; /// byte + BufferSize = 1000000; /// 1M byte buffer = (char *) malloc( BufferSize); printf("Allocated %d byte for buffer \n", BufferSize); ///for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize); @@ -78,9 +104,35 @@ inline void Data::AllocateMemory(){ inline void Data::FreeMemory(){ printf("======= Free memory\n"); - delete buffer; + if( buffer != NULL ) delete buffer; } +inline void Data::ClearData(){ + + nByte = 0; + AllocatedSize = 0; + BufferSize = 0; + + for( int i = 0 ; i < MaxNChannels; i++){ + NumEvents[i] = 0; + for( int j = 0; j < MaxNData; j++){ + Timestamp[i][j] = 0; + Energy[i][j] = 0; + Energy2[i][j] = 0; + Waveform1[i][j].clear(); + Waveform2[i][j].clear(); + DigiWaveform1[i][j].clear(); + DigiWaveform2[i][j].clear(); + } + } + + tempWaveform1.clear(); + tempWaveform2.clear(); + tempDigiWaveform1.clear(); + tempDigiWaveform2.clear(); +} + + inline unsigned int Data::ReadBuffer(unsigned int nWord, int verbose){ if( buffer == NULL ) return 0; @@ -90,7 +142,7 @@ inline unsigned int Data::ReadBuffer(unsigned int nWord, int verbose){ return word; } -inline void Data::SaveBuffer(char * fileName){ +inline void Data::SaveBuffer(const char * fileName){ FILE * haha = fopen(fileName, "a+"); fwrite(buffer, nByte, 1, haha); fclose(haha); @@ -105,11 +157,11 @@ inline void Data::DecodeBuffer(int verbose){ /// verbose : 0 = off, 1 = only energy + timestamp, 2 = show header, 3 = wave if( buffer == NULL ) { - printf(" buffer is empty \n"); + if( verbose >= 1 ) printf(" buffer is empty \n"); return; } - unsigned int nw = 0; + nw = 0; do{ if( verbose >= 2 ) printf("######################################### Board Agg.\n"); @@ -130,15 +182,13 @@ inline void Data::DecodeBuffer(int verbose){ for( int chMask = 0; chMask < 8 ; chMask ++ ){ if( ((ChannelMask >> chMask) & 0x1 ) == 0 ) continue; - if( verbose >= 2 ) printf("---------------------- Dual Channel Block : %d\n", chMask *2 ); + if( verbose >= 2 ) printf("---------------------- Dual Channel Block : %d, nw : %d\n", chMask *2, nw); if( DPPType == V1730_DPP_PHA_CODE ) { - nw = DecodePHADualChannelBlock(nw + 1, chMask, verbose); - if ( nw < 0 ) break; + if ( DecodePHADualChannelBlock(chMask, verbose) < 0 ) break; } if( DPPType == V1730_DPP_PSD_CODE ) { - nw = DecodePHADualChannelBlock(nw + 1, chMask, verbose); - if ( nw < 0 ) break; + if ( DecodePHADualChannelBlock(chMask, verbose) < 0 ) break; } } }else{ @@ -149,9 +199,9 @@ inline void Data::DecodeBuffer(int verbose){ }while(true); } -inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int ChannelMask, int verbose){ +inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose){ - int nw = nWord; + nw = nw + 1; unsigned int word = ReadBuffer(nw, verbose); bool hasFormatInfo = ((word >> 31) & 0x1); @@ -160,6 +210,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan unsigned int nSample = 0; /// wave form; unsigned int nEvents = 0; unsigned int extra2Option = 0; + bool hasDualTrace = 0 ; if( hasFormatInfo ){ nw = nw + 1; word = ReadBuffer(nw, verbose); @@ -173,7 +224,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan bool hasExtra2 = ( (word >> 28 ) & 0x1 ); bool hasTimeStamp = ( (word >> 29 ) & 0x1 ); bool hasEnergy = ( (word >> 30 ) & 0x1 ); - bool hasDualTrace = ( (word >> 31 ) & 0x1 ); + hasDualTrace = ( (word >> 31 ) & 0x1 ); if( verbose >= 2 ) { printf("dualTrace : %d, Energy : %d, Time: %d, Wave : %d, Extra2: %d \n", @@ -226,7 +277,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan if( verbose >= 2 ) printf("=========== nEvents : %d \n", nEvents); }else{ if( verbose >= 2 ) printf("does not has format info. unable to read buffer.\n"); - return -1; + return 0; } ///========== decode an event @@ -238,17 +289,38 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan int channel = ChannelMask*2 + channelTag; if( verbose >= 2 ) printf("ch : %d, timeStamp0 %u \n", channel, timeStamp0); + NumEvents[channel] ++; + + //TODO Skip ///===== read waveform + if( SaveWaveformToMemory ) { + tempWaveform1.clear(); + tempWaveform2.clear(); + tempDigiWaveform1.clear(); + } + unsigned int triggerAtSample = 0 ; for( int wi = 0; wi < nSample/2; wi++){ nw = nw +1 ; word = ReadBuffer(nw, verbose - 2); bool isTrigger1 = (( word >> 31 ) & 0x1 ); bool dp1 = (( word >> 30 ) & 0x1 ); - unsigned int wave1 = (( word >> 16) & 0x3FFF); + unsigned short wave1 = (( word >> 16) & 0x3FFF); bool isTrigger0 = (( word >> 15 ) & 0x1 ); bool dp0 = (( word >> 14 ) & 0x1 ); - unsigned int wave0 = ( word & 0x3FFF); + unsigned short wave0 = ( word & 0x3FFF); + + if( SaveWaveformToMemory){ + if( hasDualTrace ){ + tempWaveform1.push_back(wave0); + tempWaveform2.push_back(wave1); + }else{ + tempWaveform1.push_back(wave0); + tempWaveform1.push_back(wave1); + } + tempDigiWaveform1.push_back(dp0); + tempDigiWaveform1.push_back(dp1); + } if( isTrigger0 == 1 ) triggerAtSample = 2*wi ; if( isTrigger1 == 1 ) triggerAtSample = 2*wi + 1; @@ -259,6 +331,16 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan } } + if( SaveWaveformToMemory ) { + if( hasDualTrace ){ + Waveform1[channel][NumEvents[channel]] = tempWaveform1; + Waveform2[channel][NumEvents[channel]] = tempWaveform2; + }else{ + Waveform1[channel][NumEvents[channel]] = tempWaveform1; + } + DigiWaveform1[channel][NumEvents[channel]] = tempDigiWaveform1; + } + nw = nw +1 ; word = ReadBuffer(nw, verbose); unsigned int extra2 = word; unsigned long long extTimeStamp = 0; @@ -290,8 +372,11 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan } - if( verbose >= 1 ) printf("ch : %2d, PileUp : %d , energy : %d, roll-Over: %d, timestamp : %llu, triggerAt : %d\n", - channel, pileUp, energy, rollOver, timeStamp, triggerAtSample); + if( verbose >= 1 ) printf("%4d | ch : %2d, PileUp : %d , energy : %d, roll-Over: %d, timestamp : %llu, triggerAt : %d, nSample : %d\n", + NumEvents[channel], channel, pileUp, energy, rollOver, timeStamp, triggerAtSample, nSample ); + + Energy[channel][NumEvents[channel]] = energy; + Timestamp[channel][NumEvents[channel]] = timeStamp; } @@ -303,11 +388,12 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan return nw; } -inline int Data::DecodePSDDualChannelBlock(unsigned int nWord, unsigned int ChannelMask, int verbose){ - int nw = nWord; +inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose){ + + nw = nw + 1; unsigned int word = ReadBuffer(nw, verbose); - if( (word >> 31) != 1 ) return -1; + if( (word >> 31) != 1 ) return 0; unsigned int aggSize = ( word & 0x3FFFFF ) ; if( verbose >= 2 ) printf(" size : %d \n", aggSize); @@ -391,16 +477,40 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int nWord, unsigned int Chan int channel = ChannelMask*2 + channelTag; if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp0); + + NumEvents[channel] ++; + ///===== read waveform + if( SaveWaveformToMemory ) { + tempWaveform1.clear(); + tempWaveform2.clear(); + tempDigiWaveform1.clear(); + tempDigiWaveform2.clear(); + } + for( int wi = 0; wi < nSample/2; wi++){ nw = nw +1 ; word = ReadBuffer(nw, verbose - 2); bool dp2b = (( word >> 31 ) & 0x1 ); bool dp1b = (( word >> 30 ) & 0x1 ); - unsigned int waveb = (( word >> 16) & 0x3FFF); + unsigned short waveb = (( word >> 16) & 0x3FFF); bool dp2a = (( word >> 15 ) & 0x1 ); bool dp1a = (( word >> 14 ) & 0x1 ); - unsigned int wavea = ( word & 0x3FFF); + unsigned short wavea = ( word & 0x3FFF); + + if( SaveWaveformToMemory){ + if( hasDualTrace ){ + tempWaveform1.push_back(wavea); + tempWaveform2.push_back(waveb); + }else{ + tempWaveform1.push_back(wavea); + tempWaveform1.push_back(waveb); + } + tempDigiWaveform1.push_back(dp1a); + tempDigiWaveform1.push_back(dp1b); + tempDigiWaveform2.push_back(dp2a); + tempDigiWaveform2.push_back(dp2b); + } if( verbose >= 3 && ev == 0 ){ printf("%4d| %5d, %d, %d \n", 2*wi, wavea, dp1a, dp2a); @@ -408,6 +518,17 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int nWord, unsigned int Chan } } + if( SaveWaveformToMemory ) { + if( hasDualTrace ){ + Waveform1[channel][NumEvents[channel]] = tempWaveform1; + Waveform2[channel][NumEvents[channel]] = tempWaveform2; + }else{ + Waveform1[channel][NumEvents[channel]] = tempWaveform1; + } + DigiWaveform1[channel][NumEvents[channel]] = tempDigiWaveform1; + DigiWaveform2[channel][NumEvents[channel]] = tempDigiWaveform2; + } + nw = nw +1 ; word = ReadBuffer(nw, verbose); unsigned int extra = word; unsigned long long extTimeStamp = 0; @@ -426,6 +547,8 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int nWord, unsigned int Chan if( verbose >= 1 ) printf("ch : %2d, Qshort : %d, Qlong : %d, timestamp : %llu\n", channel, Qshort, Qlong, timeStamp); + Timestamp[channel][NumEvents[channel]] = timeStamp; + } ///=========== Key information diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index acd71db..4854d30 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -40,7 +40,6 @@ Digitizer::~Digitizer(){ CloseDigitizer(); delete data; - ///delete settingFile; /// not needed, settingFile open and close at everytime } void Digitizer::Reset(){ diff --git a/DigitizerPHA.cpp b/DigitizerPHA.cpp index b1b10af..3e18c35 100644 --- a/DigitizerPHA.cpp +++ b/DigitizerPHA.cpp @@ -35,12 +35,12 @@ int DigitizerPHA::ProgramBoard(){ printf("======== program Channels\n"); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::DecayTime + 0x7000 , 5000 ); - ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::TrapezoidFlatTop + 0x7000 , 62 ); + 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 , 64 ); + 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 ); @@ -48,9 +48,9 @@ int DigitizerPHA::ProgramBoard(){ 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::InputDynamicRange + 0x7000 , 0x1 ); - ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5); + ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 1000); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index b7a1467..f5411ff 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -23,7 +23,7 @@ enum MenuIdentifiers{ M_DIGITIZER_SCAN, M_FILE_OPEN, M_EXIT, - M_CH_SETTINGS_SUMMARY, + M_TRIGGER_SUMMARY, M_CH_SETTING, M_BOARD_SETTINGS, M_PROGRAM_SETTINGS, @@ -48,25 +48,26 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame); fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); fMenuFile = new TGPopupMenu(gClient->GetRoot()); - fMenuFile->AddEntry("&Scan Digitizers", M_DIGITIZER_SCAN); fMenuFile->AddEntry("&Open File", M_FILE_OPEN); fMenuFile->AddSeparator(); fMenuFile->AddEntry("E&xit", M_EXIT); fMenuFile->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); - fMenuSettings = new TGPopupMenu(gClient->GetRoot()); - fMenuSettings->AddEntry("&Settings Summary", M_CH_SETTINGS_SUMMARY); - fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING); - fMenuSettings->AddSeparator(); - fMenuSettings->AddEntry("&Digitizer Settings", M_BOARD_SETTINGS); - fMenuSettings->AddSeparator(); - fMenuSettings->AddEntry("Program Settings", M_PROGRAM_SETTINGS); - fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); - fMenuBar->AddPopup("&Settings", fMenuSettings, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); + fMenuDigitizers = new TGPopupMenu(gClient->GetRoot()); + fMenuDigitizers->AddEntry("Scan &Digitizers", M_DIGITIZER_SCAN); + fMenuDigitizers->AddEntry("&Trigger Summary", M_TRIGGER_SUMMARY); + fMenuDigitizers->AddSeparator(); + fMenuDigitizers->AddEntry("Digitizer &Settings", M_BOARD_SETTINGS); + fMenuDigitizers->AddEntry("&Channel Settings", M_CH_SETTING); + fMenuDigitizers->AddSeparator(); + fMenuDigitizers->AddEntry("&Program Settings", M_PROGRAM_SETTINGS); + fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); + fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); + fMenuUtility = new TGPopupMenu(gClient->GetRoot()); fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE); - fMenuSettings->AddSeparator(); + fMenuDigitizers->AddSeparator(); fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS); fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); @@ -120,12 +121,13 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { LogMsg("Ready to run."); HandleMenu(M_BOARD_SETTINGS); + HandleMenu(M_CH_SETTING); } MainWindow::~MainWindow() { delete fMenuBar; delete fMenuFile; - delete fMenuSettings; + delete fMenuDigitizers; delete fMenuUtility; //delete boardIDEntry; @@ -183,7 +185,7 @@ void MainWindow::HandleMenu(Int_t id){ case M_EXIT: GoodBye(); break; ///========================= Channel setting summary - case M_CH_SETTINGS_SUMMARY: { + case M_TRIGGER_SUMMARY: { }break; diff --git a/FSUDAQ.h b/FSUDAQ.h index 5f66094..1c1f8a6 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -32,7 +32,7 @@ private: static TRootEmbeddedCanvas *fEcanvas; TGMenuBar *fMenuBar; - TGPopupMenu *fMenuFile, *fMenuSettings, *fMenuUtility; + TGPopupMenu *fMenuFile, *fMenuDigitizers, *fMenuUtility; //static TGNumberEntry * boardIDEntry, *chEntry; //TGNumberEntry * runIDEntry; diff --git a/channelSetting.cpp b/channelSetting.cpp index 77c24e9..df3cdea 100644 --- a/channelSetting.cpp +++ b/channelSetting.cpp @@ -11,24 +11,53 @@ #include "channelSetting.h" //TODO set MAX -///---------------------------------------------- NAME, DIGI, unit ... MAX -TString settingName[NUM_CHANNEL_SETTING][3] = {{"TRIGGER_RISETIME", "2", "us"}, - {"TRIGGER_FLATTOP", "2", "us"}, - {"TRIGGER_THRESHOLD", "0", "ADC"}, - {"ENERGY_RISETIME", "1", "us"}, - {"ENERGY_FLATTOP", "1", "us"}, - {"TAU", "2", "us"}, - {"TRACE_LENGTH", "2", "us"}, - {"TRACE_DELAY", "2", "us"}, - {"VOFFSET", "2", "V"}, - {"XDT", "2", "us"}, - {"BASELINE_PERCENT", "0", "%"}, - {"BASELINE_AVERAGE", "0", ""}, - {"BLCUT", "0", ""}, - {"EMIN", "0", ""}, - {"MultiplicityMaskL", "0", ""}, - {"MultiplicityMaskH", "0", ""}, - {"CHANNEL_CSRA", "0", ""}}; +///------------------------------------------------ NAME, DIGI, unit ... MAX +TString settingName[NUM_CHANNEL_SETTING][3] = {{"Record Length", "3", "us"}, + {"Input Dynamic Range", "1", ""}, + {"Events / Aggregate", "4", ""}, + {"Pre-Trigger Length", "3", "us"}, + {"Trigger Threshold", "5", "LSD"}, + {"Trigger Holdoff Width", "3", "us"}, + {"DPP Algorithm Control", "8", ""}, + {"Channel DC offset", "2", "%"}, + {"Temperature", "2", "C"}, + {"Veto Width", "3", "us"}, + {"Trigger Filter Smoothing", "3", "smp"}, + {"Input Rising Time", "3", "ns"}, + {"Trapezoid Rise Time", "4", "ns"}, + {"Trapezoid Flat Top", "4", "ns"}, + {"Peaking Time", "4", "ns"}, + {"Decay Time", "4", "us"}, + {"Rise Time Valid. Win.", "4", "us"}, + {"Peak Holdoff", "4", "ns"}, + {"Shaped Trigger Width", "4", "us"}, + {"DPP Algorithm Control 2", "8", ""}, + {"Fine Gain", "3", ""} + }; + +///const uint32_t RecordLength_G = 0x1020; /// R/W +///const uint32_t InputDynamicRange = 0x1028; /// R/W +///const uint32_t NumberEventsPerAggregate_G = 0x1034; /// R/W +///const uint32_t PreTrigger = 0x1038; /// R/W +///const uint32_t TriggerThreshold = 0x106C; /// R/W +///const uint32_t TriggerHoldOffWidth = 0x1074; /// R/W +///const uint32_t DPPAlgorithmControl = 0x1080; /// R/W +///const uint32_t ChannelDCOffset = 0x1098; /// R/W +///const uint32_t ChannelADCTemperature = 0x10A8; /// R +///const uint32_t VetoWidth = 0x10D4; /// R/W + + +/// const uint32_t RCCR2SmoothingFactor = 0x1054; /// R/W Trigger Filter smoothing, triggerSmoothingFactor +/// const uint32_t InputRiseTime = 0x1058; /// R/W OK +/// const uint32_t TrapezoidRiseTime = 0x105C; /// R/W OK +/// const uint32_t TrapezoidFlatTop = 0x1060; /// R/W OK +/// const uint32_t PeakingTime = 0x1064; /// R/W OK +/// const uint32_t DecayTime = 0x1068; /// R/W OK +/// const uint32_t RiseTimeValidationWindow = 0x1070; /// R/W OK +/// const uint32_t PeakHoldOff = 0x1078; /// R/W OK +/// const uint32_t ShapedTriggerWidth = 0x1084; /// R/W not sure +/// const uint32_t DPPAlgorithmControl2_G = 0x10A0; /// R/W OK +/// const uint32_t FineGain = 0x10C4; /// R/W OK ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi){ @@ -97,6 +126,10 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer TGLabel * lbPol = new TGLabel(hframePol, "Polarity"); hframePol->AddFrame(lbPol, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); + + + + ///----- all other TGHorizontalFrame *hframe[NUM_CHANNEL_SETTING]; TGLabel * lb[NUM_CHANNEL_SETTING]; diff --git a/channelSetting.h b/channelSetting.h index 5cd702d..d0c6b58 100644 --- a/channelSetting.h +++ b/channelSetting.h @@ -8,7 +8,7 @@ #include "ClassDigitizer.h" #include "macro.h" -#define NUM_CHANNEL_SETTING 17 +#define NUM_CHANNEL_SETTING 21 class TGWindow; class TGMainFrame; diff --git a/test.cpp b/test.cpp index 671c58c..6207f47 100644 --- a/test.cpp +++ b/test.cpp @@ -5,46 +5,50 @@ int main(int argc, char* argv[]){ - /************** + /**************/ const int nBoard = 1; - DigitizerPHA *dig = new DigitizerPHA[nBoard]; - //DigitizerPSD * psd = new DigitizerPSD(); + Digitizer **dig = new Digitizer *[nBoard]; for( int i = 0 ; i < nBoard; i++){ int board = i % 3; int port = i/3; - dig[i].OpenDigitizer(board, port, true); - dig[i].CreateAndSaveSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); + dig[i] = new DigitizerPHA(board, port); + dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin"); //dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); } - dig[0].PrintBoardConfiguration(); - dig[0].PrintChannelSettingFromDigitizer(4); + DigitizerPHA * pha = dynamic_cast (dig[0]); + pha->ProgramBoard(); + pha->PrintBoardConfiguration(); + pha->PrintChannelSettingFromDigitizer(0); + pha->PrintChannelSettingFromDigitizer(15); + remove("test.bin"); - Data * data = dig[0].data; + Data * data = pha->GetData(); data->AllocateMemory(); - dig[0].StartACQ(); + pha->StartACQ(); - for( int p = 0; p < 11; p++){ + for( int p = 0; p < 100; p++){ sleep(1); - dig[0].ReadData(); + pha->ReadData(); + data->SaveBuffer("test.bin"); data->DecodeBuffer(1); + data->ClearData(); } - dig[0].StopACQ(); + pha->StopACQ(); - - delete [] dig; - //delete psd; + delete pha; + //delete [] dig; - *********************/ + /*********************/ ///********************* method for using Data Class for decoding bin file - + /** FILE * haha = fopen("output.bin", "r"); fseek(haha, 0L, SEEK_END); size_t inFileSize = ftell(haha);