now have proper energy. testing timestamp roll over

This commit is contained in:
carina@hades 2022-08-18 17:34:28 -04:00
parent b2b5c75bb3
commit c5fd1b1f65
5 changed files with 223 additions and 224 deletions

View File

@ -62,40 +62,44 @@ class Data{
printf("======= Free memory, not impletment yet \n"); printf("======= Free memory, not impletment yet \n");
} }
void ReadAllBuffer(){ void ReadAllBuffer(int verbose = 0){
/// verbose : 0 = off, 1 = only energy + timestamp, 2 = show header, 3 = wave
if( buffer == NULL ) return; if( buffer == NULL ) return;
unsigned int nw = 0; unsigned int nw = 0;
do{ do{
printf("#########################################\n"); if( verbose >= 2 ) printf("######################################### Board Agg.\n");
unsigned int word = ReadBuffer(nw); unsigned int word = ReadBuffer(nw, verbose);
if( ( (word >> 28) & 0xF ) == 0xA ) { /// start of Board Agg if( ( (word >> 28) & 0xF ) == 0xA ) { /// start of Board Agg
unsigned int nWord = word & 0x0FFFFFFF ; unsigned int nWord = word & 0x0FFFFFFF ;
printf(" number of words in this Agg : %d \n", nWord); if( verbose >= 2 ) printf(" number of words in this Agg : %d \n", nWord);
nw = nw + 1; word = ReadBuffer(nw); nw = nw + 1; word = ReadBuffer(nw, verbose);
unsigned int BoardID = ((word >> 27) & 0x1F); unsigned int BoardID = ((word >> 27) & 0x1F);
bool BoardFailFlag = ((word >> 26) & 0x1 ); bool BoardFailFlag = ((word >> 26) & 0x1 );
unsigned int ChannelMask = ( word & 0xFF ) ; unsigned int ChannelMask = ( word & 0xFF ) ;
printf("Board ID : %d, FailFlag = %d, ChannelMask = 0x%x\n", BoardID, BoardFailFlag, ChannelMask); if( verbose >= 2 ) printf("Board ID : %d, FailFlag = %d, ChannelMask = 0x%x\n", BoardID, BoardFailFlag, ChannelMask);
nw = nw + 2; nw = nw + 2;
unsigned int AggCounter = ReadBuffer(nw); unsigned int AggCounter = ReadBuffer(nw, verbose);
printf("Agg Counter : %d \n", AggCounter); if( verbose >= 2 ) printf("Agg Counter : %d \n", AggCounter);
printf("----------------------\n");
nw = nw + 1;
do{ for( int chMask = 0; chMask < 8 ; chMask ++ ){
word = ReadBuffer(nw); if( ((ChannelMask >> chMask) & 0x1 ) == 0 ) continue;
if( verbose >= 2 ) printf("---------------------- Dual Channel Block : %d\n", chMask *2 );
nw = nw + 1; word = ReadBuffer(nw, verbose);
bool hasFormatInfo = ((word >> 31) & 0x1); bool hasFormatInfo = ((word >> 31) & 0x1);
unsigned int aggSize = ( word & 0x3FFFFFF ) ; unsigned int aggSize = ( word & 0x3FFFFFF ) ;
printf(" size : %d \n", aggSize); if( verbose >= 2 ) printf(" size : %d \n", aggSize);
unsigned int nSample = 0; /// wave form; unsigned int nSample = 0; /// wave form;
unsigned int nEvents = 0; unsigned int nEvents = 0;
if( hasFormatInfo ){ if( hasFormatInfo ){
nw = nw + 1; word = ReadBuffer(nw); nw = nw + 1; word = ReadBuffer(nw, verbose);
nSample = ( word & 0xFFFF ) * 8; nSample = ( word & 0xFFFF ) * 8;
unsigned int digitalProbe = ( (word >> 16 ) & 0xF ); unsigned int digitalProbe = ( (word >> 16 ) & 0xF );
unsigned int analogProbe2 = ( (word >> 20 ) & 0x3 ); unsigned int analogProbe2 = ( (word >> 20 ) & 0x3 );
@ -107,68 +111,70 @@ class Data{
bool hasEnergy = ( (word >> 30 ) & 0x1 ); bool hasEnergy = ( (word >> 30 ) & 0x1 );
bool hasDualTrace = ( (word >> 31 ) & 0x1 ); bool hasDualTrace = ( (word >> 31 ) & 0x1 );
printf("dualTrace : %d, Energy : %d, Time: %d, Wave : %d, Extra2: %d, Extra2Option: %d \n", if( verbose >= 2 ) printf("dualTrace : %d, Energy : %d, Time: %d, Wave : %d, Extra2: %d, Extra2Option: %d \n",
hasDualTrace, hasEnergy, hasTimeStamp, hasWaveForm, hasExtra2, extra2Option); hasDualTrace, hasEnergy, hasTimeStamp, hasWaveForm, hasExtra2, extra2Option);
printf("Ana Probe 1 & 2: %d %d , Digi Probe: %d, nSample : %d \n", if( verbose >= 2 ) printf("Ana Probe 1 & 2: %d %d , Digi Probe: %d, nSample : %d \n",
analogProbe1, analogProbe2, digitalProbe, nSample); analogProbe1, analogProbe2, digitalProbe, nSample);
nEvents = aggSize / (nSample/2 + 2 + hasExtra2 ); nEvents = aggSize / (nSample/2 + 2 + hasExtra2 );
printf("=========== nEvents : %d \n", nEvents); if( verbose >= 2 ) printf("=========== nEvents : %d \n", nEvents);
}else{ }else{
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");
break; break;
} }
for( int ev = 0; ev < nEvents ; ev++){ for( int ev = 0; ev < nEvents ; ev++){
printf("=================================== event : %d\n", ev); if( verbose >= 2 ) printf("=================================== event : %d\n", ev);
nw = nw +1 ; word = ReadBuffer(nw); nw = nw +1 ; word = ReadBuffer(nw, verbose);
bool channelTag = ((word >> 31) & 0x1); bool channelTag = ((word >> 31) & 0x1);
unsigned int timeStamp = (word & 0x7FFFFFFF); unsigned int timeStamp = (word & 0x7FFFFFFF);
int channel = log(ChannelMask)/log(2) *2 + channelTag; int channel = chMask*2 + channelTag;
printf("ch : %d, timeStamp %u \n", channel, timeStamp); if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp);
///===== read waveform ///===== read waveform
for( int wi = 0; wi < nSample/2; wi++){ for( int wi = 0; wi < nSample/2; wi++){
nw = nw +1 ; word = ReadBuffer(nw, false); nw = nw +1 ; word = ReadBuffer(nw, verbose - 2);
bool isTrigger1 = (( word >> 31 ) & 0x1 ); bool isTrigger1 = (( word >> 31 ) & 0x1 );
unsigned int wave1 = (( word >> 16) & 0x3FFF); unsigned int wave1 = (( word >> 16) & 0x3FFF);
bool isTrigger0 = (( word >> 15 ) & 0x1 ); bool isTrigger0 = (( word >> 15 ) & 0x1 );
unsigned int wave0 = ( word & 0x3FFF); unsigned int wave0 = ( word & 0x3FFF);
if( ev == 0 ){ if( verbose >= 3 && ev == 0 ){
printf(" %5d, %d \n", wave0, isTrigger0); printf("%4d| %5d, %d \n", 2*wi, wave0, isTrigger0);
printf(" %5d, %d \n", wave1, isTrigger1); printf("%4d| %5d, %d \n", 2*wi+1, wave1, isTrigger1);
} }
} }
nw = nw +1 ; word = ReadBuffer(nw); nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra2 = word; unsigned int extra2 = word;
nw = nw +1 ; word = ReadBuffer(nw); nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra = (( word >> 16) & 0x3FF); unsigned int extra = (( word >> 16) & 0x3FF);
unsigned int energy = (word & 0x7FFF); unsigned int energy = (word & 0x7FFF);
bool pileUp = ((word >> 15) & 0x1); bool pileUp = ((word >> 15) & 0x1);
printf("PileUp : %d , extra : 0x%4x, energy : %d \n", pileUp, extra, energy); if( verbose >= 2 ) printf("PileUp : %d , extra : 0x%04x, energy : %d \n", pileUp, extra, energy);
if( verbose >= 1 ) printf("ch : %2d, PileUp : %d , energy : %d, timestamp : %u\n",
channel, pileUp, energy, timeStamp);
} }
}
nw ++;
}while( nw < nWord);
}else{ }else{
printf("incorrect buffer header. \n"); if( verbose >= 2 ) printf("incorrect buffer header. \n");
break; break;
} }
nw++;
}while(true); }while(true);
} }
unsigned int ReadBuffer(unsigned int nWord, bool verbose = true){ unsigned int ReadBuffer(unsigned int nWord, int verbose = 0){
if( buffer == NULL ) return 0; if( buffer == NULL ) return 0;
unsigned int word = 0; unsigned int word = 0;
for( int i = 0 ; i < 4 ; i++) word += ((buffer[i + 4 * nWord] & 0xFF) << 8*i); for( int i = 0 ; i < 4 ; i++) word += ((buffer[i + 4 * nWord] & 0xFF) << 8*i);
if( verbose) printf("%d | 0x%08x\n", nWord, word); if( verbose >= 2) printf("%d | 0x%08x\n", nWord, word);
return word; return word;
} }

