Compare commits
No commits in common. "35f6ee70c4d007d45e44cb5378ac10ee7e58690e" and "eef989aa5435e931ee3c484730c2dd084f2070f1" have entirely different histories.
35f6ee70c4
...
eef989aa54
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,4 +2,3 @@ test
|
||||||
test_indep
|
test_indep
|
||||||
|
|
||||||
*.o
|
*.o
|
||||||
*.sol
|
|
|
@ -31,14 +31,9 @@ void Digitizer2Gen::Initialization(){
|
||||||
netMask = "";
|
netMask = "";
|
||||||
gateway = "";
|
gateway = "";
|
||||||
|
|
||||||
outFileIndex = 0;
|
|
||||||
dataStartIndetifier = 0xA345;
|
|
||||||
outFile = NULL;
|
|
||||||
outFileSize = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//########################################### Handles functions
|
//########################## Handles functions
|
||||||
uint64_t Digitizer2Gen::GetHandle(const char * parameter){
|
uint64_t Digitizer2Gen::GetHandle(const char * parameter){
|
||||||
|
|
||||||
uint64_t par_handle;
|
uint64_t par_handle;
|
||||||
|
@ -72,10 +67,10 @@ std::string Digitizer2Gen::GetPath(uint64_t handle){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//########################################### Read Write
|
//############################ Read Write
|
||||||
std::string Digitizer2Gen::ReadValue(const char * parameter){
|
std::string Digitizer2Gen::ReadValue(const char * parameter){
|
||||||
if( !isConnected ) return "not connected";
|
if( !isConnected ) return "not connected";
|
||||||
//printf(" %s|%s \n", __func__, parameter);
|
printf(" %s|%s \n", __func__, parameter);
|
||||||
ret = CAEN_FELib_GetValue(handle, parameter, retValue);
|
ret = CAEN_FELib_GetValue(handle, parameter, retValue);
|
||||||
if (ret != CAEN_FELib_Success) return ErrorMsg(__func__);
|
if (ret != CAEN_FELib_Success) return ErrorMsg(__func__);
|
||||||
return retValue;
|
return retValue;
|
||||||
|
@ -101,7 +96,7 @@ void Digitizer2Gen::SendCommand(const char * parameter){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//########################################### Open digitizer
|
//############################## Open digitizer
|
||||||
int Digitizer2Gen::OpenDigitizer(const char * url){
|
int Digitizer2Gen::OpenDigitizer(const char * url){
|
||||||
|
|
||||||
printf("======== %s \n",__func__);
|
printf("======== %s \n",__func__);
|
||||||
|
@ -119,6 +114,7 @@ int Digitizer2Gen::OpenDigitizer(const char * url){
|
||||||
|
|
||||||
modelName = ReadValue("/par/ModelName");
|
modelName = ReadValue("/par/ModelName");
|
||||||
|
|
||||||
|
|
||||||
cupVersion = ReadValue("/par/cupver");
|
cupVersion = ReadValue("/par/cupver");
|
||||||
DPPVersion = ReadValue("/par/FPGA_FwVer");
|
DPPVersion = ReadValue("/par/FPGA_FwVer");
|
||||||
DPPType = ReadValue("/par/FwType");
|
DPPType = ReadValue("/par/FwType");
|
||||||
|
@ -177,7 +173,7 @@ int Digitizer2Gen::CloseDigitizer(){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//########################################### DAQ
|
//################################## DAQ
|
||||||
void Digitizer2Gen::StartACQ(){
|
void Digitizer2Gen::StartACQ(){
|
||||||
|
|
||||||
SendCommand("/cmd/armacquisition");
|
SendCommand("/cmd/armacquisition");
|
||||||
|
@ -191,7 +187,7 @@ void Digitizer2Gen::StopACQ(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer2Gen::SetPHADataFormat(unsigned dataFormat){
|
void Digitizer2Gen::SetPHADataFormat(){
|
||||||
|
|
||||||
ret = CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "dpppha");
|
ret = CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "dpppha");
|
||||||
if (ret != CAEN_FELib_Success) {
|
if (ret != CAEN_FELib_Success) {
|
||||||
|
@ -199,280 +195,98 @@ void Digitizer2Gen::SetPHADataFormat(unsigned dataFormat){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataFormatID = dataFormat;
|
ret = CAEN_FELib_SetReadDataFormat(ep_handle, " \
|
||||||
|
[ \
|
||||||
if( dataFormatID == 0 ){
|
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle, " \
|
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||||
[ \
|
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
||||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
{ \"name\" : \"ANALOG_PROBE_2\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
||||||
{ \"name\" : \"TIMESTAMP_NS\", \"type\" : \"U64\" }, \
|
{ \"name\" : \"DIGITAL_PROBE_1\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
|
{ \"name\" : \"DIGITAL_PROBE_2\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||||
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
{ \"name\" : \"DIGITAL_PROBE_3\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||||
{ \"name\" : \"ANALOG_PROBE_2\", \"type\" : \"I32\", \"dim\" : 1 }, \
|
{ \"name\" : \"DIGITAL_PROBE_4\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_1\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_2\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
{ \"name\" : \"ANALOG_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_3\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
{ \"name\" : \"DIGITAL_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_4\", \"type\" : \"U8\", \"dim\" : 1 }, \
|
{ \"name\" : \"DIGITAL_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
||||||
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
{ \"name\" : \"DIGITAL_PROBE_3_TYPE\", \"type\" : \"U8\" }, \
|
||||||
{ \"name\" : \"ANALOG_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
{ \"name\" : \"DIGITAL_PROBE_4_TYPE\", \"type\" : \"U8\" }, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
|
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
|
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_3_TYPE\", \"type\" : \"U8\" }, \
|
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
|
||||||
{ \"name\" : \"DIGITAL_PROBE_4_TYPE\", \"type\" : \"U8\" }, \
|
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||||
{ \"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( dataFormatID == 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( dataFormatID == 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( dataFormatID == 3 ){
|
|
||||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle, " \
|
|
||||||
[ \
|
|
||||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
|
||||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
|
||||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" } \
|
|
||||||
] \
|
|
||||||
");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != CAEN_FELib_Success) {
|
if (ret != CAEN_FELib_Success) {
|
||||||
ErrorMsg("Set Read Data Format");
|
ErrorMsg("Set Read Data Format");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Digitizer2Gen::ReadData(){
|
struct event {
|
||||||
//printf("========= %s \n", __func__);
|
uint8_t channel;
|
||||||
|
uint64_t timestamp;
|
||||||
|
double timestamp_us;
|
||||||
|
uint16_t fine_timestamp;
|
||||||
|
uint16_t energy;
|
||||||
|
uint16_t flags_low_priority;
|
||||||
|
uint16_t flags_high_priority;
|
||||||
|
size_t event_size;
|
||||||
|
int32_t* analog_probes[2];
|
||||||
|
uint8_t* digital_probes[4];
|
||||||
|
uint8_t analog_probes_type[2];
|
||||||
|
uint8_t digital_probes_type[4];
|
||||||
|
size_t n_allocated_samples;
|
||||||
|
size_t n_samples;
|
||||||
|
};
|
||||||
|
|
||||||
if( dataFormatID == 0){
|
void Digitizer2Gen::ReadData(){
|
||||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
printf("========= %s \n", __func__);
|
||||||
&evt.channel,
|
|
||||||
&evt.timestamp,
|
|
||||||
&evt.fine_timestamp,
|
|
||||||
&evt.timestamp_ns,
|
|
||||||
&evt.energy,
|
|
||||||
&evt.analog_probes0,
|
|
||||||
&evt.analog_probes1,
|
|
||||||
&evt.digital_probes0,
|
|
||||||
&evt.digital_probes1,
|
|
||||||
&evt.digital_probes2,
|
|
||||||
&evt.digital_probes3,
|
|
||||||
&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.timestamp_us = (evt.timestamp*8 + evt.fine_timestamp*0.0078125)/1000.;
|
|
||||||
}else if( dataFormatID == 1){
|
|
||||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
|
||||||
&evt.channel,
|
|
||||||
&evt.timestamp,
|
|
||||||
&evt.fine_timestamp,
|
|
||||||
&evt.energy,
|
|
||||||
&evt.analog_probes0,
|
|
||||||
&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( dataFormatID == 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( dataFormatID == 3){
|
|
||||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
|
||||||
&evt.channel,
|
|
||||||
&evt.timestamp,
|
|
||||||
&evt.energy
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
return CAEN_FELib_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
event evt;
|
||||||
|
|
||||||
|
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.n_samples,
|
||||||
|
evt.flags_low_priority,
|
||||||
|
evt.flags_high_priority,
|
||||||
|
evt.event_size
|
||||||
|
);
|
||||||
|
|
||||||
if( ret != CAEN_FELib_Success) {
|
if( ret != CAEN_FELib_Success) {
|
||||||
ErrorMsg("Set Read Data");
|
ErrorMsg("Set Read Data");
|
||||||
return ret;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer2Gen::ReadDataRaw(){
|
//##########################################
|
||||||
|
void Digitizer2Gen::ProgramPHA(){
|
||||||
}
|
|
||||||
//###########################################
|
|
||||||
|
|
||||||
void Digitizer2Gen::OpenOutFile(std::string fileName){
|
|
||||||
outFileNameBase = fileName;
|
|
||||||
sprintf(outFileName, "%s_%03d.sol", fileName.c_str(), outFileIndex);
|
|
||||||
outFile = fopen(outFileName, "a+");
|
|
||||||
fseek(outFile, 0L, SEEK_END);
|
|
||||||
outFileSize = ftell(outFile); // unsigned int = Max ~4GB
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Digitizer2Gen::CloseOutFile(){
|
|
||||||
fclose(outFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Digitizer2Gen::SaveDataToFile(){
|
|
||||||
|
|
||||||
if( outFileSize > (unsigned int) MaxOutFileSize){
|
|
||||||
fclose(outFile);
|
|
||||||
outFileIndex ++;
|
|
||||||
sprintf(outFileName, "%s_%03d.sol", outFileNameBase.c_str(), outFileIndex);
|
|
||||||
outFile = fopen(outFileName, "a+");
|
|
||||||
}
|
|
||||||
|
|
||||||
if( dataFormatID == 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);
|
|
||||||
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_probes0, evt.traceLenght*4, 1, outFile);
|
|
||||||
}else if( dataFormatID == 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);
|
|
||||||
fwrite(&evt.analog_probes_type[0], 1, 1, outFile);
|
|
||||||
fwrite(evt.analog_probes0, evt.traceLenght*4, 1, outFile);
|
|
||||||
}else if( dataFormatID == 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);
|
|
||||||
fwrite(&evt.flags_high_priority, 1, 1, outFile);
|
|
||||||
fwrite(&evt.flags_low_priority, 2, 1, outFile);
|
|
||||||
}else if( dataFormatID == 3){
|
|
||||||
//fwrite(&dataStartIndetifier, 2, 1, outFile);
|
|
||||||
fwrite(&evt.channel, 1, 1, outFile);
|
|
||||||
fwrite(&evt.energy, 2, 1, outFile);
|
|
||||||
fwrite(&evt.timestamp, 6, 1, outFile);
|
|
||||||
}
|
|
||||||
// tested speed, 64 readout and save cost ~ 200 us. ~ 5 kHz;
|
|
||||||
|
|
||||||
//fwrite(evt.digital_probes_type, sizeof(evt.digital_probes_type), 1, outFile);
|
|
||||||
//fwrite(evt.analog_probes1, evt.traceLenght*4, 1, outFile);
|
|
||||||
//fwrite(evt.digital_probes0, evt.traceLenght, 1, outFile);
|
|
||||||
//fwrite(evt.digital_probes1, evt.traceLenght, 1, outFile);
|
|
||||||
//fwrite(evt.digital_probes2, evt.traceLenght, 1, outFile);
|
|
||||||
//fwrite(evt.digital_probes3, evt.traceLenght, 1, outFile);
|
|
||||||
//fwrite(evt.GetWord1(), 8, 1, outFile);
|
|
||||||
//fwrite(evt.GetWord2(), 8, 1, outFile);
|
|
||||||
//fwrite(evt.GetWord3(), 8, 1, outFile);
|
|
||||||
//fwrite(evt.GetWord4(), 8, 1, outFile);
|
|
||||||
//for(int i = 0; i < evt.traceLenght; i++){
|
|
||||||
// fwrite(evt.GetWordTrace(i), 8, 1, outFile);
|
|
||||||
//}
|
|
||||||
|
|
||||||
outFileSize = ftell(outFile); // unsigned int = Max ~4GB
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//###########################################
|
|
||||||
void Digitizer2Gen::ProgramPHA(bool testPulse){
|
|
||||||
if( !isConnected ) return ;
|
if( !isConnected ) return ;
|
||||||
|
|
||||||
// Channel enable
|
// Channel enable
|
||||||
WriteValue("/ch/0..63/par/ChEnable" , "true");
|
WriteValue("/ch/0..63/par/ChEnable" , "true");
|
||||||
|
|
||||||
// Global trigger configuration
|
// Global trigger configuration
|
||||||
if( testPulse ) {
|
///WriteValue("/par/GlobalTriggerSource", "SwTrg");
|
||||||
WriteValue("/par/GlobalTriggerSource", "SwTrg | TestPulse");
|
WriteValue("/par/GlobalTriggerSource", "SwTrg | TestPulse");
|
||||||
}else{
|
WriteValue("/par/TestPulsePeriod" , "100000000");
|
||||||
WriteValue("/par/GlobalTriggerSource", "SwTrg");
|
|
||||||
}
|
|
||||||
WriteValue("/par/TestPulsePeriod" , "25000"); // 0.05 msec = 20kHz
|
|
||||||
WriteValue("/par/TestPulseWidth" , "16");
|
WriteValue("/par/TestPulseWidth" , "16");
|
||||||
|
|
||||||
// Wave configuration
|
// Wave configuration
|
||||||
|
|
|
@ -8,61 +8,6 @@
|
||||||
|
|
||||||
//#include "Parameter.h"
|
//#include "Parameter.h"
|
||||||
|
|
||||||
#define MaxOutFileSize 2*1024*1024*1024
|
|
||||||
#define MaxTraceLenght 2048
|
|
||||||
#define DataStartIndetifier 0xA345
|
|
||||||
|
|
||||||
struct event {
|
|
||||||
uint8_t channel; // 6 bit
|
|
||||||
uint16_t energy; // 16 bit
|
|
||||||
uint64_t timestamp; // 48 bit
|
|
||||||
uint16_t fine_timestamp; // 16 bit
|
|
||||||
uint64_t timestamp_ns; // 51 bit fine_timestamp not included
|
|
||||||
double timestamp_us;
|
|
||||||
uint16_t flags_low_priority; // 12 bit
|
|
||||||
uint16_t flags_high_priority; // 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_probes0[MaxTraceLenght]; // 18 bit
|
|
||||||
int32_t analog_probes1[MaxTraceLenght];
|
|
||||||
uint8_t digital_probes0[MaxTraceLenght]; // 1 bit
|
|
||||||
uint8_t digital_probes1[MaxTraceLenght];
|
|
||||||
uint8_t digital_probes2[MaxTraceLenght];
|
|
||||||
uint8_t digital_probes3[MaxTraceLenght];
|
|
||||||
uint16_t trigger_threashold; // 16 bit
|
|
||||||
size_t event_size; // 64 bit
|
|
||||||
uint32_t aggCounter; // 32 bit
|
|
||||||
|
|
||||||
void PrintEnergyTimeStamp(){
|
|
||||||
printf("ch: %2d, energy: %u, timestamp: %lu ch, traceLenght: %lu\n", channel, energy, timestamp, traceLenght);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintAll(){
|
|
||||||
printf("============== ch : %2d (0x%2X), fail: %d, flush: %d\n", channel, channel, board_fail, flush);
|
|
||||||
printf("energy: %u, timestamp: %lu, fine_timestamp: %u \n", energy, timestamp, fine_timestamp);
|
|
||||||
printf("flag (high): 0x%2X, (low): 0x%3X, traceLength: %lu\n", flags_high_priority, flags_low_priority, traceLenght);
|
|
||||||
printf("Agg counter : %u, trigger : %u, downSampling: %u \n", aggCounter, trigger_threashold, downSampling);
|
|
||||||
printf("AnaProbe Type: %u, %u\n", analog_probes_type[0], analog_probes_type[1]);
|
|
||||||
printf("DigProbe Type: %u, %u, %u, %u\n", digital_probes_type[0], digital_probes_type[1], digital_probes_type[2], digital_probes_type[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintTrace(){
|
|
||||||
for(int i = 0; i < traceLenght; i++){
|
|
||||||
printf("%4d| %6d %6d %1d %1d %1d %1d\n", i, analog_probes0[i],
|
|
||||||
analog_probes1[i],
|
|
||||||
digital_probes0[i],
|
|
||||||
digital_probes1[i],
|
|
||||||
digital_probes2[i],
|
|
||||||
digital_probes3[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class Digitizer2Gen {
|
class Digitizer2Gen {
|
||||||
private:
|
private:
|
||||||
uint64_t handle;
|
uint64_t handle;
|
||||||
|
@ -87,24 +32,11 @@ class Digitizer2Gen {
|
||||||
std::string netMask;
|
std::string netMask;
|
||||||
std::string gateway;
|
std::string gateway;
|
||||||
|
|
||||||
|
|
||||||
void Initialization();
|
void Initialization();
|
||||||
|
|
||||||
std::string ErrorMsg(const char * funcName);
|
std::string ErrorMsg(const char * funcName);
|
||||||
|
|
||||||
unsigned int dataFormatID; // 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
|
|
||||||
|
|
||||||
|
|
||||||
unsigned short outFileIndex;
|
|
||||||
unsigned short dataStartIndetifier;
|
|
||||||
std::string outFileNameBase;
|
|
||||||
char outFileName[100];
|
|
||||||
FILE * outFile;
|
|
||||||
unsigned int outFileSize;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Digitizer2Gen();
|
Digitizer2Gen();
|
||||||
~Digitizer2Gen();
|
~Digitizer2Gen();
|
||||||
|
@ -123,20 +55,15 @@ class Digitizer2Gen {
|
||||||
void StartACQ();
|
void StartACQ();
|
||||||
void StopACQ();
|
void StopACQ();
|
||||||
|
|
||||||
void SetPHADataFormat(unsigned dataFormat);
|
void SetPHADataFormat();
|
||||||
int ReadData();
|
void ReadData();
|
||||||
void ReadDataRaw(); //not impletmented
|
|
||||||
|
|
||||||
void ProgramPHA(bool testPulse = false);
|
void ProgramPHA();
|
||||||
|
|
||||||
unsigned short GetNChannels() {return nChannels;}
|
unsigned short GetNChannels() {return nChannels;}
|
||||||
unsigned short GetCh2ns() {return ch2ns;}
|
unsigned short GetCh2ns() {return ch2ns;}
|
||||||
uint64_t GetHandle() {return handle;}
|
uint64_t GetHandle() {return handle;}
|
||||||
|
|
||||||
event evt;
|
|
||||||
void OpenOutFile(std::string fileName);
|
|
||||||
void CloseOutFile();
|
|
||||||
void SaveDataToFile();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -2,8 +2,6 @@ CC = g++
|
||||||
COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread
|
COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread
|
||||||
CAENLIBS = -lCAEN_FELib
|
CAENLIBS = -lCAEN_FELib
|
||||||
|
|
||||||
all: test test_indep ClassDigitizer2Gen.o
|
|
||||||
|
|
||||||
test_indep : test_indep.cpp
|
test_indep : test_indep.cpp
|
||||||
$(CC) $(COPTS) -o test_indep test_indep.cpp $(CAENLIBS)
|
$(CC) $(COPTS) -o test_indep test_indep.cpp $(CAENLIBS)
|
||||||
|
|
||||||
|
|
35
test.cpp
35
test.cpp
|
@ -2,7 +2,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h> // time in nano-sec
|
|
||||||
|
|
||||||
#include "ClassDigitizer2Gen.h"
|
#include "ClassDigitizer2Gen.h"
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ int main(int argc, char* argv[]){
|
||||||
Digitizer2Gen * digi = new Digitizer2Gen();
|
Digitizer2Gen * digi = new Digitizer2Gen();
|
||||||
|
|
||||||
digi->OpenDigitizer(url);
|
digi->OpenDigitizer(url);
|
||||||
digi->ProgramPHA(true);
|
digi->ProgramPHA();
|
||||||
|
|
||||||
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
|
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
|
||||||
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
|
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
|
||||||
|
@ -49,42 +48,16 @@ int main(int argc, char* argv[]){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
digi->SetPHADataFormat(1);
|
digi->SetPHADataFormat();
|
||||||
|
|
||||||
digi->OpenOutFile("haha");
|
|
||||||
|
|
||||||
digi->StartACQ();
|
digi->StartACQ();
|
||||||
|
|
||||||
timespec t0, t1;
|
usleep(1e6);
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &t0);
|
//digi->ReadData();
|
||||||
for( int i = 0; i < 64*20; i++){
|
|
||||||
int ret = digi->ReadData();
|
|
||||||
|
|
||||||
if( ret == CAEN_FELib_Success){
|
|
||||||
//digi->evt.PrintAll();
|
|
||||||
//digi->evt.PrintTrace();
|
|
||||||
//printf("0x%016lX \n", *(digi->evt.GetWord1()));
|
|
||||||
//printf("0x%016lX \n", *(digi->evt.GetWord2()));
|
|
||||||
//printf("0x%016lX \n", *(digi->evt.GetWord3()));
|
|
||||||
//printf("0x%016lX \n", *(digi->evt.GetWord4()));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
digi->SaveDataToFile();
|
|
||||||
|
|
||||||
if( digi->evt.channel == 63 ) {
|
|
||||||
clock_gettime(CLOCK_REALTIME, &t1);
|
|
||||||
printf("%5d | t1-t0 : %10ld\n", i, t1.tv_nsec-t0.tv_nsec);
|
|
||||||
t0 = t1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
digi->StopACQ();
|
digi->StopACQ();
|
||||||
|
|
||||||
digi->CloseOutFile();
|
|
||||||
|
|
||||||
digi->CloseDigitizer();
|
digi->CloseDigitizer();
|
||||||
|
|
||||||
|
|
220
test_indep.cpp
220
test_indep.cpp
|
@ -4,123 +4,10 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <time.h> // time in nano-sec
|
|
||||||
|
|
||||||
void RawDecorder(uint8_t * data, size_t size, int verbose = 0){
|
|
||||||
uint64_t haha ;
|
|
||||||
unsigned short dataType;
|
|
||||||
|
|
||||||
int word = 0;
|
|
||||||
int traceWord = -2;
|
|
||||||
for( int i =0 ; i < ((int)size / 8) ; i++){
|
|
||||||
|
|
||||||
///the data is array of 1 byte.
|
|
||||||
/// by get the point of the data[8*i]
|
|
||||||
/// cast it into uint64_t pointer, that will get 8 bytes all togteher
|
|
||||||
/// get this point value, and bit swap it.
|
|
||||||
haha = __builtin_bswap64(*(uint64_t *)&(data[8*i]));
|
|
||||||
if (verbose > 0 ) printf("%7d | %3d | %3d | 0x%016lX \n", i, word, traceWord, haha);
|
|
||||||
|
|
||||||
if ( word == 0 ){ /// aggregation header, or start header, or end header
|
|
||||||
dataType = ( haha >> 56 ) & 0xFF ;
|
|
||||||
if ( verbose> 0 & dataType == 0x30 ) printf("====== start Run data\n");
|
|
||||||
if ( verbose> 0 & dataType == 0x32 ) printf("====== Stop Run data\n");
|
|
||||||
if ( verbose> 0 & (dataType >> 4) == 0x2 ) printf("====== data aggregation start\n");
|
|
||||||
}else{
|
|
||||||
|
|
||||||
|
|
||||||
if( dataType == 0x30 ){
|
|
||||||
if( word == 1){
|
|
||||||
if( (haha & 0xFFFFFFFF) != 0x2000000) printf("*** something wrong.\n");
|
|
||||||
}
|
|
||||||
uint64_t channelMask;
|
|
||||||
if( word == 2){
|
|
||||||
channelMask = ( haha & 0xFFFFFFFF );
|
|
||||||
}
|
|
||||||
if( word == 3){
|
|
||||||
channelMask += (( haha & 0xFFFFFFFF ) << 32);
|
|
||||||
if (verbose > 0 ) printf("Channel mask : 0x%016lX\n", channelMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (dataType >> 4 ) == 0x2 ) {
|
|
||||||
unsigned short chID ;
|
|
||||||
uint64_t timestamp ;
|
|
||||||
bool hasTrace;
|
|
||||||
unsigned short fl ; // flag low
|
|
||||||
unsigned short fh ; // flog hight
|
|
||||||
unsigned short energy ;
|
|
||||||
unsigned short fTime ;
|
|
||||||
|
|
||||||
unsigned short traceLength;
|
|
||||||
|
|
||||||
unsigned short anaProb0[512];
|
|
||||||
unsigned short anaProb1[512];
|
|
||||||
bool digProb0[512];
|
|
||||||
bool digProb1[512];
|
|
||||||
bool digProb2[512];
|
|
||||||
bool digProb3[512];
|
|
||||||
|
|
||||||
if( word == 1){
|
|
||||||
chID = ((haha >> 56) & 0x7F);
|
|
||||||
timestamp = (haha & 0xFFFFFFFFFFFF);
|
|
||||||
}else if( word == 2){
|
|
||||||
hasTrace = ((haha >> 62) & 0x1);
|
|
||||||
fl = (( haha >> 50) & 0x1FFF);
|
|
||||||
fh = (( haha >> 41) & 0xFF);
|
|
||||||
energy = (haha & 0xFFFF);
|
|
||||||
fTime = ((haha >> 15) & 0x7FF);
|
|
||||||
}else{
|
|
||||||
if( ((haha >> 63) & 0x1 ) == 1 && traceWord == -2) {
|
|
||||||
//printf("=====last word of header\n");
|
|
||||||
traceWord = 0;
|
|
||||||
|
|
||||||
if (verbose > 0 ) printf("ch %2d, energy %5u, time %10lu, fTime %5u %10.2f ms 0x%X, 0x%X, %u\n",
|
|
||||||
chID, energy, timestamp, fTime, (timestamp*8 + fTime*0.0078125) / 1e+6 , fl, fh, hasTrace);
|
|
||||||
|
|
||||||
word ++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( hasTrace) {
|
|
||||||
if( traceWord == 0) {
|
|
||||||
traceLength = (haha & 0xFFF );
|
|
||||||
word ++;
|
|
||||||
traceWord ++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( traceWord > 0 ){
|
|
||||||
anaProb0[traceWord-1] = (haha & 0x3FFF);
|
|
||||||
anaProb1[traceWord-1] = ((haha >> 16) & 0x3FFF);
|
|
||||||
digProb0[traceWord-1] = ((haha >> 14) & 0x1);
|
|
||||||
digProb1[traceWord-1] = ((haha >> 15) & 0x1);
|
|
||||||
digProb2[traceWord-1] = ((haha >> 30) & 0x1);
|
|
||||||
digProb3[traceWord-1] = ((haha >> 31) & 0x1);
|
|
||||||
|
|
||||||
traceWord ++;
|
|
||||||
|
|
||||||
if( traceWord - 1 == traceLength ){
|
|
||||||
//printf("============= end of one data, traceLength = %d\n", traceLength);
|
|
||||||
word = 0;
|
|
||||||
traceWord = -2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
word++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
timespec t0, t1, t2;
|
|
||||||
|
|
||||||
//#################################### Open digitizer
|
//#################################### Open digitizer
|
||||||
uint64_t dev_handle;
|
uint64_t dev_handle;
|
||||||
|
@ -144,20 +31,20 @@ int main(){
|
||||||
|
|
||||||
/// Global trigger configuration
|
/// Global trigger configuration
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/par/GlobalTriggerSource", "SwTrg | TestPulse"); // use test Pulse
|
ret = CAEN_FELib_SetValue(dev_handle, "/par/GlobalTriggerSource", "SwTrg | TestPulse"); // use test Pulse
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulsePeriod", "1000000"); /// ns, 1 msec
|
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulsePeriod", "100000000"); /// ns
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulseWidth", "16"); ///ns
|
ret = CAEN_FELib_SetValue(dev_handle, "/par/TestPulseWidth", "16"); ///ns
|
||||||
|
|
||||||
/// Wave configuration
|
/// Wave configuration
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChRecordLengthS", "512"); // when setting sample, the ChRecordLengthT will not set. vice versa
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChRecordLengthS", "512");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveTriggerSource", "GlobalTriggerSource");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveTriggerSource", "GlobalTriggerSource");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveResolution", "RES8"); // 8 ns
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveResolution", "RES8");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe0", "ADCInput");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe0", "ADCInput");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe1", "TimeFilter");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveAnalogProbe1", "TimeFilter");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe0", "Trigger");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe0", "Trigger");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe1", "TimeFilterArmed");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe1", "TimeFilterArmed");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe2", "EnergyFilterBaselineFreeze");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe2", "EnergyFilterBaselineFreeze");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe3", "EnergyFilterPeakReady");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/WaveDigitalProbe3", "EnergyFilterPeakReady");
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChPreTriggerS", "100");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/ChPreTriggerS", "200");
|
||||||
|
|
||||||
/// Event configuration
|
/// Event configuration
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
|
||||||
|
@ -178,17 +65,8 @@ int main(){
|
||||||
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EnergyFilterFineGain", "1.0");
|
ret = CAEN_FELib_SetValue(dev_handle, "/ch/0..63/par/EnergyFilterFineGain", "1.0");
|
||||||
|
|
||||||
|
|
||||||
if( ret != CAEN_FELib_Success) printf("errro in set value\n");
|
|
||||||
|
|
||||||
//#################################### setting readout
|
|
||||||
ret = CAEN_FELib_GetValue(dev_handle, "/ch/10/par/ChRecordLengthS", value);
|
|
||||||
if( ret != CAEN_FELib_Success) printf("errro in get value\n");
|
|
||||||
|
|
||||||
|
|
||||||
printf("trace length : %s sample\n", value);
|
|
||||||
|
|
||||||
//#################################### Set the end point for data
|
//#################################### Set the end point for data
|
||||||
/*
|
|
||||||
{//----------------------- RAW
|
{//----------------------- RAW
|
||||||
uint64_t ep_handle;
|
uint64_t ep_handle;
|
||||||
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/raw", &ep_handle);
|
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/raw", &ep_handle);
|
||||||
|
@ -207,7 +85,7 @@ int main(){
|
||||||
);
|
);
|
||||||
|
|
||||||
uint8_t* data = new uint8_t[200000];
|
uint8_t* data = new uint8_t[200000];
|
||||||
size_t size; /// number of byte of the data, size/8 = word [64 bits]
|
size_t size; /// number of byte of the data
|
||||||
uint32_t n_events;
|
uint32_t n_events;
|
||||||
|
|
||||||
printf("Starting ACQ\n");
|
printf("Starting ACQ\n");
|
||||||
|
@ -215,25 +93,70 @@ int main(){
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
for( int i = 0; i < 2; i++){
|
||||||
|
|
||||||
for( int i = 0; i < 10; i++){
|
usleep(10000);
|
||||||
|
|
||||||
//usleep(1000000);
|
|
||||||
clock_gettime(CLOCK_REALTIME, &t0);
|
|
||||||
|
|
||||||
ret = CAEN_FELib_ReadData(ep_handle, 100, data, &size, &n_events );
|
ret = CAEN_FELib_ReadData(ep_handle, 100, data, &size, &n_events );
|
||||||
count ++;
|
count ++;
|
||||||
clock_gettime(CLOCK_REALTIME, &t1);
|
|
||||||
|
|
||||||
if( ret == CAEN_FELib_Success ) {
|
if( ret == CAEN_FELib_Success ) {
|
||||||
printf("================= %u, %ld byte, %d \n", n_events, size, count);
|
printf("================= %u, %ld, %d \n", n_events, size, count);
|
||||||
|
|
||||||
RawDecorder(data, size);
|
uint64_t haha ;
|
||||||
clock_gettime(CLOCK_REALTIME, &t2);
|
unsigned short dataType;
|
||||||
printf("t2-t1 : %ld\n", t2.tv_nsec-t1.tv_nsec);
|
|
||||||
|
int word = 0;
|
||||||
|
for( int i =0 ; i < std::min((int)size / 8, 100) ; i++){
|
||||||
|
|
||||||
|
///the data is array of 1 byte.
|
||||||
|
/// by get the point of the data[8*i]
|
||||||
|
/// cast it into uint64_t pointer, that will get 8 bytes all togteher
|
||||||
|
/// get this point value, and bit swap it.
|
||||||
|
haha = __builtin_bswap64(*(uint64_t *)&(data[8*i]));
|
||||||
|
printf("%7d | 0x%016lX \n", i, haha);
|
||||||
|
|
||||||
|
|
||||||
|
if ( word == 0 ){ /// aggregation header, or start header, or end header
|
||||||
|
dataType = ( haha >> 55 ) & 0xFF ;
|
||||||
|
if ( dataType == 0x30 ){ /// start Run data
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dataType == 0x32 ){ /// stop Run data
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (dataType >> 4) == 0x2 ){ /// data aggregation
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( word == 1 ){
|
||||||
|
unsigned short channel = ((haha >> 56) & 0x7F);
|
||||||
|
unsigned short SE = ((haha >> 55) & 0x1);
|
||||||
|
uint64_t timestamp = (haha & 0xFFFFFFFFFFFF);
|
||||||
|
printf("ch %u, SE %u, %llu \n", channel, SE, timestamp);
|
||||||
|
}
|
||||||
|
if ( word == 2 ){
|
||||||
|
unsigned short W = ((haha >> 62) & 0x1);
|
||||||
|
unsigned short fl = (( haha >> 50) & 0x1FFF);
|
||||||
|
unsigned short fh = (( haha >> 41) & 0xFF);
|
||||||
|
unsigned short energy = (haha & 0xFFFF);
|
||||||
|
unsigned short fTime = ((haha >> 15) & 7FF);
|
||||||
|
|
||||||
|
printf("energy %u, fTiem %u, fl %u, fh %u, W %u\n", energy, fTime, fl, fh, W);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
word++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
printf("t1-t0 : %ld\n", t1.tv_nsec-t0.tv_nsec);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,8 +164,8 @@ int main(){
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/disarmacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/disarmacquisition");
|
||||||
|
|
||||||
}
|
}
|
||||||
/**/
|
|
||||||
|
|
||||||
|
/**
|
||||||
{//------------------------ DPPPHA
|
{//------------------------ DPPPHA
|
||||||
uint64_t ep_handle;
|
uint64_t ep_handle;
|
||||||
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/dpppha", &ep_handle);
|
ret = CAEN_FELib_GetHandle(dev_handle, "/endpoint/dpppha", &ep_handle);
|
||||||
|
@ -308,14 +231,11 @@ int main(){
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/armacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/armacquisition");
|
||||||
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
ret = CAEN_FELib_SendCommand(dev_handle, "/cmd/swstartacquisition");
|
||||||
|
|
||||||
timespec tsum;
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for( int i = 0; i < 64*5; i++){
|
for( int i = 0; i < 10; i++){
|
||||||
|
|
||||||
//usleep(10000);
|
usleep(10000);
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &t0);
|
|
||||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||||
&channel,
|
&channel,
|
||||||
×tamp,
|
×tamp,
|
||||||
|
@ -339,18 +259,6 @@ int main(){
|
||||||
&event_size
|
&event_size
|
||||||
);
|
);
|
||||||
count ++;
|
count ++;
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &t1);
|
|
||||||
printf("%3d | t1-t0 : %ld\n", i, t1.tv_nsec-t0.tv_nsec);
|
|
||||||
|
|
||||||
tsum.tv_nsec += t1.tv_nsec-t0.tv_nsec;
|
|
||||||
|
|
||||||
if( channel == 63) {
|
|
||||||
printf("================###################=== tsum : %ld\n", tsum.tv_nsec);
|
|
||||||
tsum.tv_nsec = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( ret == CAEN_FELib_Success ) {
|
if( ret == CAEN_FELib_Success ) {
|
||||||
printf("================= %ld, %d \n", event_size, count);
|
printf("================= %ld, %d \n", event_size, count);
|
||||||
printf("ch : %u, energy : %u, time : %lu, fTime : %u \n", channel, energy, timestamp, fine_timestamp);
|
printf("ch : %u, energy : %u, time : %lu, fTime : %u \n", channel, energy, timestamp, fine_timestamp);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user