Digitizer use CAEN to set agg, UpdateScope don't Clear rigger

This commit is contained in:
carina@hades 2023-12-12 19:01:41 -05:00
parent f50383d336
commit ca59c6954a
3 changed files with 46 additions and 26 deletions

View File

@ -92,8 +92,18 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
LinkType = CAEN_DGTZ_OpticalLink ; LinkType = CAEN_DGTZ_OpticalLink ;
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle); ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle);
} }
if (ret != 0){ ///---------- try A4818
LinkType = CAEN_DGTZ_USB_A4818 ;
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle);
}
ErrorMsg("=== Open Digitizer port " +std::to_string(portID) + " board " + std::to_string(boardID)); ErrorMsg("=== Open Digitizer port " +std::to_string(portID) + " board " + std::to_string(boardID));
if( ret == 0 ){
if( LinkType == CAEN_DGTZ_USB ) printf("Open digitizer via USB, board : %d\n", boardID);
if( LinkType == CAEN_DGTZ_OpticalLink ) printf("Open digitizer via Optical Link, port : %d, board : %d\n", portID, boardID);
if( LinkType == CAEN_DGTZ_USB_A4818 ) printf("Open digitizer via A4818, port : %d, board : %d\n", portID, boardID);
}
if (ret != 0) { if (ret != 0) {
if( verbose) printf("Can't open digitizer\n"); if( verbose) printf("Can't open digitizer\n");
return -1; return -1;
@ -325,10 +335,13 @@ int Digitizer::ProgramBoard_PHA(){
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 32 ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 32 );
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::InputDynamicRange) + 0x7000 , 0x0 ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::InputDynamicRange) + 0x7000 , 0x0 );
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::NumberEventsPerAggregate_G) + 0x7000, 10); //ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::NumberEventsPerAggregate_G) + 0x7000, 10);
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::AggregateOrganization), 0); //ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::AggregateOrganization), 0);
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::MaxAggregatePerBlockTransfer), 100); //ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::MaxAggregatePerBlockTransfer), 100);
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::DPPAlgorithmControl) + 0x7000, 0xC30200f); ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(DPP::DPPAlgorithmControl) + 0x7000, 0x030200f);
ret |= CAEN_DGTZ_SetNumEventsPerAggregate(handle, 10);
ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, 0, 0); // Auto set
if( ret != 0 ) { printf("!!!!!!!! set channels error.\n");} if( ret != 0 ) { printf("!!!!!!!! set channels error.\n");}
@ -392,6 +405,9 @@ int Digitizer::ProgramBoard_PSD(){
ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardID, (DPPType & 0xF)); ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardID, (DPPType & 0xF));
//WriteRegister(DPP::BoardID, (DPPType & 0xF)); //WriteRegister(DPP::BoardID, (DPPType & 0xF));
ret |= CAEN_DGTZ_SetNumEventsPerAggregate(handle, 10);
ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, 0, 0); // Auto set
isSettingFilledinMemeory = false; /// unlock the ReadAllSettingsFromBoard(); isSettingFilledinMemeory = false; /// unlock the ReadAllSettingsFromBoard();
usleep(1000*300); usleep(1000*300);
@ -408,7 +424,7 @@ int Digitizer::ProgramBoard_QDC(){
int ret = 0; int ret = 0;
WriteRegister(DPP::QDC::NumberEventsPerAggregate, 0x10, -1); //WriteRegister(DPP::QDC::NumberEventsPerAggregate, 0x10, -1);
WriteRegister(DPP::QDC::RecordLength_W, 16, -1); // 128 sample = 2048 ns WriteRegister(DPP::QDC::RecordLength_W, 16, -1); // 128 sample = 2048 ns
WriteRegister(DPP::QDC::PreTrigger, 60, -1); // at 60 sample = 960 ns WriteRegister(DPP::QDC::PreTrigger, 60, -1); // at 60 sample = 960 ns
@ -437,8 +453,8 @@ int Digitizer::ProgramBoard_QDC(){
WriteRegister(DPP::QDC::TriggerThreshold_sub7, 100, -1); WriteRegister(DPP::QDC::TriggerThreshold_sub7, 100, -1);
WriteRegister(DPP::BoardConfiguration, 0xC0110); WriteRegister(DPP::BoardConfiguration, 0xC0110);
WriteRegister(DPP::AggregateOrganization, 0x0); //WriteRegister(DPP::AggregateOrganization, 0x0);
WriteRegister(DPP::MaxAggregatePerBlockTransfer, 100); //WriteRegister(DPP::MaxAggregatePerBlockTransfer, 100);
WriteRegister(DPP::AcquisitionControl, 0x0); WriteRegister(DPP::AcquisitionControl, 0x0);
WriteRegister(DPP::GlobalTriggerMask, 0x0); WriteRegister(DPP::GlobalTriggerMask, 0x0);
WriteRegister(DPP::FrontPanelTRGOUTEnableMask, 0x0); WriteRegister(DPP::FrontPanelTRGOUTEnableMask, 0x0);
@ -449,6 +465,9 @@ int Digitizer::ProgramBoard_QDC(){
ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardID, (DPPType & 0xF)); ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardID, (DPPType & 0xF));
//WriteRegister(DPP::BoardID, (DPPType & 0xF)); //WriteRegister(DPP::BoardID, (DPPType & 0xF));
ret |= CAEN_DGTZ_SetNumEventsPerAggregate(handle, 10);
ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, 0, 0); // Auto set
isSettingFilledinMemeory = false; /// unlock the ReadAllSettingsFromBoard(); isSettingFilledinMemeory = false; /// unlock the ReadAllSettingsFromBoard();
usleep(1000*300); usleep(1000*300);
@ -462,6 +481,8 @@ void Digitizer::StartACQ(){
if( softwareDisable ) return; if( softwareDisable ) return;
if ( AcqRun ) return; if ( AcqRun ) return;
ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, 0, 0); // Auto set
unsigned int bufferSize = 0; unsigned int bufferSize = 0;
if( DPPType == V1730_DPP_PHA_CODE ){ if( DPPType == V1730_DPP_PHA_CODE ){
bufferSize = CalByteForBuffer(); bufferSize = CalByteForBuffer();
@ -478,7 +499,6 @@ void Digitizer::StartACQ(){
return; return;
} }
data->AllocateMemory(bufferSize); data->AllocateMemory(bufferSize);
ret = CAEN_DGTZ_SWStartAcquisition(handle); ret = CAEN_DGTZ_SWStartAcquisition(handle);
@ -809,20 +829,20 @@ void Digitizer::ProgramSettingsToBoard(){
printf("========== %s \n", __func__); printf("========== %s \n", __func__);
const short pauseMilliSec = 10; const short pauseMilliSec = 50;
Reg haha; Reg haha;
if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_PSD_CODE ){ if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_PSD_CODE ){
/// board setting /// board setting
for( int p = 0; p < (int) RegisterBoardList_PHAPSD.size(); p++){ //for( int p = 0; p < (int) RegisterBoardList_PHAPSD.size(); p++){
if( RegisterBoardList_PHAPSD[p].GetRWType() == RW::ReadWrite) { // if( RegisterBoardList_PHAPSD[p].GetRWType() == RW::ReadWrite) {
haha = RegisterBoardList_PHAPSD[p]; // haha = RegisterBoardList_PHAPSD[p];
WriteRegister(haha, GetSettingFromMemory(haha), -1, false); // WriteRegister(haha, GetSettingFromMemory(haha), -1, false);
usleep(pauseMilliSec * 1000); // usleep(pauseMilliSec * 1000);
} // }
} //}
/// Channels Setting /// Channels Setting
for( int ch = 0; ch < NumInputCh; ch ++){ for( int ch = 0; ch < NumInputCh; ch ++){
if( DPPType == V1730_DPP_PHA_CODE ){ if( DPPType == V1730_DPP_PHA_CODE ){
@ -847,13 +867,13 @@ void Digitizer::ProgramSettingsToBoard(){
}else{ }else{
/// board setting /// board setting
for( int p = 0; p < (int) RegisterBoardList_QDC.size(); p++){ //for( int p = 0; p < (int) RegisterBoardList_QDC.size(); p++){
if( RegisterBoardList_QDC[p].GetRWType() == RW::ReadWrite) { // if( RegisterBoardList_QDC[p].GetRWType() == RW::ReadWrite) {
haha = RegisterBoardList_QDC[p]; // haha = RegisterBoardList_QDC[p];
WriteRegister(haha, GetSettingFromMemory(haha), -1, false); // WriteRegister(haha, GetSettingFromMemory(haha), -1, false);
usleep(pauseMilliSec * 1000); // usleep(pauseMilliSec * 1000);
} // }
} //}
/// Channels Setting /// Channels Setting
for( int ch = 0; ch < GetNumRegChannels(); ch ++){ for( int ch = 0; ch < GetNumRegChannels(); ch ++){
for( int p = 0; p < (int) RegisterChannelList_QDC.size(); p++){ for( int p = 0; p < (int) RegisterChannelList_QDC.size(); p++){

View File

@ -50,7 +50,7 @@ public:
QCPColorGradient color; QCPColorGradient color;
color.clearColorStops(); color.clearColorStops();
color.setColorStopAt( 0.0, QColor("white" )); color.setColorStopAt( 0.0, QColor("white" ));
color.setColorStopAt( 0.0001, QColor("purple" )); color.setColorStopAt( 0.000001, QColor("purple" ));
color.setColorStopAt( 0.2, QColor("blue")); color.setColorStopAt( 0.2, QColor("blue"));
color.setColorStopAt( 0.4, QColor("cyan")); color.setColorStopAt( 0.4, QColor("cyan"));
color.setColorStopAt( 0.6, QColor("green")); color.setColorStopAt( 0.6, QColor("green"));

View File

@ -529,7 +529,7 @@ void Scope::UpdateScope(){
dataTrace[4]->replace(points[4]); dataTrace[4]->replace(points[4]);
} }
} }
data->ClearTriggerRate(); //data->ClearTriggerRate();
digiMTX[ID].unlock(); digiMTX[ID].unlock();
// if( data->TriggerRate[ch] == 0 ){ // if( data->TriggerRate[ch] == 0 ){