add a buffer safe guard for QDC

This commit is contained in:
Ryan Tang 2024-03-20 12:57:54 -04:00
parent b73505695e
commit ecd7ea9afd
2 changed files with 23 additions and 18 deletions

View File

@ -156,17 +156,6 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
} }
} }
uint32_t boardInfo = GetSettingFromMemory(DPP::BoardInfo_R);
uint32_t haha = ((boardInfo >> 8 ) & 0xFF);
printf("------- 0x%08X = %u \n", boardInfo, haha);
switch(haha) {
case 0x01 : MemorySizekSample = 640; break;
case 0x02 : MemorySizekSample = 192; break;
case 0x08 : MemorySizekSample = 5242; break;
case 0x10 : MemorySizekSample = 1536; break;
default: MemorySizekSample = 192; break;
}
///====================== Check DPP firmware revision ///====================== Check DPP firmware revision
sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType); sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType);
data->DPPType = DPPType; data->DPPType = DPPType;
@ -188,6 +177,19 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
/// change address 0xEF08 (5 bits), this will reflected in the 2nd word of the Board Agg. header. /// change address 0xEF08 (5 bits), this will reflected in the 2nd word of the Board Agg. header.
ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardID, (DPPType & 0xF)); ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardID, (DPPType & 0xF));
//TODO somehow the bdInfo does not work, use DPPType to set it
uint32_t bdInfo = GetSettingFromMemory(DPP::BoardInfo_R);
uint32_t haha = ((bdInfo >> 8 ) & 0xFF);
// printf("------- 0x%08X = %u \n", bdInfo, haha);
switch(haha) {
case 0x01 : MemorySizekSample = 640; break;
case 0x02 : MemorySizekSample = 192; break;
case 0x08 : MemorySizekSample = 5242; break;
case 0x10 : MemorySizekSample = 1536; break;
default: MemorySizekSample = 192; break;
}
if ( verbose ){ if ( verbose ){
PrintBoard(); PrintBoard();
if (DPPType < 0x80 ) { if (DPPType < 0x80 ) {
@ -560,8 +562,12 @@ void Digitizer::StartACQ(){
data->ClearTriggerRate(); data->ClearTriggerRate();
data->ClearData(); data->ClearData();
if( DPPType == DPPTypeCode::DPP_QDC_CODE ) SetOptimialAggOrg();
printf(" ACQ mode : %s (%d), TRG-OUT mode : %s (%d) \n", acqStr.c_str(), acqID, trgOutStr.c_str(), trgOutID); printf(" ACQ mode : %s (%d), TRG-OUT mode : %s (%d) \n", acqStr.c_str(), acqID, trgOutStr.c_str(), trgOutID);
usleep(1000); // wait for 1 msec to start/Arm ACQ;
ret = CAEN_DGTZ_SWStartAcquisition(handle); ret = CAEN_DGTZ_SWStartAcquisition(handle);
if( ret != 0 ) { if( ret != 0 ) {
ErrorMsg("Start ACQ"); ErrorMsg("Start ACQ");
@ -1327,11 +1333,14 @@ void Digitizer::SetOptimialAggOrg(){
printf(" Record Length (bit) : %u = %u sample = %u ns\n", RecordLen, RecordLen*8, RecordLen*8*16); printf(" Record Length (bit) : %u = %u sample = %u ns\n", RecordLen, RecordLen*8, RecordLen*8*16);
printf("==============================================================\n"); printf("==============================================================\n");
int eventSize = 2 + traceOn * RecordLen * 8; // sample int eventSize = 6 + 2 * Ex + traceOn * RecordLen * 8; // sample
double maxAggOrg = log2( MemorySizekSample * 1024 / eventSize ); double maxAggOrg = log2( MemorySizekSample * 1024 / eventSize / EventAgg );
printf(" max Agg. Org. should be less than %.2f\n", maxAggOrg); printf(" max Agg. Org. should be less than %.2f\n", maxAggOrg);
uint32_t aggOrg = std::floor(maxAggOrg) ;
int bufferSize = pow(2, aggOrg) * EventAgg * eventSize;
printf("================= BufferSize : %d kSample | system memeory : %d kSample \n", bufferSize / 1024, MemorySizekSample);
uint32_t aggOrg = std::floor(maxAggOrg);
WriteRegister(DPP::AggregateOrganization, aggOrg); WriteRegister(DPP::AggregateOrganization, aggOrg);
} }

View File

@ -2978,12 +2978,8 @@ void DigiSettingsPanel::SetUpChannel_QDC(){
} }
if( i == 2 ){ if( i == 2 ){
if( ch == 0 ){
QLabel * lb0 = new QLabel("Event pre Agg.", this); lb0->setAlignment(Qt::AlignHCenter); tabLayout->addWidget(lb0, 0, 6);
}
SetUpCheckBox(chkDisableSelfTrigger[ID][ch], "Disable Self Trigger ", tabLayout, ch+1, 1, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableSelfTrigger, ch); SetUpCheckBox(chkDisableSelfTrigger[ID][ch], "Disable Self Trigger ", tabLayout, ch+1, 1, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableSelfTrigger, ch);
SetUpCheckBox(chkDisableTriggerHysteresis[ID][ch], "Disbale Trig. Hysteresis ", tabLayout, ch+1, 3, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableTriggerHysteresis, ch, 2); SetUpCheckBox(chkDisableTriggerHysteresis[ID][ch], "Disbale Trig. Hysteresis ", tabLayout, ch+1, 3, DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::DisableTriggerHysteresis, ch, 2);
} }
} }