add PSD in the core Digitizer Class and SolReader
This commit is contained in:
parent
71464484ba
commit
95310aa1c2
|
@ -38,6 +38,7 @@ void Digitizer2Gen::Initialization(){
|
|||
acqON = false;
|
||||
|
||||
settingFileName = "";
|
||||
|
||||
boardSettings = PHA::DIG::AllSettings;
|
||||
for( int ch = 0; ch < MaxNumberOfChannel ; ch ++) chSettings[ch] = PHA::CH::AllSettings;
|
||||
for( int index = 0 ; index < 4; index ++) {
|
||||
|
@ -49,7 +50,8 @@ void Digitizer2Gen::Initialization(){
|
|||
for( int i = 0; i < (int) PHA::DIG::AllSettings.size(); i++) boardMap[PHA::DIG::AllSettings[i].GetPara()] = i;
|
||||
for( int i = 0; i < (int) PHA::LVDS::AllSettings.size(); i++) LVDSMap[PHA::LVDS::AllSettings[i].GetPara()] = i;
|
||||
for( int i = 0; i < (int) PHA::CH::AllSettings.size(); i++) chMap[PHA::CH::AllSettings[i].GetPara()] = i;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Digitizer2Gen::SetDummy(unsigned short sn){
|
||||
|
@ -58,7 +60,6 @@ void Digitizer2Gen::SetDummy(unsigned short sn){
|
|||
serialNumber = sn;
|
||||
nChannels = 64;
|
||||
FPGAType = "DPP_PHA";
|
||||
|
||||
}
|
||||
|
||||
//########################################### Handles functions
|
||||
|
@ -122,7 +123,6 @@ std::string Digitizer2Gen::ReadValue(const char * parameter, bool verbose){
|
|||
|
||||
std::string Digitizer2Gen::ReadValue(const Reg para, int ch_index, bool verbose){
|
||||
std:: string ans = ReadValue(para.GetFullPara(ch_index).c_str(), verbose);
|
||||
//printf("%s | %s \n", para.GetFullPara(ch_index).c_str(), ans.c_str());
|
||||
|
||||
int index = FindIndex(para);
|
||||
switch( para.GetType()){
|
||||
|
@ -131,6 +131,8 @@ std::string Digitizer2Gen::ReadValue(const Reg para, int ch_index, bool verbose
|
|||
case TYPE::VGA : VGASetting[ch_index].SetValue(ans); break;
|
||||
case TYPE::LVDS: LVDSSettings[ch_index][index].SetValue(ans);break;
|
||||
}
|
||||
|
||||
//printf("%s | %s | index %d | %s \n", para.GetFullPara(ch_index).c_str(), ans.c_str(), index, chSettings[ch_index][index].GetValue().c_str());
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
@ -219,28 +221,64 @@ int Digitizer2Gen::OpenDigitizer(const char * url){
|
|||
isConnected = true;
|
||||
|
||||
printf("#################################################\n");
|
||||
ReadAllSettings();
|
||||
|
||||
serialNumber = atoi(GetSettingValue(PHA::DIG::SerialNumber).c_str());
|
||||
FPGAType = GetSettingValue(PHA::DIG::FirmwareType);
|
||||
FPGAVer = atoi(GetSettingValue(PHA::DIG::CupVer).c_str());
|
||||
nChannels = atoi(GetSettingValue(PHA::DIG::NumberOfChannel).c_str());
|
||||
ModelName = GetSettingValue(PHA::DIG::ModelName);
|
||||
int adcRate = atoi(GetSettingValue(PHA::DIG::ADC_SampleRate).c_str());
|
||||
//========== PHA and PSD are the same
|
||||
serialNumber = atoi(ReadValue(PHA::DIG::SerialNumber).c_str());
|
||||
FPGAType = ReadValue(PHA::DIG::FirmwareType);
|
||||
FPGAVer = atoi(ReadValue(PHA::DIG::CupVer).c_str());
|
||||
nChannels = atoi(ReadValue(PHA::DIG::NumberOfChannel).c_str());
|
||||
ModelName = ReadValue(PHA::DIG::ModelName);
|
||||
int adcRate = atoi(ReadValue(PHA::DIG::ADC_SampleRate).c_str());
|
||||
ch2ns = 1000/adcRate;
|
||||
|
||||
printf(" IP address : %s\n", GetSettingValue(PHA::DIG::IPAddress).c_str());
|
||||
printf(" Net Mask : %s\n", GetSettingValue(PHA::DIG::NetMask).c_str());
|
||||
printf(" Gateway : %s\n", GetSettingValue(PHA::DIG::Gateway).c_str());
|
||||
|
||||
printf(" IP address : %s\n", ReadValue(PHA::DIG::IPAddress).c_str());
|
||||
printf(" Net Mask : %s\n", ReadValue(PHA::DIG::NetMask).c_str());
|
||||
printf(" Gateway : %s\n", ReadValue(PHA::DIG::Gateway).c_str());
|
||||
printf(" Model name : %s\n", ModelName.c_str());
|
||||
printf(" CUP version : %s\n", GetSettingValue(PHA::DIG::CupVer).c_str());
|
||||
printf(" DPP Type : %s\n", GetSettingValue(PHA::DIG::FirmwareType).c_str());
|
||||
printf(" DPP Type : %s (%d)\n", FPGAType.c_str(), FPGAVer);
|
||||
printf("Serial number : %d\n", serialNumber);
|
||||
printf(" ADC bits : %s\n", GetSettingValue(PHA::DIG::ADC_bit).c_str());
|
||||
printf(" ADC bits : %s\n", ReadValue(PHA::DIG::ADC_bit).c_str());
|
||||
printf(" ADC rate : %d Msps, ch2ns : %d ns\n", adcRate, ch2ns);
|
||||
printf(" Channels : %d\n", nChannels);
|
||||
|
||||
if( FPGAType == DPPType::PHA) {
|
||||
|
||||
printf("========== defining setting arrays for %s \n", FPGAType.c_str());
|
||||
|
||||
boardSettings = PHA::DIG::AllSettings;
|
||||
for( int ch = 0; ch < MaxNumberOfChannel ; ch ++) chSettings[ch] = PHA::CH::AllSettings;
|
||||
for( int index = 0 ; index < 4; index ++) {
|
||||
VGASetting[index] = PHA::VGA::VGAGain;
|
||||
LVDSSettings[index] = PHA::LVDS::AllSettings;
|
||||
}
|
||||
|
||||
//build map
|
||||
for( int i = 0; i < (int) PHA::DIG::AllSettings.size(); i++) boardMap[PHA::DIG::AllSettings[i].GetPara()] = i;
|
||||
for( int i = 0; i < (int) PHA::LVDS::AllSettings.size(); i++) LVDSMap[PHA::LVDS::AllSettings[i].GetPara()] = i;
|
||||
for( int i = 0; i < (int) PHA::CH::AllSettings.size(); i++) chMap[PHA::CH::AllSettings[i].GetPara()] = i;
|
||||
|
||||
}else if (FPGAType == DPPType::PSD){
|
||||
|
||||
printf("========== defining setting arrays for %s \n", FPGAType.c_str());
|
||||
|
||||
boardSettings = PSD::DIG::AllSettings;
|
||||
for( int ch = 0; ch < MaxNumberOfChannel ; ch ++) chSettings[ch] = PSD::CH::AllSettings;
|
||||
for( int index = 0 ; index < 4; index ++) {
|
||||
VGASetting[index] = PSD::VGA::VGAGain;
|
||||
LVDSSettings[index] = PSD::LVDS::AllSettings;
|
||||
}
|
||||
|
||||
//build map
|
||||
for( int i = 0; i < (int) PSD::DIG::AllSettings.size(); i++) boardMap[PSD::DIG::AllSettings[i].GetPara()] = i;
|
||||
for( int i = 0; i < (int) PSD::LVDS::AllSettings.size(); i++) LVDSMap[PSD::LVDS::AllSettings[i].GetPara()] = i;
|
||||
for( int i = 0; i < (int) PSD::CH::AllSettings.size(); i++) chMap[PSD::CH::AllSettings[i].GetPara()] = i;
|
||||
|
||||
}else{
|
||||
printf(" DPP Type %s is not supported.\n", FPGAType.c_str());
|
||||
return -303;
|
||||
}
|
||||
|
||||
ReadAllSettings();
|
||||
//------ set default setting file name
|
||||
settingFileName = "settings_"+ std::to_string(serialNumber) + ".dat";
|
||||
|
||||
|
@ -283,30 +321,25 @@ void Digitizer2Gen::StopACQ(){
|
|||
acqON = false;
|
||||
}
|
||||
|
||||
//================ Data Format
|
||||
//------- PHA
|
||||
// 0 = all
|
||||
// 1 = 1 trace
|
||||
// 2 = no trace
|
||||
// 3 = minimum (only energy and timestamp)
|
||||
// 15 = raw buffer
|
||||
//------- PSD
|
||||
//?? 4 = all
|
||||
//?? 5 = 1 trace
|
||||
//?? 6 = no trace
|
||||
//?? 7 = only energy + timestamp
|
||||
//?? 16 = raw buffer
|
||||
|
||||
void Digitizer2Gen::SetPHADataFormat(unsigned short dataFormat){
|
||||
void Digitizer2Gen::SetDataFormat(unsigned short dataFormat){
|
||||
|
||||
printf("%s : %d\n", __func__, dataFormat);
|
||||
|
||||
///========== get endpoint and endpoint folder handle
|
||||
if( dataFormat < 15 ){
|
||||
if( dataFormat != DataFormat::RAW ){
|
||||
|
||||
ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppha", &ep_handle);
|
||||
ret |= CAEN_FELib_GetParentHandle(ep_handle, NULL, &ep_folder_handle);
|
||||
ret |= CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "dpppha");
|
||||
if( FPGAType == DPPType::PHA ){
|
||||
ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppha", &ep_handle);
|
||||
ret |= CAEN_FELib_GetParentHandle(ep_handle, NULL, &ep_folder_handle);
|
||||
ret |= CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "dpppha");
|
||||
}else if(FPGAType == DPPType::PSD) {
|
||||
ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppsd", &ep_handle);
|
||||
ret |= CAEN_FELib_GetParentHandle(ep_handle, NULL, &ep_folder_handle);
|
||||
ret |= CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "dpppsd");
|
||||
}else{
|
||||
ErrorMsg("DPP-Type not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ret != CAEN_FELib_Success) {
|
||||
ErrorMsg("Set active endpoint");
|
||||
|
@ -326,89 +359,177 @@ void Digitizer2Gen::SetPHADataFormat(unsigned short dataFormat){
|
|||
|
||||
if( evt ) delete evt;
|
||||
evt = new Event();
|
||||
evt->SetDataType(dataFormat);
|
||||
dataStartIndetifier = 0xAAA0 + dataFormat;
|
||||
evt->SetDataType(dataFormat, FPGAType);
|
||||
dataStartIndetifier = 0xAA00 + dataFormat;
|
||||
if(FPGAType == DPPType::PSD ) dataStartIndetifier += 0x0010;
|
||||
|
||||
if( FPGAType == DPPType::PHA) {
|
||||
if( dataFormat == DataFormat::ALL ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_2\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_1\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_2\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_3\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_4\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_3_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_4_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == DataFormat::OneTrace ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == DataFormat::NoTrace ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == DataFormat::Minimum ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" } \
|
||||
]");
|
||||
}
|
||||
}else if ( FPGAType == DPPType::PSD ){
|
||||
|
||||
if( dataFormat == DataFormat::ALL ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY_SHORT\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_2\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_1\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_2\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_3\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_4\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_3_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_4_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == DataFormat::OneTrace ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY_SHORT\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == DataFormat::NoTrace ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY_SHORT\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == DataFormat::Minimum ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY_SHORT\", \"type\" : \"U16\" }, \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == 0 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_2\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_1\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_2\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_3\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_4\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_3_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"DIGITAL_PROBE_4_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == 1 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == 2 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
|
||||
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == 3 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" } \
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == 15 ){
|
||||
if( dataFormat == DataFormat::RAW ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
" [ \
|
||||
{ \"name\": \"DATA\", \"type\": \"U8\", \"dim\": 1 }, \
|
||||
|
@ -469,82 +590,174 @@ void Digitizer2Gen::PrintStat(){
|
|||
int Digitizer2Gen::ReadData(){
|
||||
//printf("========= %s \n", __func__);
|
||||
|
||||
if( evt->dataType == 0){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
evt->analog_probes[0],
|
||||
evt->analog_probes[1],
|
||||
evt->digital_probes[0],
|
||||
evt->digital_probes[1],
|
||||
evt->digital_probes[2],
|
||||
evt->digital_probes[3],
|
||||
&evt->analog_probes_type[0],
|
||||
&evt->analog_probes_type[1],
|
||||
&evt->digital_probes_type[0],
|
||||
&evt->digital_probes_type[1],
|
||||
&evt->digital_probes_type[2],
|
||||
&evt->digital_probes_type[3],
|
||||
&evt->traceLenght,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}else if( evt->dataType == 1){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
evt->analog_probes[0],
|
||||
&evt->analog_probes_type[0],
|
||||
&evt->traceLenght,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}else if( evt->dataType == 2){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}else if( evt->dataType == 3){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->energy
|
||||
);
|
||||
}else if( evt->dataType == 15){
|
||||
if( FPGAType != DPPType::PHA || FPGAType != DPPType::PSD ) return -404;
|
||||
|
||||
if( evt->dataType == DataFormat::ALL ){
|
||||
if( FPGAType == DPPType::PHA ){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
evt->analog_probes[0],
|
||||
evt->analog_probes[1],
|
||||
evt->digital_probes[0],
|
||||
evt->digital_probes[1],
|
||||
evt->digital_probes[2],
|
||||
evt->digital_probes[3],
|
||||
&evt->analog_probes_type[0],
|
||||
&evt->analog_probes_type[1],
|
||||
&evt->digital_probes_type[0],
|
||||
&evt->digital_probes_type[1],
|
||||
&evt->digital_probes_type[2],
|
||||
&evt->digital_probes_type[3],
|
||||
&evt->traceLenght,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}else{
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
&evt->energy_short,
|
||||
evt->analog_probes[0],
|
||||
evt->analog_probes[1],
|
||||
evt->digital_probes[0],
|
||||
evt->digital_probes[1],
|
||||
evt->digital_probes[2],
|
||||
evt->digital_probes[3],
|
||||
&evt->analog_probes_type[0],
|
||||
&evt->analog_probes_type[1],
|
||||
&evt->digital_probes_type[0],
|
||||
&evt->digital_probes_type[1],
|
||||
&evt->digital_probes_type[2],
|
||||
&evt->digital_probes_type[3],
|
||||
&evt->traceLenght,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}
|
||||
|
||||
evt->isTraceAllZero = false;
|
||||
|
||||
}else if( evt->dataType == DataFormat::OneTrace){
|
||||
if( FPGAType == DPPType::PHA ){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
evt->analog_probes[0],
|
||||
&evt->analog_probes_type[0],
|
||||
&evt->traceLenght,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}else{
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
&evt->energy_short,
|
||||
evt->analog_probes[0],
|
||||
&evt->analog_probes_type[0],
|
||||
&evt->traceLenght,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}
|
||||
|
||||
evt->isTraceAllZero = false;
|
||||
|
||||
}else if( evt->dataType == DataFormat::NoTrace){
|
||||
if( FPGAType == DPPType::PHA ){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}else{
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->energy,
|
||||
&evt->energy_short,
|
||||
&evt->flags_low_priority,
|
||||
&evt->flags_high_priority,
|
||||
&evt->trigger_threashold,
|
||||
&evt->downSampling,
|
||||
&evt->board_fail,
|
||||
&evt->flush,
|
||||
&evt->aggCounter,
|
||||
&evt->event_size
|
||||
);
|
||||
}
|
||||
|
||||
evt->isTraceAllZero = true;
|
||||
|
||||
}else if( evt->dataType == DataFormat::Minimum){
|
||||
if( FPGAType == DPPType::PHA ){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->energy
|
||||
);
|
||||
}else{
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->energy,
|
||||
&evt->energy_short
|
||||
);
|
||||
}
|
||||
|
||||
evt->isTraceAllZero = true;
|
||||
}else if( evt->dataType == DataFormat::RAW){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100, evt->data, &evt->dataSize, &evt->n_events );
|
||||
//printf("data size: %lu byte\n", evt.dataSize);
|
||||
|
||||
evt->isTraceAllZero = true; //assume no trace, as the trace need to be extracted.
|
||||
}else{
|
||||
return CAEN_FELib_UNKNOWN;
|
||||
}
|
||||
|
||||
evt->isTraceAllZero = false;
|
||||
|
||||
if( ret != CAEN_FELib_Success) {
|
||||
//ErrorMsg("ReadData()");
|
||||
return ret;
|
||||
|
@ -582,56 +795,60 @@ void Digitizer2Gen::SaveDataToFile(){
|
|||
outFile = fopen(outFileName, "wb"); //overwrite binary
|
||||
}
|
||||
|
||||
if( evt->dataType == 0){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
fwrite(&evt->fine_timestamp, 2, 1, outFile);
|
||||
if( evt->dataType == DataFormat::ALL){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
fwrite(&evt->fine_timestamp, 2, 1, outFile);
|
||||
fwrite(&evt->flags_high_priority, 1, 1, outFile);
|
||||
fwrite(&evt->flags_low_priority, 2, 1, outFile);
|
||||
fwrite(&evt->downSampling, 1, 1, outFile);
|
||||
fwrite(&evt->board_fail, 1, 1, outFile);
|
||||
fwrite(&evt->flush, 1, 1, outFile);
|
||||
fwrite(&evt->trigger_threashold, 2, 1, outFile);
|
||||
fwrite(&evt->event_size, 8, 1, outFile);
|
||||
fwrite(&evt->aggCounter, 4, 1, outFile);
|
||||
fwrite(&evt->traceLenght, 8, 1, outFile);
|
||||
fwrite(evt->analog_probes_type, 2, 1, outFile);
|
||||
fwrite(evt->digital_probes_type, 4, 1, outFile);
|
||||
fwrite(&evt->flags_low_priority, 2, 1, outFile);
|
||||
fwrite(&evt->downSampling, 1, 1, outFile);
|
||||
fwrite(&evt->board_fail, 1, 1, outFile);
|
||||
fwrite(&evt->flush, 1, 1, outFile);
|
||||
fwrite(&evt->trigger_threashold, 2, 1, outFile);
|
||||
fwrite(&evt->event_size, 8, 1, outFile);
|
||||
fwrite(&evt->aggCounter, 4, 1, outFile);
|
||||
fwrite(&evt->traceLenght, 8, 1, outFile);
|
||||
fwrite(evt->analog_probes_type, 2, 1, outFile);
|
||||
fwrite(evt->digital_probes_type, 4, 1, outFile);
|
||||
fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile);
|
||||
fwrite(evt->analog_probes[1], evt->traceLenght*4, 1, outFile);
|
||||
fwrite(evt->digital_probes[0], evt->traceLenght, 1, outFile);
|
||||
fwrite(evt->digital_probes[1], evt->traceLenght, 1, outFile);
|
||||
fwrite(evt->digital_probes[2], evt->traceLenght, 1, outFile);
|
||||
fwrite(evt->digital_probes[3], evt->traceLenght, 1, outFile);
|
||||
}else if( evt->dataType == 1){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
fwrite(&evt->fine_timestamp, 2, 1, outFile);
|
||||
fwrite(&evt->flags_high_priority, 1, 1, outFile);
|
||||
fwrite(&evt->flags_low_priority, 2, 1, outFile);
|
||||
fwrite(&evt->traceLenght, 8, 1, outFile);
|
||||
}else if( evt->dataType == DataFormat::OneTrace){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
fwrite(&evt->fine_timestamp, 2, 1, outFile);
|
||||
fwrite(&evt->flags_high_priority, 1, 1, outFile);
|
||||
fwrite(&evt->flags_low_priority, 2, 1, outFile);
|
||||
fwrite(&evt->traceLenght, 8, 1, outFile);
|
||||
fwrite(&evt->analog_probes_type[0], 1, 1, outFile);
|
||||
fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile);
|
||||
}else if( evt->dataType == 2){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
fwrite(&evt->fine_timestamp, 2, 1, outFile);
|
||||
}else if( evt->dataType == DataFormat::NoTrace ){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
fwrite(&evt->fine_timestamp, 2, 1, outFile);
|
||||
fwrite(&evt->flags_high_priority, 1, 1, outFile);
|
||||
fwrite(&evt->flags_low_priority, 2, 1, outFile);
|
||||
}else if( evt->dataType == 3){
|
||||
fwrite(&evt->flags_low_priority, 2, 1, outFile);
|
||||
}else if( evt->dataType == DataFormat::Minimum ){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
}else if( evt->dataType == 15){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->dataSize, 8, 1, outFile);
|
||||
fwrite(&evt->channel, 1, 1, outFile);
|
||||
fwrite(&evt->energy, 2, 1, outFile);
|
||||
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile);
|
||||
fwrite(&evt->timestamp, 6, 1, outFile);
|
||||
}else if( evt->dataType == DataFormat::RAW){
|
||||
fwrite(&dataStartIndetifier, 2, 1, outFile);
|
||||
fwrite(&evt->dataSize, 8, 1, outFile);
|
||||
fwrite(evt->data, evt->dataSize, 1, outFile);
|
||||
}
|
||||
|
||||
|
@ -825,9 +1042,14 @@ std::string Digitizer2Gen::ErrorMsg(const char * funcName){
|
|||
//^===================================================== Settings
|
||||
void Digitizer2Gen::ReadAllSettings(){
|
||||
if( !isConnected ) return;
|
||||
|
||||
printf("Digitizer2Gen::%s | %s \n", __func__, FPGAType.c_str());
|
||||
|
||||
for(int i = 0; i < (int) boardSettings.size(); i++){
|
||||
if( boardSettings[i].ReadWrite() == RW::WriteOnly) continue;
|
||||
if( !(ModelName == "VX2745" && FPGAType == "DPP_PHA") &&
|
||||
|
||||
// here TempSens is same for PHA and PSD
|
||||
if( !(ModelName == "VX2745") &&
|
||||
(boardSettings[i].GetPara() == PHA::DIG::TempSensADC1.GetPara() ||
|
||||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC2.GetPara() ||
|
||||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC3.GetPara() ||
|
||||
|
@ -839,7 +1061,7 @@ void Digitizer2Gen::ReadAllSettings(){
|
|||
ReadValue(boardSettings[i]);
|
||||
}
|
||||
|
||||
if( ModelName == "VX2745" && FPGAType == "DPP_PHA") for(int i = 0; i < 4 ; i ++) ReadValue(VGASetting[i], i);
|
||||
if( ModelName == "VX2745") for(int i = 0; i < 4 ; i ++) ReadValue(VGASetting[i], i);
|
||||
|
||||
for( int index = 0; index < 4; index++){
|
||||
for( int i = 0; i < (int) LVDSSettings[index].size(); i++){
|
||||
|
@ -855,6 +1077,7 @@ void Digitizer2Gen::ReadAllSettings(){
|
|||
ReadValue(chSettings[ch][i], ch);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int Digitizer2Gen::SaveSettingsToFile(const char * saveFileName, bool setReadOnly){
|
||||
|
@ -867,7 +1090,28 @@ int Digitizer2Gen::SaveSettingsToFile(const char * saveFileName, bool setReadOnl
|
|||
for(int i = 0; i < (int) boardSettings.size(); i++){
|
||||
if( boardSettings[i].ReadWrite() == RW::WriteOnly) continue;
|
||||
totCount ++;
|
||||
if( boardSettings[i].GetValue() == "" && boardSettings[i].GetPara() != "Gateway") break;
|
||||
//--- exclude Gateway
|
||||
if( boardSettings[i].GetPara() == PHA::DIG::Gateway.GetPara()) {
|
||||
totCount --;
|
||||
continue;
|
||||
}
|
||||
|
||||
//--- exclude some TempSens for Not VX2745
|
||||
if( ModelName != "VX2745" &&
|
||||
( boardSettings[i].GetPara() == PHA::DIG::TempSensADC1.GetPara() ||
|
||||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC2.GetPara() ||
|
||||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC3.GetPara() ||
|
||||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC4.GetPara() ||
|
||||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC5.GetPara() ||
|
||||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC6.GetPara() ) ) {
|
||||
totCount --;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( boardSettings[i].GetValue() == "") {
|
||||
printf(" No value for %s \n", boardSettings[i].GetPara().c_str());
|
||||
continue;
|
||||
}
|
||||
fprintf(saveFile, "%-45s!%d!%4d!%s\n", boardSettings[i].GetFullPara().c_str(),
|
||||
boardSettings[i].ReadWrite(),
|
||||
8000 + i,
|
||||
|
@ -875,10 +1119,13 @@ int Digitizer2Gen::SaveSettingsToFile(const char * saveFileName, bool setReadOnl
|
|||
count ++;
|
||||
}
|
||||
|
||||
if( ModelName == "VX2745" && FPGAType == "DPP_PHA") {
|
||||
if( ModelName == "VX2745" && FPGAType == DPPType::PHA) {
|
||||
for(int i = 0; i < 4 ; i ++){
|
||||
totCount ++;
|
||||
if( VGASetting[i].GetValue() == "" ) break;
|
||||
if( VGASetting[i].GetValue() == "" ) {
|
||||
printf(" No value for %s \n", VGASetting[i].GetPara().c_str());
|
||||
continue;
|
||||
}
|
||||
fprintf(saveFile, "%-45s!%d!%4d!%s\n", VGASetting[i].GetFullPara(i).c_str(),
|
||||
VGASetting[i].ReadWrite(),
|
||||
9000 + i,
|
||||
|
@ -891,7 +1138,10 @@ int Digitizer2Gen::SaveSettingsToFile(const char * saveFileName, bool setReadOnl
|
|||
for( int index = 0; index < 4; index++){
|
||||
if( LVDSSettings[index][i].ReadWrite() == RW::WriteOnly) continue;
|
||||
totCount ++;
|
||||
if( LVDSSettings[index][i].GetValue() == "") break;
|
||||
if( LVDSSettings[index][i].GetValue() == "") {
|
||||
printf(" No value for %s \n", LVDSSettings[index][i].GetPara().c_str());
|
||||
continue;
|
||||
}
|
||||
fprintf(saveFile, "%-45s!%d!%4d!%s\n", LVDSSettings[index][i].GetFullPara(index).c_str(),
|
||||
LVDSSettings[index][i].ReadWrite(),
|
||||
7000 + 4 * index + i,
|
||||
|
@ -904,7 +1154,10 @@ int Digitizer2Gen::SaveSettingsToFile(const char * saveFileName, bool setReadOnl
|
|||
for(int ch = 0; ch < nChannels ; ch++ ){
|
||||
if( chSettings[ch][i].ReadWrite() == RW::WriteOnly) continue;
|
||||
totCount ++;
|
||||
if( chSettings[ch][i].GetValue() == "") break;
|
||||
if( chSettings[ch][i].GetValue() == "") {
|
||||
printf("[%i] No value for %s , ch-%02d\n", i, chSettings[ch][i].GetPara().c_str(), ch);
|
||||
continue;
|
||||
}
|
||||
fprintf(saveFile, "%-45s!%d!%4d!%s\n", chSettings[ch][i].GetFullPara(ch).c_str(),
|
||||
chSettings[ch][i].ReadWrite(),
|
||||
ch*100 + i,
|
||||
|
|
|
@ -32,8 +32,8 @@ class Digitizer2Gen {
|
|||
char retValue[256];
|
||||
|
||||
unsigned short serialNumber;
|
||||
std::string FPGAType;
|
||||
unsigned int FPGAVer;
|
||||
std::string FPGAType; // look the DigitiParameter.h::PHA::DIG::FirwareType, DPP_PHA, DPP_ZLE, DPP_PSD, DPP_DAW, DPP_OPEN, and Scope
|
||||
unsigned int FPGAVer; // for checking copy setting
|
||||
unsigned short nChannels;
|
||||
unsigned short ch2ns;
|
||||
std::string ModelName;
|
||||
|
@ -71,21 +71,23 @@ class Digitizer2Gen {
|
|||
Digitizer2Gen();
|
||||
~Digitizer2Gen();
|
||||
|
||||
unsigned short GetSerialNumber() const{return serialNumber;}
|
||||
std::string GetFPGAType() const {return FPGAType;}
|
||||
std::string GetModelName() const {return ModelName;}
|
||||
unsigned int GetFPGAVersion() const {return FPGAVer;}
|
||||
unsigned short GetSerialNumber() const {return serialNumber;}
|
||||
std::string GetFPGAType() const {return FPGAType;}
|
||||
std::string GetModelName() const {return ModelName;}
|
||||
unsigned int GetFPGAVersion() const {return FPGAVer;}
|
||||
|
||||
void SetDummy(unsigned short sn);
|
||||
bool IsDummy() const {return isDummy;}
|
||||
bool IsDummy() const {return isDummy;}
|
||||
bool IsConnected() const {return isConnected;}
|
||||
|
||||
int OpenDigitizer(const char * url);
|
||||
bool IsConnected() const {return isConnected;}
|
||||
int CloseDigitizer();
|
||||
int OpenDigitizer(const char * url);
|
||||
int CloseDigitizer();
|
||||
|
||||
int GetRet() const {return ret;};
|
||||
|
||||
int FindIndex(const Reg para); // get index from DIGIPARA
|
||||
uint64_t GetHandle(const char * parameter);
|
||||
uint64_t GetParentHandle(uint64_t handle);
|
||||
std::string GetPath(uint64_t handle);
|
||||
|
||||
std::string ReadValue(const char * parameter, bool verbose = false);
|
||||
std::string ReadValue(const Reg para, int ch_index = -1, bool verbose = false); // read digitizer and save to memory
|
||||
|
@ -94,9 +96,9 @@ class Digitizer2Gen {
|
|||
void SendCommand(const char * parameter);
|
||||
void SendCommand(std::string shortPara);
|
||||
|
||||
uint64_t GetHandle(const char * parameter);
|
||||
uint64_t GetParentHandle(uint64_t handle);
|
||||
std::string GetPath(uint64_t handle);
|
||||
int FindIndex(const Reg para); // get index from DIGIPARA
|
||||
std::string GetSettingValue(const Reg para, unsigned int ch_index = 0); // read from memory
|
||||
|
||||
|
||||
std::string ErrorMsg(const char * funcName);
|
||||
|
||||
|
@ -104,11 +106,8 @@ class Digitizer2Gen {
|
|||
void StopACQ();
|
||||
bool IsAcqOn() const {return acqON;}
|
||||
|
||||
void SetPHADataFormat(unsigned short dataFormat); // 0 = all data,
|
||||
// 1 = analog trace-0 only + flags
|
||||
// 2 = no trace, only ch, energy, timestamp, fine_timestamp + flags
|
||||
// 3 = only ch, energy, timestamp, minimum
|
||||
// 15 = raw data
|
||||
void SetDataFormat(unsigned short dataFormat); // dataFormat = namespace DataFormat
|
||||
|
||||
int ReadData();
|
||||
int ReadStat(); // digitizer update it every 500 msec
|
||||
void PrintStat();
|
||||
|
@ -138,7 +137,6 @@ class Digitizer2Gen {
|
|||
int ReadAndSaveSettingsToFile(const char * saveFileName = NULL); // ReadAllSettings + text file
|
||||
bool LoadSettingsFromFile(const char * loadFileName = NULL); // Load settings, write to digitizer and save to memory
|
||||
|
||||
std::string GetSettingValue(const Reg para, unsigned int ch_index = 0); // read from memory
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
116
DigiParameters.h
116
DigiParameters.h
|
@ -1041,70 +1041,70 @@ namespace PSD{
|
|||
|
||||
const Reg ADCInputBaselineGuardSample ("ADCInputBaselineGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
|
||||
const Reg CFDDelaySample ("CFDDelayS", RW::ReadWrite, TYPE::CH, {{"4", ""},{"1023", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
|
||||
const Reg TimeFilterRetriggerGuardSample ("TimeFilterRetriggerGuardT", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8000", ""},{"8", ""}}, ANSTYPE::INTEGER, "sample");
|
||||
const Reg TimeFilterRetriggerGuardSample ("TimeFilterRetriggerGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8000", ""},{"8", ""}}, ANSTYPE::INTEGER, "sample");
|
||||
const Reg GateLongLengthSample ("GateLongLengthS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"4000", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
|
||||
const Reg GateShortLengthSample ("GateShortLengthS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"4000", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
|
||||
const Reg GateOffsetSample ("GateOffsetS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"250", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
|
||||
|
||||
|
||||
const std::vector<Reg> AllSettings = {
|
||||
SelfTrgRate ,
|
||||
ChannelStatus ,
|
||||
GainFactor ,
|
||||
ADCToVolts ,
|
||||
ChannelRealtime ,
|
||||
ChannelDeadtime ,
|
||||
ChannelTriggerCount ,
|
||||
ChannelSavedCount ,
|
||||
ChannelWaveCount ,
|
||||
ChannelEnable ,
|
||||
DC_Offset ,
|
||||
TriggerThreshold ,
|
||||
Polarity ,
|
||||
WaveDataSource ,
|
||||
RecordLength ,
|
||||
WaveSaving ,
|
||||
WaveResolution ,
|
||||
PreTrigger ,
|
||||
WaveAnalogProbe0 ,
|
||||
WaveAnalogProbe1 ,
|
||||
WaveDigitalProbe0 ,
|
||||
WaveDigitalProbe1 ,
|
||||
WaveDigitalProbe2 ,
|
||||
WaveDigitalProbe3 ,
|
||||
EventTriggerSource ,
|
||||
ChannelsTriggerMask ,
|
||||
ChannelVetoSource ,
|
||||
WaveTriggerSource ,
|
||||
EventSelector ,
|
||||
WaveSelector ,
|
||||
CoincidenceMask ,
|
||||
AntiCoincidenceMask ,
|
||||
CoincidenceLength ,
|
||||
CoincidenceLengthSample ,
|
||||
ADCVetoWidth ,
|
||||
EnergySkimLowDiscriminator ,
|
||||
EnergySkimHighDiscriminator,
|
||||
RecordLengthSample ,
|
||||
PreTriggerSample ,
|
||||
ITLConnect ,
|
||||
ADCInputBaselineAvg ,
|
||||
AbsoluteBaseline ,
|
||||
ADCInputBaselineGuard ,
|
||||
SmoothingFactor ,
|
||||
ChargeSmoothing ,
|
||||
TimeFilterSmoothing ,
|
||||
TriggerFilterSelection ,
|
||||
CFDDelay ,
|
||||
CFDFraction ,
|
||||
TimeFilterRetriggerGuard ,
|
||||
TriggerHysteresis ,
|
||||
PileupGap ,
|
||||
GateLongLength ,
|
||||
GateShortLength ,
|
||||
GateOffset ,
|
||||
LongChargeIntegratorPedestal,
|
||||
ShortChargeIntegratorPedestal,
|
||||
SelfTrgRate , // 0
|
||||
ChannelStatus , // 1
|
||||
GainFactor , // 2
|
||||
ADCToVolts , // 3
|
||||
ChannelRealtime , // 4
|
||||
ChannelDeadtime , // 5
|
||||
ChannelTriggerCount , // 6
|
||||
ChannelSavedCount , // 7
|
||||
ChannelWaveCount , // 8
|
||||
ChannelEnable , // 9
|
||||
DC_Offset , // 10
|
||||
TriggerThreshold , // 11
|
||||
Polarity , // 12
|
||||
WaveDataSource , // 13
|
||||
RecordLength , // 14
|
||||
WaveSaving , // 15
|
||||
WaveResolution , // 16
|
||||
PreTrigger , // 17
|
||||
WaveAnalogProbe0 , // 18
|
||||
WaveAnalogProbe1 , // 19
|
||||
WaveDigitalProbe0 , // 20
|
||||
WaveDigitalProbe1 , // 21
|
||||
WaveDigitalProbe2 , // 22
|
||||
WaveDigitalProbe3 , // 23
|
||||
EventTriggerSource , // 24
|
||||
ChannelsTriggerMask , // 25
|
||||
ChannelVetoSource , // 26
|
||||
WaveTriggerSource , // 27
|
||||
EventSelector , // 28
|
||||
WaveSelector , // 29
|
||||
CoincidenceMask , // 30
|
||||
AntiCoincidenceMask , // 31
|
||||
CoincidenceLength , // 32
|
||||
CoincidenceLengthSample , // 33
|
||||
ADCVetoWidth , // 34
|
||||
EnergySkimLowDiscriminator , // 35
|
||||
EnergySkimHighDiscriminator, // 36
|
||||
RecordLengthSample , // 37
|
||||
PreTriggerSample , // 38
|
||||
ITLConnect , // 39
|
||||
ADCInputBaselineAvg , // 40
|
||||
AbsoluteBaseline , // 41
|
||||
ADCInputBaselineGuard , // 42
|
||||
SmoothingFactor , // 43
|
||||
ChargeSmoothing , // 44
|
||||
TimeFilterSmoothing , // 45
|
||||
TriggerFilterSelection , // 46
|
||||
CFDDelay , // 47
|
||||
CFDFraction , // 48
|
||||
TimeFilterRetriggerGuard , // 49
|
||||
TriggerHysteresis , // 50
|
||||
PileupGap , // 51
|
||||
GateLongLength , // 52
|
||||
GateShortLength , // 53
|
||||
GateOffset , // 54
|
||||
LongChargeIntegratorPedestal, //
|
||||
ShortChargeIntegratorPedestal, //
|
||||
EnergyGain ,
|
||||
NeutronThreshold ,
|
||||
ADCInputBaselineGuardSample,
|
||||
|
|
104
Event.h
104
Event.h
|
@ -7,27 +7,46 @@
|
|||
|
||||
#define MaxTraceLenght 8100
|
||||
|
||||
enum DataFormat{
|
||||
|
||||
ALL = 0,
|
||||
OneTrace = 1,
|
||||
NoTrace = 2,
|
||||
Minimum = 3,
|
||||
RAW = 0x0A,
|
||||
|
||||
};
|
||||
|
||||
namespace DPPType{
|
||||
|
||||
const std::string PHA = "DPP_PHA";
|
||||
const std::string PSD = "DPP_PSD";
|
||||
|
||||
};
|
||||
|
||||
class Event {
|
||||
public:
|
||||
|
||||
unsigned short dataType;
|
||||
std::string DPPType;
|
||||
|
||||
///============= for dpp-pha
|
||||
uint8_t channel; // 6 bit
|
||||
uint16_t energy; // 16 bit
|
||||
uint64_t timestamp; // 48 bit
|
||||
uint8_t channel; // 6 bit
|
||||
uint16_t energy; // 16 bit
|
||||
uint16_t energy_short; // 16 bit, only for PSD
|
||||
uint64_t timestamp; // 48 bit
|
||||
uint16_t fine_timestamp; // 16 bit
|
||||
uint16_t flags_low_priority; // 12 bit
|
||||
uint16_t flags_high_priority; // 8 bit
|
||||
size_t traceLenght; // 64 bit
|
||||
uint8_t downSampling; // 8 bit
|
||||
size_t traceLenght; // 64 bit
|
||||
uint8_t downSampling; // 8 bit
|
||||
bool board_fail;
|
||||
bool flush;
|
||||
uint8_t analog_probes_type[2]; // 3 bit
|
||||
uint8_t digital_probes_type[4]; // 4 bit
|
||||
int32_t * analog_probes[2]; // 18 bit
|
||||
uint8_t * digital_probes[4]; // 1 bit
|
||||
uint16_t trigger_threashold; // 16 bit
|
||||
uint8_t analog_probes_type[2]; // 3 bit for PHA, 4 bit for PSD
|
||||
uint8_t digital_probes_type[4]; // 4 bit for PHA, 5 bit for PSD
|
||||
int32_t * analog_probes[2]; // 18 bit
|
||||
uint8_t * digital_probes[4]; // 1 bit
|
||||
uint16_t trigger_threashold; // 16 bit
|
||||
size_t event_size; // 64 bit
|
||||
uint32_t aggCounter; // 32 bit
|
||||
|
||||
|
@ -47,8 +66,12 @@ class Event {
|
|||
}
|
||||
|
||||
void Init(){
|
||||
DPPType = DPPType::PHA;
|
||||
dataType = DataFormat::ALL;
|
||||
|
||||
channel = 0;
|
||||
energy = 0;
|
||||
energy_short = 0;
|
||||
timestamp = 0;
|
||||
fine_timestamp = 0;
|
||||
downSampling = 0;
|
||||
|
@ -91,11 +114,12 @@ class Event {
|
|||
isTraceAllZero = true;
|
||||
}
|
||||
|
||||
void SetDataType(unsigned int type){
|
||||
void SetDataType(unsigned int type, std::string dppType){
|
||||
dataType = type;
|
||||
DPPType = dppType;
|
||||
ClearMemory();
|
||||
|
||||
if( dataType == 0xF){
|
||||
if( dataType == DataFormat::RAW){
|
||||
data = new uint8_t[20*1024*1024];
|
||||
}else{
|
||||
analog_probes[0] = new int32_t[MaxTraceLenght];
|
||||
|
@ -131,30 +155,46 @@ class Event {
|
|||
}
|
||||
|
||||
std::string AnaProbeType(uint8_t probeType){
|
||||
switch(probeType){
|
||||
case 0: return "ADC";
|
||||
case 1: return "Time filter";
|
||||
case 2: return "Energy filter";
|
||||
default : return "none";
|
||||
|
||||
if( DPPType == DPPType::PHA){
|
||||
switch(probeType){
|
||||
case 0: return "ADC";
|
||||
case 1: return "Time filter";
|
||||
case 2: return "Energy filter";
|
||||
default : return "none";
|
||||
}
|
||||
}else if (DPPType == DPPType::PSD){
|
||||
|
||||
|
||||
}else{
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
std::string DigiProbeType(uint8_t probeType){
|
||||
switch(probeType){
|
||||
case 0: return "Trigger";
|
||||
case 1: return "Time filter armed";
|
||||
case 2: return "Re-trigger guard";
|
||||
case 3: return "Energy filter baseline freeze";
|
||||
case 4: return "Energy filter peaking";
|
||||
case 5: return "Energy filter peaking ready";
|
||||
case 6: return "Energy filter pile-up guard";
|
||||
case 7: return "Event pile-up";
|
||||
case 8: return "ADC saturation";
|
||||
case 9: return "ADC saturation protection";
|
||||
case 10: return "Post-saturation event";
|
||||
case 11: return "Energy filter saturation";
|
||||
case 12: return "Signal inhibit";
|
||||
default : return "none";
|
||||
|
||||
if( DPPType == DPPType::PHA){
|
||||
switch(probeType){
|
||||
case 0: return "Trigger";
|
||||
case 1: return "Time filter armed";
|
||||
case 2: return "Re-trigger guard";
|
||||
case 3: return "Energy filter baseline freeze";
|
||||
case 4: return "Energy filter peaking";
|
||||
case 5: return "Energy filter peaking ready";
|
||||
case 6: return "Energy filter pile-up guard";
|
||||
case 7: return "Event pile-up";
|
||||
case 8: return "ADC saturation";
|
||||
case 9: return "ADC saturation protection";
|
||||
case 10: return "Post-saturation event";
|
||||
case 11: return "Energy filter saturation";
|
||||
case 12: return "Signal inhibit";
|
||||
default : return "none";
|
||||
}
|
||||
}else if (DPPType == DPPType::PSD){
|
||||
|
||||
|
||||
}else{
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
85
SolReader.h
85
SolReader.h
|
@ -67,7 +67,7 @@ SolReader::SolReader(){
|
|||
SolReader::SolReader(std::string fileName, unsigned short dataType = 0){
|
||||
init();
|
||||
OpenFile(fileName);
|
||||
evt->SetDataType(dataType);
|
||||
evt->SetDataType(dataType, DPPType::PHA);
|
||||
}
|
||||
|
||||
SolReader::~SolReader(){
|
||||
|
@ -107,39 +107,41 @@ inline int SolReader::ReadNextBlock(int opt){
|
|||
|
||||
fread(&blockStartIdentifier, 2, 1, inFile);
|
||||
|
||||
if( (blockStartIdentifier & 0xAAA0) != 0xAAA0 ) {
|
||||
if( (blockStartIdentifier & 0xAA00) != 0xAA00 ) {
|
||||
printf("header fail.\n");
|
||||
return -2 ;
|
||||
}
|
||||
|
||||
if( ( blockStartIdentifier & 0xF ) == 15 ){
|
||||
evt->SetDataType(15);
|
||||
if( ( blockStartIdentifier & 0xF ) == DataFormat::RAW ){
|
||||
evt->SetDataType(DataFormat::RAW, ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD);
|
||||
}
|
||||
evt->dataType = blockStartIdentifier & 0xF;
|
||||
evt->DPPType = ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD;
|
||||
|
||||
if( evt->dataType == 0){
|
||||
if( evt->dataType == DataFormat::ALL){
|
||||
if( opt == 0 ){
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
fread(&evt->timestamp, 6, 1, inFile);
|
||||
fread(&evt->fine_timestamp, 2, 1, inFile);
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile);
|
||||
fread(&evt->timestamp, 6, 1, inFile);
|
||||
fread(&evt->fine_timestamp, 2, 1, inFile);
|
||||
fread(&evt->flags_high_priority, 1, 1, inFile);
|
||||
fread(&evt->flags_low_priority, 2, 1, inFile);
|
||||
fread(&evt->downSampling, 1, 1, inFile);
|
||||
fread(&evt->board_fail, 1, 1, inFile);
|
||||
fread(&evt->flush, 1, 1, inFile);
|
||||
fread(&evt->trigger_threashold, 2, 1, inFile);
|
||||
fread(&evt->event_size, 8, 1, inFile);
|
||||
fread(&evt->aggCounter, 4, 1, inFile);
|
||||
fread(&evt->flags_low_priority, 2, 1, inFile);
|
||||
fread(&evt->downSampling, 1, 1, inFile);
|
||||
fread(&evt->board_fail, 1, 1, inFile);
|
||||
fread(&evt->flush, 1, 1, inFile);
|
||||
fread(&evt->trigger_threashold, 2, 1, inFile);
|
||||
fread(&evt->event_size, 8, 1, inFile);
|
||||
fread(&evt->aggCounter, 4, 1, inFile);
|
||||
}else{
|
||||
fseek(inFile, 31, SEEK_CUR);
|
||||
fseek(inFile, evt->DPPType == DPPType::PHA ? 31 : 33, SEEK_CUR);
|
||||
}
|
||||
fread(&evt->traceLenght, 8, 1, inFile);
|
||||
if( opt == 0){
|
||||
fread(evt->analog_probes_type, 2, 1, inFile);
|
||||
fread(evt->digital_probes_type, 4, 1, inFile);
|
||||
fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile);
|
||||
fread(evt->analog_probes[1], evt->traceLenght*4, 1, inFile);
|
||||
fread(evt->analog_probes_type, 2, 1, inFile);
|
||||
fread(evt->digital_probes_type, 4, 1, inFile);
|
||||
fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile);
|
||||
fread(evt->analog_probes[1], evt->traceLenght*4, 1, inFile);
|
||||
fread(evt->digital_probes[0], evt->traceLenght, 1, inFile);
|
||||
fread(evt->digital_probes[1], evt->traceLenght, 1, inFile);
|
||||
fread(evt->digital_probes[2], evt->traceLenght, 1, inFile);
|
||||
|
@ -147,16 +149,17 @@ inline int SolReader::ReadNextBlock(int opt){
|
|||
}else{
|
||||
fseek(inFile, 6 + evt->traceLenght*(12), SEEK_CUR);
|
||||
}
|
||||
}else if( evt->dataType == 1){
|
||||
}else if( evt->dataType == DataFormat::OneTrace){
|
||||
if( opt == 0 ){
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
fread(&evt->timestamp, 6, 1, inFile);
|
||||
fread(&evt->fine_timestamp, 2, 1, inFile);
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile);
|
||||
fread(&evt->timestamp, 6, 1, inFile);
|
||||
fread(&evt->fine_timestamp, 2, 1, inFile);
|
||||
fread(&evt->flags_high_priority, 1, 1, inFile);
|
||||
fread(&evt->flags_low_priority, 2, 1, inFile);
|
||||
fread(&evt->flags_low_priority, 2, 1, inFile);
|
||||
}else{
|
||||
fseek(inFile, 14, SEEK_CUR);
|
||||
fseek(inFile, evt->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
|
||||
}
|
||||
fread(&evt->traceLenght, 8, 1, inFile);
|
||||
if( opt == 0){
|
||||
|
@ -165,26 +168,28 @@ inline int SolReader::ReadNextBlock(int opt){
|
|||
}else{
|
||||
fseek(inFile, 1 + evt->traceLenght*4, SEEK_CUR);
|
||||
}
|
||||
}else if( evt->dataType == 2){
|
||||
}else if( evt->dataType == DataFormat::NoTrace){
|
||||
if( opt == 0 ){
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
fread(&evt->timestamp, 6, 1, inFile);
|
||||
fread(&evt->fine_timestamp, 2, 1, inFile);
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile);
|
||||
fread(&evt->timestamp, 6, 1, inFile);
|
||||
fread(&evt->fine_timestamp, 2, 1, inFile);
|
||||
fread(&evt->flags_high_priority, 1, 1, inFile);
|
||||
fread(&evt->flags_low_priority, 2, 1, inFile);
|
||||
fread(&evt->flags_low_priority, 2, 1, inFile);
|
||||
}else{
|
||||
fseek(inFile, 14, SEEK_CUR);
|
||||
fseek(inFile, evt->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
|
||||
}
|
||||
}else if( evt->dataType == 3){
|
||||
}else if( evt->dataType == DataFormat::Minimum){
|
||||
if( opt == 0 ){
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
fread(&evt->channel, 1, 1, inFile);
|
||||
fread(&evt->energy, 2, 1, inFile);
|
||||
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile);
|
||||
fread(&evt->timestamp, 6, 1, inFile);
|
||||
}else{
|
||||
fseek(inFile, 9, SEEK_CUR);
|
||||
fseek(inFile, evt->DPPType == DPPType::PHA ? 9 : 11, SEEK_CUR);
|
||||
}
|
||||
}else if( evt->dataType == 15){
|
||||
}else if( evt->dataType == DataFormat::RAW){
|
||||
fread(&evt->dataSize, 8, 1, inFile);
|
||||
if( opt == 0){
|
||||
fread(evt->data, evt->dataSize, 1, inFile);
|
||||
|
|
|
@ -436,7 +436,7 @@ int MainWindow::StartACQ(){
|
|||
|
||||
//digi[i]->SetPHADataFormat(1);// only save 1 trace
|
||||
int dataFormatID = cbDataFormat->currentData().toInt();
|
||||
digi[i]->SetPHADataFormat(dataFormatID);// only save 1 trace
|
||||
digi[i]->SetDataFormat(dataFormatID);
|
||||
|
||||
//Additional settings, it is better user to control
|
||||
//if( cbDataFormat->currentIndex() < 2 ) {
|
||||
|
|
4
makeTest
4
makeTest
|
@ -1,5 +1,5 @@
|
|||
CC = g++
|
||||
COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread
|
||||
COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread -g
|
||||
CAENLIBS = -lCAEN_FELib
|
||||
CURLLIBS = -lcurl
|
||||
|
||||
|
@ -15,7 +15,7 @@ test : test.cpp ClassDigitizer2Gen.o influxdb.o
|
|||
@echo "------- test"
|
||||
$(CC) $(COPTS) $(OBJS) -o test test.cpp $(CAENLIBS) $(CURLLIBS)
|
||||
#
|
||||
ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Event.h
|
||||
ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Event.h DigiParameters.h
|
||||
@echo "------- ClassDigitizer2Gen.o"
|
||||
$(CC) $(COPTS) -c ClassDigitizer2Gen.cpp $(CAENLIBS)
|
||||
#
|
||||
|
|
|
@ -474,7 +474,7 @@ void Scope::StartScope(){
|
|||
|
||||
}
|
||||
|
||||
digi[iDigi]->SetPHADataFormat(0);
|
||||
digi[iDigi]->SetDataFormat(0); //TODO Should be only trace?
|
||||
digi[iDigi]->StartACQ();
|
||||
|
||||
readDataThread[iDigi]->SetSaveData(false);
|
||||
|
|
16
test.cpp
16
test.cpp
|
@ -86,10 +86,22 @@ int main(int argc, char* argv[]){
|
|||
|
||||
remove("haha_000.sol");
|
||||
|
||||
const char * url = "dig2://192.168.0.100/";
|
||||
//const char * url = "dig2://192.168.0.100/";
|
||||
const char * url = "dig2://192.168.0.254/";
|
||||
|
||||
digi->OpenDigitizer(url);
|
||||
digi->Reset();
|
||||
//digi->ReadValue(PSD::DIG::CupVer, -1, true);
|
||||
digi->ReadAllSettings();
|
||||
|
||||
for( int ch = 0; ch < 64; ch++ ) {
|
||||
printf( "|%s| \n", digi->GetSettingValue(PSD::CH::TimeFilterRetriggerGuard, ch).c_str());
|
||||
}
|
||||
|
||||
|
||||
digi->SaveSettingsToFile("test_setting.txt");
|
||||
|
||||
|
||||
//digi->ProgramDPPBoard(false);
|
||||
|
||||
//printf("--------%s \n", digi->ReadChValue("0..63", "WaveAnalogprobe0", true).c_str());
|
||||
|
@ -98,7 +110,7 @@ int main(int argc, char* argv[]){
|
|||
|
||||
//printf("===================================\n");
|
||||
|
||||
printf("======== index : %d \n", digi->FindIndex(PHA::CH::ChannelEnable));
|
||||
//printf("======== index : %d \n", digi->FindIndex(PHA::CH::ChannelEnable));
|
||||
|
||||
//digi->LoadSettingsFromFile("settings_21245.dat");
|
||||
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
|
||||
|
|
Loading…
Reference in New Issue
Block a user