added read raw data (but very slow, seperated the Event into Event.h
This commit is contained in:
parent
35f6ee70c4
commit
338aeb0475
|
@ -32,10 +32,12 @@ void Digitizer2Gen::Initialization(){
|
|||
gateway = "";
|
||||
|
||||
outFileIndex = 0;
|
||||
dataStartIndetifier = 0xA345;
|
||||
dataStartIndetifier = 0xAAA0;
|
||||
outFile = NULL;
|
||||
outFileSize = 0;
|
||||
|
||||
evt = NULL;
|
||||
|
||||
}
|
||||
|
||||
//########################################### Handles functions
|
||||
|
@ -145,20 +147,7 @@ int Digitizer2Gen::OpenDigitizer(const char * url){
|
|||
printf(" ADC bits : %d\n", adcBits);
|
||||
printf(" ADC rate : %d Msps, ch2ns : %d ns\n", adcRate, ch2ns);
|
||||
printf(" Channels : %d\n", nChannels);
|
||||
|
||||
|
||||
///========== get endpoint and endpoint folder handle
|
||||
ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppha", &ep_handle);
|
||||
if (ret != CAEN_FELib_Success) {
|
||||
ErrorMsg("Get Handle");
|
||||
return -2;
|
||||
}
|
||||
|
||||
ret = CAEN_FELib_GetParentHandle(ep_handle, NULL, &ep_folder_handle);
|
||||
if (ret != CAEN_FELib_Success) {
|
||||
ErrorMsg("GetParentHandle");
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
||||
///SendCommand("/cmd/reset");
|
||||
|
||||
|
@ -193,17 +182,36 @@ void Digitizer2Gen::StopACQ(){
|
|||
|
||||
void Digitizer2Gen::SetPHADataFormat(unsigned dataFormat){
|
||||
|
||||
ret = CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "dpppha");
|
||||
if (ret != CAEN_FELib_Success) {
|
||||
ErrorMsg("Set active endpoint");
|
||||
return;
|
||||
///========== get endpoint and endpoint folder handle
|
||||
if( dataFormat < 15 ){
|
||||
|
||||
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 (ret != CAEN_FELib_Success) {
|
||||
ErrorMsg("Set active endpoint");
|
||||
return;
|
||||
}
|
||||
|
||||
}else{
|
||||
ret = CAEN_FELib_GetHandle(handle, "/endpoint/raw", &ep_handle);
|
||||
ret |= CAEN_FELib_GetParentHandle(ep_handle, NULL, &ep_folder_handle);
|
||||
ret |= CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "raw");
|
||||
|
||||
if (ret != CAEN_FELib_Success) {
|
||||
ErrorMsg("Set active endpoint");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dataFormatID = dataFormat;
|
||||
|
||||
if( dataFormatID == 0 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle, " \
|
||||
[ \
|
||||
evt = new Event();
|
||||
evt->SetDataType(dataFormat);
|
||||
dataStartIndetifier += dataFormat;
|
||||
|
||||
if( dataFormat == 0 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
|
@ -230,13 +238,12 @@ void Digitizer2Gen::SetPHADataFormat(unsigned dataFormat){
|
|||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
] \
|
||||
");
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormatID == 1 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle, " \
|
||||
[ \
|
||||
if( dataFormat == 1 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
|
@ -252,13 +259,12 @@ void Digitizer2Gen::SetPHADataFormat(unsigned dataFormat){
|
|||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
] \
|
||||
");
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormatID == 2 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle, " \
|
||||
[ \
|
||||
if( dataFormat == 2 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
|
||||
|
@ -271,18 +277,26 @@ void Digitizer2Gen::SetPHADataFormat(unsigned dataFormat){
|
|||
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
|
||||
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
|
||||
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
|
||||
] \
|
||||
");
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormatID == 3 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle, " \
|
||||
[ \
|
||||
if( dataFormat == 3 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
"[ \
|
||||
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
|
||||
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
|
||||
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" } \
|
||||
] \
|
||||
");
|
||||
]");
|
||||
}
|
||||
|
||||
if( dataFormat == 15 ){
|
||||
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
|
||||
" [ \
|
||||
{ \"name\": \"DATA\", \"type\": \"U8\", \"dim\": 1 }, \
|
||||
{ \"name\": \"SIZE\", \"type\": \"SIZE_T\" }, \
|
||||
{ \"name\": \"N_EVENTS\", \"type\": \"U32\" } \
|
||||
]"
|
||||
);
|
||||
}
|
||||
|
||||
if (ret != CAEN_FELib_Success) {
|
||||
|
@ -294,75 +308,77 @@ void Digitizer2Gen::SetPHADataFormat(unsigned dataFormat){
|
|||
int Digitizer2Gen::ReadData(){
|
||||
//printf("========= %s \n", __func__);
|
||||
|
||||
if( dataFormatID == 0){
|
||||
if( evt->dataType == 0){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&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->channel,
|
||||
&evt->timestamp,
|
||||
&evt->fine_timestamp,
|
||||
&evt->timestamp_ns,
|
||||
&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
|
||||
);
|
||||
evt.timestamp_us = (evt.timestamp*8 + evt.fine_timestamp*0.0078125)/1000.;
|
||||
}else if( dataFormatID == 1){
|
||||
}else if( evt->dataType == 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
|
||||
&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( dataFormatID == 2){
|
||||
}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
|
||||
&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){
|
||||
}else if( evt->dataType == 3){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100,
|
||||
&evt.channel,
|
||||
&evt.timestamp,
|
||||
&evt.energy
|
||||
&evt->channel,
|
||||
&evt->timestamp,
|
||||
&evt->energy
|
||||
);
|
||||
}else if( evt->dataType == 15){
|
||||
ret = CAEN_FELib_ReadData(ep_handle, 100, evt->data, &evt->dataSize, &evt->n_events );
|
||||
//printf("data size: %lu byte\n", evt.dataSize);
|
||||
}else{
|
||||
return CAEN_FELib_UNKNOWN;
|
||||
}
|
||||
|
@ -402,58 +418,57 @@ void Digitizer2Gen::SaveDataToFile(){
|
|||
outFile = fopen(outFileName, "a+");
|
||||
}
|
||||
|
||||
if( dataFormatID == 0){
|
||||
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);
|
||||
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(&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->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);
|
||||
fwrite(&evt.analog_probes_type[0], 1, 1, outFile);
|
||||
fwrite(evt.analog_probes0, evt.traceLenght*4, 1, outFile);
|
||||
}else if( dataFormatID == 2){
|
||||
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_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);
|
||||
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);
|
||||
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( evt->dataType == 3){
|
||||
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(evt->data, evt->dataSize, 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
|
||||
|
||||
}
|
||||
|
@ -472,7 +487,7 @@ void Digitizer2Gen::ProgramPHA(bool testPulse){
|
|||
}else{
|
||||
WriteValue("/par/GlobalTriggerSource", "SwTrg");
|
||||
}
|
||||
WriteValue("/par/TestPulsePeriod" , "25000"); // 0.05 msec = 20kHz
|
||||
WriteValue("/par/TestPulsePeriod" , "500000"); // 0.5 msec = 2kHz
|
||||
WriteValue("/par/TestPulseWidth" , "16");
|
||||
|
||||
// Wave configuration
|
||||
|
|
|
@ -6,62 +6,10 @@
|
|||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include "Event.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 {
|
||||
private:
|
||||
|
@ -91,12 +39,6 @@ class Digitizer2Gen {
|
|||
|
||||
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;
|
||||
|
@ -123,7 +65,11 @@ class Digitizer2Gen {
|
|||
void StartACQ();
|
||||
void StopACQ();
|
||||
|
||||
void SetPHADataFormat(unsigned dataFormat);
|
||||
void SetPHADataFormat(unsigned 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
|
||||
int ReadData();
|
||||
void ReadDataRaw(); //not impletmented
|
||||
|
||||
|
@ -133,7 +79,7 @@ class Digitizer2Gen {
|
|||
unsigned short GetCh2ns() {return ch2ns;}
|
||||
uint64_t GetHandle() {return handle;}
|
||||
|
||||
event evt;
|
||||
Event *evt;
|
||||
void OpenOutFile(std::string fileName);
|
||||
void CloseOutFile();
|
||||
void SaveDataToFile();
|
||||
|
|
114
Event.h
Normal file
114
Event.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
#ifndef EVENT_H
|
||||
#define EVENT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MaxTraceLenght 2048
|
||||
|
||||
class Event {
|
||||
public:
|
||||
|
||||
unsigned short dataType;
|
||||
|
||||
///============= for dpp-pha
|
||||
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
|
||||
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_probes[2]; // 18 bit
|
||||
uint8_t * digital_probes[2]; // 1 bit
|
||||
uint16_t trigger_threashold; // 16 bit
|
||||
size_t event_size; // 64 bit
|
||||
uint32_t aggCounter; // 32 bit
|
||||
|
||||
///============= for raw
|
||||
uint8_t * data;
|
||||
size_t dataSize; /// number of byte of the data, size/8 = word [64 bits]
|
||||
uint32_t n_events;
|
||||
|
||||
Event(){
|
||||
analog_probes[0] = NULL;
|
||||
analog_probes[1] = NULL;
|
||||
digital_probes[0] = NULL;
|
||||
digital_probes[1] = NULL;
|
||||
digital_probes[2] = NULL;
|
||||
digital_probes[3] = NULL;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
~Event(){
|
||||
ClearMemory();
|
||||
}
|
||||
|
||||
void ClearMemory(){
|
||||
if( data != NULL ) delete data;
|
||||
|
||||
if( analog_probes != NULL) {
|
||||
delete analog_probes[0];
|
||||
delete analog_probes[1];
|
||||
}
|
||||
|
||||
if( digital_probes != NULL) {
|
||||
delete digital_probes[0];
|
||||
delete digital_probes[1];
|
||||
delete digital_probes[2];
|
||||
delete digital_probes[3];
|
||||
}
|
||||
}
|
||||
|
||||
void SetDataType(unsigned int type){
|
||||
dataType = type;
|
||||
ClearMemory();
|
||||
|
||||
if( dataType != 0xF){
|
||||
analog_probes[0] = new int32_t[MaxTraceLenght];
|
||||
analog_probes[1] = new int32_t[MaxTraceLenght];
|
||||
|
||||
digital_probes[0] = new uint8_t[MaxTraceLenght];
|
||||
digital_probes[1] = new uint8_t[MaxTraceLenght];
|
||||
digital_probes[2] = new uint8_t[MaxTraceLenght];
|
||||
digital_probes[3] = new uint8_t[MaxTraceLenght];
|
||||
}else{
|
||||
data = new uint8_t[20*1024*1024];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PrintEnergyTimeStamp(){
|
||||
printf("ch: %2d, energy: %u, timestamp: %lu ch, traceLenght: %lu\n", channel, energy, timestamp, traceLenght);
|
||||
}
|
||||
|
||||
void PrintAll(){
|
||||
printf("ch : %2d (0x%02X), 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%02X, (low): 0x%03X, 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 PrintAllTrace(){
|
||||
for(int i = 0; i < traceLenght; i++){
|
||||
printf("%4d| %6d %6d %1d %1d %1d %1d\n", i, analog_probes[0][i],
|
||||
analog_probes[1][i],
|
||||
digital_probes[0][i],
|
||||
digital_probes[1][i],
|
||||
digital_probes[2][i],
|
||||
digital_probes[3][i]);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
4
Makefile
4
Makefile
|
@ -7,9 +7,9 @@ all: test test_indep ClassDigitizer2Gen.o
|
|||
test_indep : test_indep.cpp
|
||||
$(CC) $(COPTS) -o test_indep test_indep.cpp $(CAENLIBS)
|
||||
|
||||
test : test.cpp ClassDigitizer2Gen.o
|
||||
test : test.cpp ClassDigitizer2Gen.o
|
||||
$(CC) $(COPTS) -o test test.cpp ClassDigitizer2Gen.o $(CAENLIBS)
|
||||
|
||||
ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Parameter.h
|
||||
ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Event.h
|
||||
$(CC) $(COPTS) -c ClassDigitizer2Gen.cpp $(CAENLIBS)
|
||||
|
||||
|
|
8
test.cpp
8
test.cpp
|
@ -49,7 +49,7 @@ int main(int argc, char* argv[]){
|
|||
|
||||
|
||||
|
||||
digi->SetPHADataFormat(1);
|
||||
digi->SetPHADataFormat(0);
|
||||
|
||||
digi->OpenOutFile("haha");
|
||||
|
||||
|
@ -71,13 +71,15 @@ int main(int argc, char* argv[]){
|
|||
|
||||
|
||||
|
||||
digi->SaveDataToFile();
|
||||
//digi->SaveDataToFile();
|
||||
|
||||
if( digi->evt.channel == 63 ) {
|
||||
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;
|
||||
}
|
||||
}else{
|
||||
printf("something wrong when ReadData()");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user