added min+fine_timestamo data format

This commit is contained in:
Ryan Tang 2023-11-06 13:44:55 -05:00
parent 876ae26450
commit 937bed699a
4 changed files with 103 additions and 28 deletions

View File

@ -462,7 +462,7 @@ void Digitizer2Gen::SetDataFormat(unsigned short dataFormat){
]");
}
if( dataFormat == DataFormat::Minimum ){
if( dataFormat == DataFormat::MiniWithFineTime ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
"[ \
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
@ -471,6 +471,16 @@ void Digitizer2Gen::SetDataFormat(unsigned short dataFormat){
]");
}
if( dataFormat == DataFormat::Minimum ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
"[ \
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" } \
]");
}
//^===================================================== PSD
}else if ( FPGAType == DPPType::PSD ){
@ -547,6 +557,17 @@ void Digitizer2Gen::SetDataFormat(unsigned short dataFormat){
]");
}
if( dataFormat == DataFormat::MiniWithFineTime ){
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\" } \
]");
}
if( dataFormat == DataFormat::Minimum ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
"[ \
@ -771,6 +792,26 @@ int Digitizer2Gen::ReadData(){
hit->isTraceAllZero = true;
}else if( hit->dataType == DataFormat::MiniWithFineTime){
if( FPGAType == DPPType::PHA ){
ret = CAEN_FELib_ReadData(ep_handle, 100,
&hit->channel,
&hit->timestamp,
&hit->fine_timestamp,
&hit->energy
);
}else{
ret = CAEN_FELib_ReadData(ep_handle, 100,
&hit->channel,
&hit->timestamp,
&hit->fine_timestamp,
&hit->energy,
&hit->energy_short
);
}
hit->isTraceAllZero = true;
}else if( hit->dataType == DataFormat::Minimum){
if( FPGAType == DPPType::PHA ){
ret = CAEN_FELib_ReadData(ep_handle, 100,
@ -788,6 +829,7 @@ int Digitizer2Gen::ReadData(){
}
hit->isTraceAllZero = true;
}else if( hit->dataType == DataFormat::Raw){
ret = CAEN_FELib_ReadData(ep_handle, 100, hit->data, &hit->dataSize, &hit->n_events );
//printf("data size: %lu byte\n", evt.dataSize);
@ -858,6 +900,7 @@ void Digitizer2Gen::SaveDataToFile(){
fwrite(hit->digital_probes[1], hit->traceLenght, 1, outFile);
fwrite(hit->digital_probes[2], hit->traceLenght, 1, outFile);
fwrite(hit->digital_probes[3], hit->traceLenght, 1, outFile);
}else if( hit->dataType == DataFormat::OneTrace){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&hit->channel, 1, 1, outFile);
@ -870,21 +913,32 @@ void Digitizer2Gen::SaveDataToFile(){
fwrite(&hit->traceLenght, 8, 1, outFile);
fwrite(&hit->analog_probes_type[0], 1, 1, outFile);
fwrite(hit->analog_probes[0], hit->traceLenght*4, 1, outFile);
}else if( hit->dataType == DataFormat::NoTrace ){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&hit->channel, 1, 1, outFile);
fwrite(&hit->energy, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
fwrite(&hit->timestamp, 6, 1, outFile);
fwrite(&hit->fine_timestamp, 2, 1, outFile);
fwrite(&hit->flags_high_priority, 1, 1, outFile);
fwrite(&hit->flags_low_priority, 2, 1, outFile);
}else if( hit->dataType == DataFormat::MiniWithFineTime ){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&hit->channel, 1, 1, outFile);
fwrite(&hit->energy, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
fwrite(&hit->timestamp, 6, 1, outFile);
fwrite(&hit->fine_timestamp, 2, 1, outFile);
}else if( hit->dataType == DataFormat::Minimum ){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&hit->channel, 1, 1, outFile);
fwrite(&hit->energy, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
fwrite(&hit->timestamp, 6, 1, outFile);
}else if( hit->dataType == DataFormat::Raw){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&hit->dataSize, 8, 1, outFile);

11
Hit.h
View File

@ -238,11 +238,12 @@ class Hit {
void PrintAll(){
switch(dataType){
case DataFormat::ALL : printf("============= Type : ALL\n"); break;
case DataFormat::OneTrace : printf("============= Type : OneTrace\n"); break;
case DataFormat::NoTrace : printf("============= Type : NoTrace\n"); break;
case DataFormat::Minimum : printf("============= Type : Minimum\n"); break;
case DataFormat::Raw : printf("============= Type : Raw\n"); return; break;
case DataFormat::ALL : printf("============= Type : ALL\n"); break;
case DataFormat::OneTrace : printf("============= Type : OneTrace\n"); break;
case DataFormat::NoTrace : printf("============= Type : NoTrace\n"); break;
case DataFormat::MiniWithFineTime : printf("============= Type : Min with FineTimestamp\n"); break;
case DataFormat::Minimum : printf("============= Type : Minimum\n"); break;
case DataFormat::Raw : printf("============= Type : Raw\n"); return; break;
default : return;
}

View File

@ -31,15 +31,17 @@ class SolReader {
~SolReader();
void OpenFile(std::string fileName);
int ReadNextBlock(int opt = 0); // opt = 0, noraml, 1, fast
int ReadBlock(unsigned int index);
int ReadNextBlock(int isSkip = 0); // opt = 0, noraml, 1, fast
int ReadBlock(unsigned int index, bool verbose = false);
void ScanNumBlock();
unsigned int GetNumBlock() {return numBlock;}
unsigned int GetTotalNumBlock() {return totNumBlock;}
unsigned int GetFilePos() {return filePos;}
unsigned int GetFileSize() {return inFileSize;}
bool IsEndOfFile() const {return (filePos >= inFileSize ? true : false);}
unsigned int GetBlockID() const {return numBlock - 1;}
unsigned int GetNumBlock() const {return numBlock;}
unsigned int GetTotalNumBlock() const {return totNumBlock;}
unsigned int GetFilePos() const {return filePos;}
unsigned int GetFileSize() const {return inFileSize;}
void RewindFile();
@ -86,21 +88,23 @@ inline void SolReader::OpenFile(std::string fileName){
}
}
inline int SolReader::ReadBlock(unsigned int index){
inline int SolReader::ReadBlock(unsigned int index, bool verbose){
if( isScanned == false) return -1;
if( index >= totNumBlock )return -1;
fseek(inFile, 0L, SEEK_SET);
printf("-----------%u, %u\n", index, blockPos[index]);
if( verbose ) printf("Block index: %u, File Pos: %u byte\n", index, blockPos[index]);
fseek(inFile, blockPos[index], SEEK_CUR);
filePos = blockPos[index];
numBlock = index;
return ReadNextBlock();
}
inline int SolReader::ReadNextBlock(int opt){
inline int SolReader::ReadNextBlock(int isSkip){
if( inFile == NULL ) return -1;
if( feof(inFile) ) return -1;
if( filePos >= inFileSize) return -1;
@ -119,7 +123,7 @@ inline int SolReader::ReadNextBlock(int opt){
hit->DPPType = ((blockStartIdentifier >> 4) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD;
if( hit->dataType == DataFormat::ALL){
if( opt == 0 ){
if( isSkip == 0 ){
fread(&hit->channel, 1, 1, inFile);
fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
@ -137,7 +141,7 @@ inline int SolReader::ReadNextBlock(int opt){
fseek(inFile, hit->DPPType == DPPType::PHA ? 31 : 33, SEEK_CUR);
}
fread(&hit->traceLenght, 8, 1, inFile);
if( opt == 0){
if( isSkip == 0){
fread(hit->analog_probes_type, 2, 1, inFile);
fread(hit->digital_probes_type, 4, 1, inFile);
fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
@ -149,8 +153,9 @@ inline int SolReader::ReadNextBlock(int opt){
}else{
fseek(inFile, 6 + hit->traceLenght*(12), SEEK_CUR);
}
}else if( hit->dataType == DataFormat::OneTrace){
if( opt == 0 ){
if( isSkip == 0 ){
fread(&hit->channel, 1, 1, inFile);
fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
@ -162,14 +167,15 @@ inline int SolReader::ReadNextBlock(int opt){
fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
}
fread(&hit->traceLenght, 8, 1, inFile);
if( opt == 0){
if( isSkip == 0){
fread(&hit->analog_probes_type[0], 1, 1, inFile);
fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
}else{
fseek(inFile, 1 + hit->traceLenght*4, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::NoTrace){
if( opt == 0 ){
if( isSkip == 0 ){
fread(&hit->channel, 1, 1, inFile);
fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
@ -180,8 +186,20 @@ inline int SolReader::ReadNextBlock(int opt){
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::MiniWithFineTime){
if( isSkip == 0 ){
fread(&hit->channel, 1, 1, inFile);
fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
fread(&hit->timestamp, 6, 1, inFile);
fread(&hit->fine_timestamp, 2, 1, inFile);
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 11 : 13, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::Minimum){
if( opt == 0 ){
if( isSkip == 0 ){
fread(&hit->channel, 1, 1, inFile);
fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
@ -189,9 +207,10 @@ inline int SolReader::ReadNextBlock(int opt){
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 9 : 11, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::Raw){
fread(&hit->dataSize, 8, 1, inFile);
if( opt == 0){
if( isSkip == 0){
fread(hit->data, hit->dataSize, 1, inFile);
}else{
fseek(inFile, hit->dataSize, SEEK_CUR);

View File

@ -198,10 +198,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
cbAutoRun->setEnabled(false);
cbDataFormat = new QComboBox(this);
cbDataFormat->addItem("Everything", 0);
cbDataFormat->addItem("1 trace", 1);
cbDataFormat->addItem("No trace", 2);
cbDataFormat->addItem("Minimum", 3);
cbDataFormat->addItem("Everything", DataFormat::ALL);
cbDataFormat->addItem("1 trace", DataFormat::OneTrace);
cbDataFormat->addItem("No trace", DataFormat::NoTrace);
cbDataFormat->addItem("Minimum", DataFormat::Minimum);
cbDataFormat->addItem("Min + fineTimestamp", DataFormat::MiniWithFineTime);
cbDataFormat->setCurrentIndex(3);
cbDataFormat->setEnabled(false);