improved ClassData and channelSetting

This commit is contained in:
carina@hades 2022-08-26 17:18:43 -04:00
parent 7fb52da872
commit 545aaec419
8 changed files with 253 additions and 92 deletions

View File

@ -8,8 +8,12 @@
#include <cstring> ///memset #include <cstring> ///memset
#include <iostream> ///cout #include <iostream> ///cout
#include <bitset> #include <bitset>
#include <vector>
#include "CAENDigitizerType.h" #include "CAENDigitizerType.h"
#include "macro.h"
#define MaxNData 10000 /// for timestamp 8 byte = 80kB
class Data{ class Data{
@ -20,7 +24,17 @@ class Data{
char *buffer; /// readout buffer char *buffer; /// readout buffer
uint32_t AllocatedSize; uint32_t AllocatedSize;
uint32_t BufferSize; 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<unsigned short> Waveform1[MaxNChannels][MaxNData];
std::vector<unsigned short> Waveform2[MaxNChannels][MaxNData];
std::vector<bool> DigiWaveform1[MaxNChannels][MaxNData];
std::vector<bool> DigiWaveform2[MaxNChannels][MaxNData];
///CAEN_DGTZ_DPP_PHA_Event_t *Events[MaxNChannels]; /// events buffer ///CAEN_DGTZ_DPP_PHA_Event_t *Events[MaxNChannels]; /// events buffer
///CAEN_DGTZ_DPP_PHA_Waveforms_t *Waveform[MaxNChannels]; /// waveforms buffer ///CAEN_DGTZ_DPP_PHA_Waveforms_t *Waveform[MaxNChannels]; /// waveforms buffer
@ -31,35 +45,47 @@ class Data{
void AllocateMemory(); void AllocateMemory();
void FreeMemory(); 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(int verbose = 0);
void DecodeBuffer(char * buffer, int verbose = 0); void DecodeBuffer(char * buffer, int verbose = 0);
protected: protected:
unsigned int nw;
bool SaveWaveformToMemory;
///for temperary
std::vector<unsigned short> tempWaveform1;
std::vector<unsigned short> tempWaveform2;
std::vector<bool> tempDigiWaveform1;
std::vector<bool> tempDigiWaveform2;
unsigned int ReadBuffer(unsigned int nWord, int verbose = 0); unsigned int ReadBuffer(unsigned int nWord, int verbose = 0);
int DecodePHADualChannelBlock(unsigned int nWord, unsigned int ChannelMask, int verbose); int DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose);
int DecodePSDDualChannelBlock(unsigned int nWord, unsigned int ChannelMask, int verbose); int DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose);
}; };
//========================================== //==========================================
inline Data::Data(){ inline Data::Data(){
nByte = 0;
buffer = NULL; buffer = NULL;
AllocatedSize = 0; ClearData();
BufferSize = 0; SaveWaveformToMemory = false;
///for( int i = 0 ; i < MaxNChannels; i++){ nw = 0;
/// NumEvents[i] = 0;
/// Events[i] = NULL;
/// Waveform[i] = NULL;
///}
} }
inline Data::~Data(){ inline Data::~Data(){
if( buffer != NULL ) delete buffer; FreeMemory();
///if( buffer != NULL ) delete buffer;
///for( int i = 0 ; i < MaxNChannels; i++){ ///for( int i = 0 ; i < MaxNChannels; i++){
/// delete Events [i]; /// delete Events [i];
/// delete Waveform [i]; /// delete Waveform [i];
@ -68,7 +94,7 @@ inline Data::~Data(){
inline void Data::AllocateMemory(){ inline void Data::AllocateMemory(){
BufferSize = 100000; /// byte BufferSize = 1000000; /// 1M byte
buffer = (char *) malloc( BufferSize); buffer = (char *) malloc( BufferSize);
printf("Allocated %d byte for buffer \n", 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); ///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(){ inline void Data::FreeMemory(){
printf("======= Free memory\n"); 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){ inline unsigned int Data::ReadBuffer(unsigned int nWord, int verbose){
if( buffer == NULL ) return 0; if( buffer == NULL ) return 0;
@ -90,7 +142,7 @@ inline unsigned int Data::ReadBuffer(unsigned int nWord, int verbose){
return word; return word;
} }
inline void Data::SaveBuffer(char * fileName){ inline void Data::SaveBuffer(const char * fileName){
FILE * haha = fopen(fileName, "a+"); FILE * haha = fopen(fileName, "a+");
fwrite(buffer, nByte, 1, haha); fwrite(buffer, nByte, 1, haha);
fclose(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 /// verbose : 0 = off, 1 = only energy + timestamp, 2 = show header, 3 = wave
if( buffer == NULL ) { if( buffer == NULL ) {
printf(" buffer is empty \n"); if( verbose >= 1 ) printf(" buffer is empty \n");
return; return;
} }
unsigned int nw = 0; nw = 0;
do{ do{
if( verbose >= 2 ) printf("######################################### Board Agg.\n"); if( verbose >= 2 ) printf("######################################### Board Agg.\n");
@ -130,15 +182,13 @@ inline void Data::DecodeBuffer(int verbose){
for( int chMask = 0; chMask < 8 ; chMask ++ ){ for( int chMask = 0; chMask < 8 ; chMask ++ ){
if( ((ChannelMask >> chMask) & 0x1 ) == 0 ) continue; 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 ) { if( DPPType == V1730_DPP_PHA_CODE ) {
nw = DecodePHADualChannelBlock(nw + 1, chMask, verbose); if ( DecodePHADualChannelBlock(chMask, verbose) < 0 ) break;
if ( nw < 0 ) break;
} }
if( DPPType == V1730_DPP_PSD_CODE ) { if( DPPType == V1730_DPP_PSD_CODE ) {
nw = DecodePHADualChannelBlock(nw + 1, chMask, verbose); if ( DecodePHADualChannelBlock(chMask, verbose) < 0 ) break;
if ( nw < 0 ) break;
} }
} }
}else{ }else{
@ -149,9 +199,9 @@ inline void Data::DecodeBuffer(int verbose){
}while(true); }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); unsigned int word = ReadBuffer(nw, verbose);
bool hasFormatInfo = ((word >> 31) & 0x1); 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 nSample = 0; /// wave form;
unsigned int nEvents = 0; unsigned int nEvents = 0;
unsigned int extra2Option = 0; unsigned int extra2Option = 0;
bool hasDualTrace = 0 ;
if( hasFormatInfo ){ if( hasFormatInfo ){
nw = nw + 1; word = ReadBuffer(nw, verbose); 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 hasExtra2 = ( (word >> 28 ) & 0x1 );
bool hasTimeStamp = ( (word >> 29 ) & 0x1 ); bool hasTimeStamp = ( (word >> 29 ) & 0x1 );
bool hasEnergy = ( (word >> 30 ) & 0x1 ); bool hasEnergy = ( (word >> 30 ) & 0x1 );
bool hasDualTrace = ( (word >> 31 ) & 0x1 ); hasDualTrace = ( (word >> 31 ) & 0x1 );
if( verbose >= 2 ) { if( verbose >= 2 ) {
printf("dualTrace : %d, Energy : %d, Time: %d, Wave : %d, Extra2: %d \n", 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); if( verbose >= 2 ) printf("=========== nEvents : %d \n", nEvents);
}else{ }else{
if( verbose >= 2 ) printf("does not has format info. unable to read buffer.\n"); if( verbose >= 2 ) printf("does not has format info. unable to read buffer.\n");
return -1; return 0;
} }
///========== decode an event ///========== decode an event
@ -238,17 +289,38 @@ inline int Data::DecodePHADualChannelBlock(unsigned int nWord, unsigned int Chan
int channel = ChannelMask*2 + channelTag; int channel = ChannelMask*2 + channelTag;
if( verbose >= 2 ) printf("ch : %d, timeStamp0 %u \n", channel, timeStamp0); if( verbose >= 2 ) printf("ch : %d, timeStamp0 %u \n", channel, timeStamp0);
NumEvents[channel] ++;
//TODO Skip
///===== read waveform ///===== read waveform
if( SaveWaveformToMemory ) {
tempWaveform1.clear();
tempWaveform2.clear();
tempDigiWaveform1.clear();
}
unsigned int triggerAtSample = 0 ; unsigned int triggerAtSample = 0 ;
for( int wi = 0; wi < nSample/2; wi++){ for( int wi = 0; wi < nSample/2; wi++){
nw = nw +1 ; word = ReadBuffer(nw, verbose - 2); nw = nw +1 ; word = ReadBuffer(nw, verbose - 2);
bool isTrigger1 = (( word >> 31 ) & 0x1 ); bool isTrigger1 = (( word >> 31 ) & 0x1 );
bool dp1 = (( word >> 30 ) & 0x1 ); bool dp1 = (( word >> 30 ) & 0x1 );
unsigned int wave1 = (( word >> 16) & 0x3FFF); unsigned short wave1 = (( word >> 16) & 0x3FFF);
bool isTrigger0 = (( word >> 15 ) & 0x1 ); bool isTrigger0 = (( word >> 15 ) & 0x1 );
bool dp0 = (( word >> 14 ) & 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( isTrigger0 == 1 ) triggerAtSample = 2*wi ;
if( isTrigger1 == 1 ) triggerAtSample = 2*wi + 1; 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); nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra2 = word; unsigned int extra2 = word;
unsigned long long extTimeStamp = 0; 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", if( verbose >= 1 ) printf("%4d | ch : %2d, PileUp : %d , energy : %d, roll-Over: %d, timestamp : %llu, triggerAt : %d, nSample : %d\n",
channel, pileUp, energy, rollOver, timeStamp, triggerAtSample); 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; return nw;
} }
inline int Data::DecodePSDDualChannelBlock(unsigned int nWord, unsigned int ChannelMask, int verbose){ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose){
int nw = nWord;
nw = nw + 1;
unsigned int word = ReadBuffer(nw, verbose); unsigned int word = ReadBuffer(nw, verbose);
if( (word >> 31) != 1 ) return -1; if( (word >> 31) != 1 ) return 0;
unsigned int aggSize = ( word & 0x3FFFFF ) ; unsigned int aggSize = ( word & 0x3FFFFF ) ;
if( verbose >= 2 ) printf(" size : %d \n", aggSize); 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; int channel = ChannelMask*2 + channelTag;
if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp0); if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp0);
NumEvents[channel] ++;
///===== read waveform ///===== read waveform
if( SaveWaveformToMemory ) {
tempWaveform1.clear();
tempWaveform2.clear();
tempDigiWaveform1.clear();
tempDigiWaveform2.clear();
}
for( int wi = 0; wi < nSample/2; wi++){ for( int wi = 0; wi < nSample/2; wi++){
nw = nw +1 ; word = ReadBuffer(nw, verbose - 2); nw = nw +1 ; word = ReadBuffer(nw, verbose - 2);
bool dp2b = (( word >> 31 ) & 0x1 ); bool dp2b = (( word >> 31 ) & 0x1 );
bool dp1b = (( word >> 30 ) & 0x1 ); bool dp1b = (( word >> 30 ) & 0x1 );
unsigned int waveb = (( word >> 16) & 0x3FFF); unsigned short waveb = (( word >> 16) & 0x3FFF);
bool dp2a = (( word >> 15 ) & 0x1 ); bool dp2a = (( word >> 15 ) & 0x1 );
bool dp1a = (( word >> 14 ) & 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 ){ if( verbose >= 3 && ev == 0 ){
printf("%4d| %5d, %d, %d \n", 2*wi, wavea, dp1a, dp2a); 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); nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra = word; unsigned int extra = word;
unsigned long long extTimeStamp = 0; 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", if( verbose >= 1 ) printf("ch : %2d, Qshort : %d, Qlong : %d, timestamp : %llu\n",
channel, Qshort, Qlong, timeStamp); channel, Qshort, Qlong, timeStamp);
Timestamp[channel][NumEvents[channel]] = timeStamp;
} }
///=========== Key information ///=========== Key information

View File

@ -40,7 +40,6 @@ Digitizer::~Digitizer(){
CloseDigitizer(); CloseDigitizer();
delete data; delete data;
///delete settingFile; /// not needed, settingFile open and close at everytime
} }
void Digitizer::Reset(){ void Digitizer::Reset(){

View File

@ -35,12 +35,12 @@ int DigitizerPHA::ProgramBoard(){
printf("======== program Channels\n"); printf("======== program Channels\n");
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::DecayTime + 0x7000 , 5000 ); 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::TrapezoidRiseTime + 0x7000 , 6 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::PeakingTime + 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::RCCR2SmoothingFactor + 0x7000 , 4 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::InputRiseTime + 0x7000 , 6 ); 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::PeakHoldOff + 0x7000 , 0x3E );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PHA::TriggerHoldOffWidth + 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::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::ChannelDCOffset + 0x7000 , 0xEEEE );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PreTrigger + 0x7000 , 124 ); 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::AggregateOrganization, 0);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlockTransfer, 40);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f);

View File

@ -23,7 +23,7 @@ enum MenuIdentifiers{
M_DIGITIZER_SCAN, M_DIGITIZER_SCAN,
M_FILE_OPEN, M_FILE_OPEN,
M_EXIT, M_EXIT,
M_CH_SETTINGS_SUMMARY, M_TRIGGER_SUMMARY,
M_CH_SETTING, M_CH_SETTING,
M_BOARD_SETTINGS, M_BOARD_SETTINGS,
M_PROGRAM_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); fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame);
fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
fMenuFile = new TGPopupMenu(gClient->GetRoot()); fMenuFile = new TGPopupMenu(gClient->GetRoot());
fMenuFile->AddEntry("&Scan Digitizers", M_DIGITIZER_SCAN);
fMenuFile->AddEntry("&Open File", M_FILE_OPEN); fMenuFile->AddEntry("&Open File", M_FILE_OPEN);
fMenuFile->AddSeparator(); fMenuFile->AddSeparator();
fMenuFile->AddEntry("E&xit", M_EXIT); fMenuFile->AddEntry("E&xit", M_EXIT);
fMenuFile->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuFile->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fMenuSettings = new TGPopupMenu(gClient->GetRoot()); fMenuDigitizers = new TGPopupMenu(gClient->GetRoot());
fMenuSettings->AddEntry("&Settings Summary", M_CH_SETTINGS_SUMMARY); fMenuDigitizers->AddEntry("Scan &Digitizers", M_DIGITIZER_SCAN);
fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING); fMenuDigitizers->AddEntry("&Trigger Summary", M_TRIGGER_SUMMARY);
fMenuSettings->AddSeparator(); fMenuDigitizers->AddSeparator();
fMenuSettings->AddEntry("&Digitizer Settings", M_BOARD_SETTINGS); fMenuDigitizers->AddEntry("Digitizer &Settings", M_BOARD_SETTINGS);
fMenuSettings->AddSeparator(); fMenuDigitizers->AddEntry("&Channel Settings", M_CH_SETTING);
fMenuSettings->AddEntry("Program Settings", M_PROGRAM_SETTINGS); fMenuDigitizers->AddSeparator();
fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuDigitizers->AddEntry("&Program Settings", M_PROGRAM_SETTINGS);
fMenuBar->AddPopup("&Settings", fMenuSettings, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); 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 = new TGPopupMenu(gClient->GetRoot());
fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE); fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE);
fMenuSettings->AddSeparator(); fMenuDigitizers->AddSeparator();
fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS); fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS);
fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); 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."); LogMsg("Ready to run.");
HandleMenu(M_BOARD_SETTINGS); HandleMenu(M_BOARD_SETTINGS);
HandleMenu(M_CH_SETTING);
} }
MainWindow::~MainWindow() { MainWindow::~MainWindow() {
delete fMenuBar; delete fMenuBar;
delete fMenuFile; delete fMenuFile;
delete fMenuSettings; delete fMenuDigitizers;
delete fMenuUtility; delete fMenuUtility;
//delete boardIDEntry; //delete boardIDEntry;
@ -183,7 +185,7 @@ void MainWindow::HandleMenu(Int_t id){
case M_EXIT: GoodBye(); break; case M_EXIT: GoodBye(); break;
///========================= Channel setting summary ///========================= Channel setting summary
case M_CH_SETTINGS_SUMMARY: { case M_TRIGGER_SUMMARY: {
}break; }break;

View File

@ -32,7 +32,7 @@ private:
static TRootEmbeddedCanvas *fEcanvas; static TRootEmbeddedCanvas *fEcanvas;
TGMenuBar *fMenuBar; TGMenuBar *fMenuBar;
TGPopupMenu *fMenuFile, *fMenuSettings, *fMenuUtility; TGPopupMenu *fMenuFile, *fMenuDigitizers, *fMenuUtility;
//static TGNumberEntry * boardIDEntry, *chEntry; //static TGNumberEntry * boardIDEntry, *chEntry;
//TGNumberEntry * runIDEntry; //TGNumberEntry * runIDEntry;

View File

@ -11,24 +11,53 @@
#include "channelSetting.h" #include "channelSetting.h"
//TODO set MAX //TODO set MAX
///---------------------------------------------- NAME, DIGI, unit ... MAX ///------------------------------------------------ NAME, DIGI, unit ... MAX
TString settingName[NUM_CHANNEL_SETTING][3] = {{"TRIGGER_RISETIME", "2", "us"}, TString settingName[NUM_CHANNEL_SETTING][3] = {{"Record Length", "3", "us"},
{"TRIGGER_FLATTOP", "2", "us"}, {"Input Dynamic Range", "1", ""},
{"TRIGGER_THRESHOLD", "0", "ADC"}, {"Events / Aggregate", "4", ""},
{"ENERGY_RISETIME", "1", "us"}, {"Pre-Trigger Length", "3", "us"},
{"ENERGY_FLATTOP", "1", "us"}, {"Trigger Threshold", "5", "LSD"},
{"TAU", "2", "us"}, {"Trigger Holdoff Width", "3", "us"},
{"TRACE_LENGTH", "2", "us"}, {"DPP Algorithm Control", "8", ""},
{"TRACE_DELAY", "2", "us"}, {"Channel DC offset", "2", "%"},
{"VOFFSET", "2", "V"}, {"Temperature", "2", "C"},
{"XDT", "2", "us"}, {"Veto Width", "3", "us"},
{"BASELINE_PERCENT", "0", "%"}, {"Trigger Filter Smoothing", "3", "smp"},
{"BASELINE_AVERAGE", "0", ""}, {"Input Rising Time", "3", "ns"},
{"BLCUT", "0", ""}, {"Trapezoid Rise Time", "4", "ns"},
{"EMIN", "0", ""}, {"Trapezoid Flat Top", "4", "ns"},
{"MultiplicityMaskL", "0", ""}, {"Peaking Time", "4", "ns"},
{"MultiplicityMaskH", "0", ""}, {"Decay Time", "4", "us"},
{"CHANNEL_CSRA", "0", ""}}; {"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){ 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"); TGLabel * lbPol = new TGLabel(hframePol, "Polarity");
hframePol->AddFrame(lbPol, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); hframePol->AddFrame(lbPol, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4));
///----- all other ///----- all other
TGHorizontalFrame *hframe[NUM_CHANNEL_SETTING]; TGHorizontalFrame *hframe[NUM_CHANNEL_SETTING];
TGLabel * lb[NUM_CHANNEL_SETTING]; TGLabel * lb[NUM_CHANNEL_SETTING];

View File

@ -8,7 +8,7 @@
#include "ClassDigitizer.h" #include "ClassDigitizer.h"
#include "macro.h" #include "macro.h"
#define NUM_CHANNEL_SETTING 17 #define NUM_CHANNEL_SETTING 21
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;

View File

@ -5,46 +5,50 @@
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
/************** /**************/
const int nBoard = 1; const int nBoard = 1;
DigitizerPHA *dig = new DigitizerPHA[nBoard]; Digitizer **dig = new Digitizer *[nBoard];
//DigitizerPSD * psd = new DigitizerPSD();
for( int i = 0 ; i < nBoard; i++){ for( int i = 0 ; i < nBoard; i++){
int board = i % 3; int board = i % 3;
int port = i/3; int port = i/3;
dig[i].OpenDigitizer(board, port, true); dig[i] = new DigitizerPHA(board, port);
dig[i].CreateAndSaveSettingBinary("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"); //dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
} }
dig[0].PrintBoardConfiguration(); DigitizerPHA * pha = dynamic_cast<DigitizerPHA*> (dig[0]);
dig[0].PrintChannelSettingFromDigitizer(4); pha->ProgramBoard();
pha->PrintBoardConfiguration();
pha->PrintChannelSettingFromDigitizer(0);
pha->PrintChannelSettingFromDigitizer(15);
remove("test.bin");
Data * data = dig[0].data; Data * data = pha->GetData();
data->AllocateMemory(); data->AllocateMemory();
dig[0].StartACQ(); pha->StartACQ();
for( int p = 0; p < 11; p++){ for( int p = 0; p < 100; p++){
sleep(1); sleep(1);
dig[0].ReadData(); pha->ReadData();
data->SaveBuffer("test.bin");
data->DecodeBuffer(1); data->DecodeBuffer(1);
data->ClearData();
} }
dig[0].StopACQ(); pha->StopACQ();
delete pha;
//delete [] dig;
delete [] dig; /*********************/
//delete psd;
*********************/
///********************* method for using Data Class for decoding bin file ///********************* method for using Data Class for decoding bin file
/**
FILE * haha = fopen("output.bin", "r"); FILE * haha = fopen("output.bin", "r");
fseek(haha, 0L, SEEK_END); fseek(haha, 0L, SEEK_END);
size_t inFileSize = ftell(haha); size_t inFileSize = ftell(haha);