View File

@ -364,12 +364,12 @@ void Digitizer::ReadData(){
return; return;
} }
//ret = CAEN_DGTZ_ReadData(handle, CAEN_DGTZ_SLAVE_TERMINATED_READOUT_MBLT, data->buffer, &(data->nByte)); ret = CAEN_DGTZ_ReadData(handle, CAEN_DGTZ_SLAVE_TERMINATED_READOUT_MBLT, data->buffer, &(data->nByte));
//printf("Read Buffer size %d byte \n", data->nByte); printf("Read Buffer size %d byte \n", data->nByte);
//if (ret || data->nByte == 0) { if (ret || data->nByte == 0) {
// ErrorMsg("ReadData"); ErrorMsg("ReadData");
// return; return;
//} }
ret = (CAEN_DGTZ_ErrorCode) CAEN_DGTZ_GetDPPEvents(handle, data->buffer, data->BufferSize, reinterpret_cast<void**>(&(data->Events)), data->NumEvents); ret = (CAEN_DGTZ_ErrorCode) CAEN_DGTZ_GetDPPEvents(handle, data->buffer, data->BufferSize, reinterpret_cast<void**>(&(data->Events)), data->NumEvents);
for( int i = 0 ; i < MaxNChannels; i++){ for( int i = 0 ; i < MaxNChannels; i++){

View File

@ -13,146 +13,56 @@ DigitizerPHA::~DigitizerPHA(){
} }
int DigitizerPHA::ProgramBoard(){ int DigitizerPHA::ProgramBoard(){
Digitizer::ProgramBoard();
printf("----- program PHA\n"); ret = CAEN_DGTZ_Reset(handle);
/// Set trigger propagation printf("======== program board\n");
/// Set analog probe 1 to input
/// Set analog probe 2 to Tranpedoiz - Baseline ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 625);
/// disable waveform recording if( ret != 0 ) { printf("==== set Record Length.\n"); return 0;}
/// enable extrac 2 word
/// record time stamp ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x4E8115);
/// record energy
/// digitial virtual probe 1 = Peaking ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
/// digitial virtual probe 2 = trigger
///ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration , 0x000F8114); ret |= CAEN_DGTZ_SetIOLevel(handle, CAEN_DGTZ_IOLevel_NIM);
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration , 0x014F8905);
ErrorMsg("PHA-ProgramBoard"); ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY);
if( ret != 0 ) { printf("==== CAEN_DGTZ_SetExtTriggerInputMode.\n"); return 0;}
ret = CAEN_DGTZ_SetChannelEnableMask(handle, 0xFFFF);
if( ret != 0 ) { printf("==== CAEN_DGTZ_SetChannelEnableMask.\n"); return 0;}
ret = CAEN_DGTZ_SetNumEventsPerAggregate(handle, 0);
if( ret != 0 ) { printf("==== CAEN_DGTZ_SetNumEventsPerAggregate. %d\n", ret); return 0;}
ret = CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
if( ret != 0 ) { printf("==== set board error.\n"); return 0;}
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::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::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 );
///==================== Set default Channel setting using CAEN function ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PreTrigger + 0x7000 , 124 );
CAEN_DGTZ_DPP_PHA_Params_t DPPParams; ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::InputDynamicRange + 0x7000 , 0x0 );
memset(&DPPParams, 0, sizeof(CAEN_DGTZ_DPP_PHA_Params_t));
for(int i = 0; i < NChannel; i++){ ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5);
DPPParams.M[i] = 100000; /// decay time [ns] ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0);
DPPParams.m[i] = 992; /// flat-top [ns] ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlackTransfer, 40);
DPPParams.k[i] = 96; /// rise-time [ns] ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f);
DPPParams.ftd[i] = 192; /// flat-top delay, peaking time [ns]
DPPParams.a[i] = 4; /// Trigger Filter smoothing factor, 1, 2, 3, 4, 16, 32
DPPParams.b[i] = 96; /// input rise time [ns]
DPPParams.thr[i] = 100; /// Threshold [LSB]
DPPParams.nsbl[i] = 3; /// Baseline samples, 0 = 0, when > 0, pow(4, n+1)
DPPParams.nspk[i] = 2; /// peak samples, 4^n
DPPParams.pkho[i] = 992 ; /// peak hold off [ns]
DPPParams.trgho[i] = 480 ; /// trigger hold off [ns]
DPPParams.twwdt[i] = 0 ; /// rise time validation window, 0x1070
DPPParams.trgwin[i] = 0 ; /// trigger coincident window
DPPParams.dgain[i] = 0; /// digial gain for digial probe, 2^n
DPPParams.enf[i] = 1 ; /// energy normalization factor (fine gain?)
DPPParams.decimation[i] = 0 ; /// waveform decimation, 2^n, when n = 0, disable
DPPParams.blho[i] = 0; /// not use
}
ret = CAEN_DGTZ_SetDPPParameters(handle, channelMask, &DPPParams); if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
ErrorMsg("PHA-CAEN_DGTZ_SetDPPParameters");
for(int i=0; i<NChannel; i++) {
if (channelMask & (1<<i)) {
/// Set a DC offset to the input signal to adapt it to digitizer's dynamic range
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, i, 0xCCCC); /// 20%
/// Set the Pre-Trigger size (in samples)
ret |= CAEN_DGTZ_SetDPPPreTriggerSize(handle, i, 124); /// 496ns
/// Set the polarity for the given channel (CAEN_DGTZ_PulsePolarityPositive or CAEN_DGTZ_PulsePolarityNegative)
ret |= CAEN_DGTZ_SetChannelPulsePolarity(handle, i, CAEN_DGTZ_PulsePolarityPositive);
/// Set InputDynamic Range
ret |= CAEN_DGTZ_WriteRegister(handle, 0x1028 + (i<<8), 0x0); /// 2.0 Vpp
/// read the register to check the input is correct
///uint32_t * value = new uint32_t[8];
///ret = CAEN_DGTZ_ReadRegister(handle, 0x1028 + (i << 8), value);
///printf(" InputDynamic Range (ch:%d): %d \n", i, value[0]);
}
}
/**************/
//ret = CAEN_DGTZ_MallocReadoutBuffer(handle, &(data->buffer), &(data->AllocatedSize));
//ret |= CAEN_DGTZ_MallocDPPEvents(handle, reinterpret_cast<void**>(&(data->Events)), &(data->AllocatedSize)) ;
//WriteRegister(Register::DPP::RecordLength_G, 0x138);
//WriteRegister(Register::DPP::InputDynamicRange, 0x0);
//WriteRegister(Register::DPP::NumberEventsPerAggregate_G, 0x1A);
//WriteRegister(Register::DPP::PreTrigger, 0x1F);
//
//WriteRegister(Register::DPP::PHA::RCCR2SmoothingFactor, 0x2);
//WriteRegister(Register::DPP::PHA::InputRiseTime, 0x6);
//WriteRegister(Register::DPP::PHA::TrapezoidRiseTime, 0x6);
//WriteRegister(Register::DPP::PHA::TrapezoidFlatTop, 0x3E);
//WriteRegister(Register::DPP::PHA::PeakingTime, 0xC);
//WriteRegister(Register::DPP::PHA::DecayTime, 0x186A);
//WriteRegister(Register::DPP::PHA::TriggerThreshold, 0x64);
//WriteRegister(Register::DPP::PHA::RiseTimeValidationWindow, 0x0);
//WriteRegister(Register::DPP::PHA::TriggerHoldOffWidth, 0x1E);
//WriteRegister(Register::DPP::PHA::PeakHoldOff, 0x3E);
//WriteRegister(Register::DPP::DPPAlgorithmControl, 0x0C30200F);
//WriteRegister(Register::DPP::PHA::ShapedTriggerWidth, 0x6);
//WriteRegister(Register::DPP::ChannelDCOffset, 0xCCCC);
//WriteRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, 0x0);
//WriteRegister(Register::DPP::PHA::FineGain, 0xDFB1);
//WriteRegister(Register::DPP::VetoWidth, 0xA);
//
//
//WriteRegister(Register::DPP::BoardConfiguration, 0x14F8905);
//WriteRegister(Register::DPP::AggregateOrganization, 0x2);
//WriteRegister(Register::DPP::AcquisitionControl, 0x0);
//WriteRegister(Register::DPP::GlobalTriggerMask, 0x80000000);
//WriteRegister(Register::DPP::ReadoutControl, 0x10);
SetRecordLength(4096*4);
SetPreTriggerDuration(1000*4);
SetBaselineSampling(3);
SetDCOffset(0.2);
SetInputDynamicRange(0);
SetPulsePolarity(0);
SetTriggerThreshold(400);
SetTriggerHoldOff(248);
SetTriggerSmoothingFactor(2);
SetTriggerOutputWidth(6);
SetInputRiseTime(6);
//SetTrapezoidRescaling(23);
SetTrapezoidRiseTime(31);
SetTrapezoidFlatTop(31);
SetDecayTime(312);
SetPeakingTime(3);
SetPeakingHoldOff(25);
SetPeakSampling(8);
SetRiseTimeValidWindow(0);
SetTrapezoidRescaling(13);
SetEnergyFineGain(30000);
//AutoSetTrapezoidRescalingAndFindGate(1.0);
//SetDPPAlgorithmControl(0xC30200E);
//SetEnergyFineGain(0xDFB1);
SetEventAggregation(2); /// max 511
SetMaxNumberOfAggregatePerBlackTransfer(4);
SetAggregateOrganization(0); ///0 or 1 = no division in buffer, n = 2^n divsions
SetRollOverFlag(1);
SetPileUpFlag(1);
SetExtra2WordOption(2);
ErrorMsg("PHA-ProgramBoard");
printf("End of program board and channels\n"); printf("End of program board and channels\n");
return ret; return ret;
@ -227,35 +137,52 @@ void DigitizerPHA::PrintBoardConfiguration(){
printf(" | | | | | | | | |\n"); printf(" | | | | | | | | |\n");
cout <<" Board Configuration : 0b" << bitset<32>(value[0]) << endl; cout <<" Board Configuration : 0b" << bitset<32>(value[0]) << endl;
printf(" : 0x%x\n", value[0]); printf(" : 0x%x\n", value[0]);
printf(" Bit[ 0] = Auto Data Flush \n");
printf(" Bit[ 1] = Save decimated waveform \n"); printf(" Bit[ 0] = %d = Auto Data Flush \n", value[0] & 0x1);
printf(" Bit[ 2] = Trigger propagation \n"); printf(" Bit[ 1] = %d = Decimated waveform \n", (value[0] >> 1) & 0x1 );
printf(" Bit[ 3:10] = must be 001 0001 0 \n"); printf(" Bit[ 2] = %d = Trigger propagation \n", (value[0] >> 2) & 0x1 );
printf(" Bit[ 11] = Dual Trace \n"); printf(" Bit[ 3:10] = %d = must be 001 0001 0 = 22 \n", (value[0] >> 3) & 0xFF );
printf(" Bit[12:13] = Analog probe 1 : 00 = input, 01 = RC-CR (1st derivative), 10 = RC-CR2 (2nd derivative), 11 = Trapezoid.\n"); printf(" Bit[ 11] = %d = Dual Trace \n", (value[0] >> 11) & 0x1 );
printf(" Bit[14:15] = Analog probe 2 : 00 = input, 01 = Threshold, 10 = Trapezoid - Baseline, 11 = baseline.\n"); printf(" Bit[12:13] = %d = Analog probe 1 : ",((value[0] >> 12) & 0x3 ));
printf(" Bit[ 16] = WaveForm Recording \n"); switch ( ((value[0] >> 12) & 0x3 ) ){
printf(" Bit[ 17] = Extras 2 word enable \n"); case 0 : printf("input\n"); break;
printf(" Bit[ 18] = Record Time Stamp \n"); case 1 : printf("RC-CR (1st derivative)\n");break;
printf(" Bit[ 19] = Record Energy \n"); case 2 : printf("RC-CR2 (2nd derivative)\n"); break;
printf(" Bit[20:23] = Digital Virtual probe 1 : \n"); case 3 : printf("Trapezoid \n"); break;
printf(" 0000: Peaking, shows where the energy is calculated; \n"); }
printf(" 0001: ”Armed”, digital input showing where the RCCR2 crosses the Threshold\n"); printf(" Bit[14:15] = %d = Analog probe 2 : ", ((value[0] >> 14) & 0x3 ));
printf(" 0010: ”Peak Run”, starts with the trigger and last for the whole event\n"); switch ( ((value[0] >> 14) & 0x3 ) ){
printf(" 0011: ”Pileup”, shows where a pileup event occurred\n"); case 0 : printf("input\n"); break;
printf(" 0100: ”Peaking”, shows where the energy is calculated\n"); case 1 : printf("Threshold\n"); break;
printf(" 0101: ”TRG Validation Win”, digital input showing the trigger validation acceptance window TVAW\n"); case 2 : printf("Trapezoid - Baseline\n"); break;
printf(" 0110: ”Baseline freeze”, shows where the algorithm stops calculating the baseline and its value is frozen\n"); case 3 : printf("baseline.\n"); break;
printf(" 0111: ”TRG Holdoff”, shows the trigger holdoff parameter\n"); }
printf(" 1000: ”TRG Validation”, shows the trigger validation signal TRG_VAL \n"); printf(" Bit[ 16] = %d = WaveForm Recording \n",((value[0] >> 16) & 0x1 ) );
printf(" 1001: ”Acq Busy”, this is 1 when the board is busy (saturated input signal or full memory board) or there is a veto\n"); printf(" Bit[ 17] = %d = Extras 2 word enable \n", ((value[0] >> 17) & 0x1 ));
printf(" 1010: ”Zero Cross. Win.”, shows the RT Discrimination Width\n"); printf(" Bit[ 18] = %d = Record Time Stamp \n", ((value[0] >> 18) & 0x1 ));
printf(" 1011: ”Ext TRG”, shows the external trigger, when available\n"); printf(" Bit[ 19] = %d = Record Energy \n", ((value[0] >> 19) & 0x1 ));
printf(" 1100: ”Busy”, shows when the memory board is full.\n"); printf(" Bit[20:23] = %d = Digital Virtual probe 1 : ", ((value[0] >> 20) & 0x7 ));
printf(" Bit[26:28] = Digital Virtual probe 2 : \n"); switch (((value[0] >> 20) & 0xF )) {
printf(" 000: Trigger\n"); case 0: printf("Peaking, shows where the energy is calculated; \n"); break;
printf(" other: Reserved\n"); case 1: printf("”Armed”, digital input showing where the RCCR2 crosses the Threshold\n");
printf("====================================== \n"); case 2: printf("”Peak Run”, starts with the trigger and last for the whole event\n");
case 3: printf("”Pileup”, shows where a pileup event occurred\n");
case 4: printf("”Peaking”, shows where the energy is calculated\n");
case 5: printf("”TRG Validation Win”, digital input showing the trigger validation acceptance window TVAW\n");
case 6: printf("”Baseline freeze”, shows where the algorithm stops calculating the baseline and its value is frozen\n");
case 7: printf("”TRG Holdoff”, shows the trigger holdoff parameter\n");
case 8: printf("”TRG Validation”, shows the trigger validation signal TRG_VAL \n");
case 9: printf("”Acq Busy”, this is 1 when the board is busy (saturated input signal or full memory board) or there is a veto\n");
case 10: printf("”Zero Cross. Win.”, shows the RT Discrimination Width\n");
case 11: printf("”Ext TRG”, shows the external trigger, when available\n");
case 12: printf("”Busy”, shows when the memory board is full.\n");
}
printf(" Bit[26:28] = %d = Digital Virtual probe 2 : ", ((value[0] >> 26) & 0x7 ));
if( ((value[0] >> 26) & 0x7 ) == 0 ) {
printf("Trigger\n");
}else{
printf("Reserved\n");
}
} }
void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){ void DigitizerPHA::PrintChannelSettingFromDigitizer(int ch){

View File

@ -11,9 +11,10 @@ int main(int argc, char* argv[]){
int board = i % 3; int board = i % 3;
int port = i/3; int port = i/3;
dig[i].OpenDigitizer(board, port, true); dig[i].OpenDigitizer(board, port, true);
dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); dig[i].CreateAndSaveSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
dig[i].SetAcqMode("list"); //dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
dig[i].PrintACQStatue(); //dig[i].SetAcqMode("list");
//dig[i].PrintACQStatue();
} }
//dig[0].WriteRegister(Register::DPP::FrontPanelTRGOUTEnableMask, 0xFF, -1); //dig[0].WriteRegister(Register::DPP::FrontPanelTRGOUTEnableMask, 0xFF, -1);
@ -34,6 +35,8 @@ int main(int argc, char* argv[]){
//dig[0].PrintChannelSettingFromDigitizer(8); //dig[0].PrintChannelSettingFromDigitizer(8);
//dig[0].PrintChannelSettingFromDigitizer(9); //dig[0].PrintChannelSettingFromDigitizer(9);
//dig[0].PrintChannelSettingFromDigitizer(10); //dig[0].PrintChannelSettingFromDigitizer(10);
dig[0].PrintBoardConfiguration();
dig[0].PrintChannelSettingFromDigitizer(4); dig[0].PrintChannelSettingFromDigitizer(4);
//dig[0].ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, 13, "DPP Control 2"); //dig[0].ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, 13, "DPP Control 2");
//dig[0].ReadRegister(Register::DPP::AcquisitionControl, -1, "Acq control"); // [0:1] //dig[0].ReadRegister(Register::DPP::AcquisitionControl, -1, "Acq control"); // [0:1]
@ -43,9 +46,6 @@ int main(int argc, char* argv[]){
//dig[0].ReadRegister(Register::DPP::DisableExternalTrigger, -1, "Disable External Trigger"); //dig[0].ReadRegister(Register::DPP::DisableExternalTrigger, -1, "Disable External Trigger");
//dig[0].ReadRegister(Register::DPP::TriggerValidationMask, -1, "Trigger validation Mask"); //dig[0].ReadRegister(Register::DPP::TriggerValidationMask, -1, "Trigger validation Mask");
//dig[0].PrintChannelSettingFromDigitizer(15); //dig[0].PrintChannelSettingFromDigitizer(15);
Data * data = dig[0].data; Data * data = dig[0].data;
@ -53,15 +53,17 @@ int main(int argc, char* argv[]){
dig[0].StartACQ(); dig[0].StartACQ();
for( int p = 0; p < 11; p++){
sleep(1); sleep(1);
dig[0].ReadData(); dig[0].ReadData();
}
//printf("|%s|\n", data->buffer); //printf("|%s|\n", data->buffer);
dig[0].StopACQ(); dig[0].StopACQ();
data->ReadAllBuffer(); data->ReadAllBuffer(1);
delete [] dig; delete [] dig;
//delete psd; //delete psd;

View File

@ -98,6 +98,65 @@ void PrintChannelSettingFromDigitizer(int handle, int ch, float ch2ns){
} }
void PrintBoardConfiguration(int handle){
printf("\e[33m================================================\n");
printf("================ Setting for Board \n");
printf("================================================\e[0m\n");
uint32_t * value = new uint32_t[1];
CAEN_DGTZ_ReadRegister(handle, (uint32_t) Register::BoardConfiguration, value);
printf(" 32 28 24 20 16 12 8 4 0\n");
printf(" | | | | | | | | |\n");
cout <<" Board Configuration : 0b" << bitset<32>(value[0]) << endl;
printf(" : 0x%x\n", value[0]);
printf(" Bit[ 0] = %d = Auto Data Flush \n", value[0] & 0x1);
printf(" Bit[ 1] = %d = Decimated waveform \n", (value[0] >> 1) & 0x1 );
printf(" Bit[ 2] = %d = Trigger propagation \n", (value[0] >> 2) & 0x1 );
printf(" Bit[ 3:10] = %d = must be 001 0001 0 = 22 \n", (value[0] >> 3) & 0xFF );
printf(" Bit[ 11] = %d = Dual Trace \n", (value[0] >> 11) & 0x1 );
printf(" Bit[12:13] = %d = Analog probe 1 : ",((value[0] >> 12) & 0x3 ));
switch ( ((value[0] >> 12) & 0x3 ) ){
case 0 : printf("input\n"); break;
case 1 : printf("RC-CR (1st derivative)\n");break;
case 2 : printf("RC-CR2 (2nd derivative)\n"); break;
case 3 : printf("Trapezoid \n"); break;
}
printf(" Bit[14:15] = %d = Analog probe 2 : ", ((value[0] >> 14) & 0x3 ));
switch ( ((value[0] >> 14) & 0x3 ) ){
case 0 : printf("input\n"); break;
case 1 : printf("Threshold\n"); break;
case 2 : printf("Trapezoid - Baseline\n"); break;
case 3 : printf("baseline.\n"); break;
}
printf(" Bit[ 16] = %d = WaveForm Recording \n",((value[0] >> 16) & 0x1 ) );
printf(" Bit[ 17] = %d = Extras 2 word enable \n", ((value[0] >> 17) & 0x1 ));
printf(" Bit[ 18] = %d = Record Time Stamp \n", ((value[0] >> 18) & 0x1 ));
printf(" Bit[ 19] = %d = Record Energy \n", ((value[0] >> 19) & 0x1 ));
printf(" Bit[20:23] = %d = Digital Virtual probe 1 : ", ((value[0] >> 20) & 0x7 ));
switch (((value[0] >> 20) & 0xF )) {
case 0: printf("Peaking, shows where the energy is calculated; \n"); break;
case 1: printf("”Armed”, digital input showing where the RCCR2 crosses the Threshold\n");
case 2: printf("”Peak Run”, starts with the trigger and last for the whole event\n");
case 3: printf("”Pileup”, shows where a pileup event occurred\n");
case 4: printf("”Peaking”, shows where the energy is calculated\n");
case 5: printf("”TRG Validation Win”, digital input showing the trigger validation acceptance window TVAW\n");
case 6: printf("”Baseline freeze”, shows where the algorithm stops calculating the baseline and its value is frozen\n");
case 7: printf("”TRG Holdoff”, shows the trigger holdoff parameter\n");
case 8: printf("”TRG Validation”, shows the trigger validation signal TRG_VAL \n");
case 9: printf("”Acq Busy”, this is 1 when the board is busy (saturated input signal or full memory board) or there is a veto\n");
case 10: printf("”Zero Cross. Win.”, shows the RT Discrimination Width\n");
case 11: printf("”Ext TRG”, shows the external trigger, when available\n");
case 12: printf("”Busy”, shows when the memory board is full.\n");
}
printf(" Bit[26:28] = %d = Digital Virtual probe 2 : ", ((value[0] >> 26) & 0x7 ));
if( ((value[0] >> 26) & 0x7 ) == 0 ) {
printf("Trigger\n");
}else{
printf("Reserved\n");
}
printf("====================================== \n");
}
unsigned int ReadBuffer(unsigned int nWord, char * buffer, bool verbose = true){ unsigned int ReadBuffer(unsigned int nWord, char * buffer, bool verbose = true){
if( buffer == NULL ) return 0; if( buffer == NULL ) return 0;
@ -136,15 +195,18 @@ int main(int argc, char* argv[]){
printf("======== program board\n"); printf("======== program board\n");
//ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, CAEN_DGTZ_DPP_ACQ_MODE_List, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime); ///ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, CAEN_DGTZ_DPP_ACQ_MODE_List, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime);
ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, CAEN_DGTZ_DPP_ACQ_MODE_Mixed, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime); ///ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, CAEN_DGTZ_DPP_ACQ_MODE_Mixed, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime); /// Board Configure can do that
ret |= CAEN_DGTZ_WriteRegister(handle, 0x8000, 0x01000114); /// Channel Control Reg (indiv trg, seq readout) ??
/// Set the number of samples for each waveform /// Set the number of samples for each waveform
ret |= CAEN_DGTZ_SetRecordLength(handle, 1000); ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 625);
if( ret != 0 ) { printf("==== set Record Length.\n"); return 0;} if( ret != 0 ) { printf("==== set Record Length.\n"); return 0;}
//ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x4F8115); // with wave
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x4E8115); // with-out wave
/// Set the digitizer acquisition mode (CAEN_DGTZ_SW_CONTROLLED or CAEN_DGTZ_S_IN_CONTROLLED) /// 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_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
@ -216,7 +278,7 @@ int main(int argc, char* argv[]){
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::InputDynamicRange + 0x7000 , 0x0 ); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::InputDynamicRange + 0x7000 , 0x0 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration , 0x10E0114 ); //ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration , 0x10E0114 );
ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 5);
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::MaxNumberOfAggregatePerBlackTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxNumberOfAggregatePerBlackTransfer, 40);
@ -246,6 +308,7 @@ int main(int argc, char* argv[]){
if( ret != 0 ) { printf("==== memory allocation error.\n"); return 0;} if( ret != 0 ) { printf("==== memory allocation error.\n"); return 0;}
PrintBoardConfiguration(handle);
PrintChannelSettingFromDigitizer(handle, 4, ch2ns); PrintChannelSettingFromDigitizer(handle, 4, ch2ns);
printf("============ Start ACQ \n"); printf("============ Start ACQ \n");
@ -324,10 +387,11 @@ int main(int argc, char* argv[]){
unsigned int AggCounter = ReadBuffer(nw, buffer); unsigned int AggCounter = ReadBuffer(nw, buffer);
printf("Agg Counter : %d \n", AggCounter); printf("Agg Counter : %d \n", AggCounter);
printf("---------------------- Dual Channel Block\n");
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;
printf("---------------------- Dual Channel Block : %d\n", chMask *2 );
nw = nw + 1; word = ReadBuffer(nw, buffer); nw = nw + 1; word = ReadBuffer(nw, buffer);
bool hasFormatInfo = ((word >> 31) & 0x1); bool hasFormatInfo = ((word >> 31) & 0x1);
unsigned int aggSize = ( word & 0x3FFFFFF ) ; unsigned int aggSize = ( word & 0x3FFFFFF ) ;
@ -377,8 +441,8 @@ int main(int argc, char* argv[]){
unsigned int wave0 = ( word & 0x3FFF); unsigned int wave0 = ( word & 0x3FFF);
if( ev == 0 ){ if( ev == 0 ){
printf(" %5d, %d \n", wave0, isTrigger0); printf("%4d| %5d, %d \n", 2*wi, wave0, isTrigger0);
printf(" %5d, %d \n", wave1, isTrigger1); printf("%4d| %5d, %d \n", 2*wi+1, wave1, isTrigger1);
} }
} }