From bbe9ef799007334342e64769852e0da59a88b6a4 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Tue, 18 Jun 2024 14:15:46 -0400 Subject: [PATCH] ClassData, fine timestamp in ps. added flags and trace for FSU2CAEN --- Aux/FSU2CAEN.cpp | 24 +++++++++++++++++++----- ClassData.h | 4 ++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Aux/FSU2CAEN.cpp b/Aux/FSU2CAEN.cpp index a802b20..7d94966 100644 --- a/Aux/FSU2CAEN.cpp +++ b/Aux/FSU2CAEN.cpp @@ -6,8 +6,8 @@ struct FileInfo{ unsigned long hitCount; }; -const unsigned short header = 0xCAE1; -const unsigned int flags = 0; +unsigned short header = 0xCAE1; +unsigned int flags = 0; #define minNARG 4 @@ -54,7 +54,6 @@ int main(int argc, char **argv) { printf("========================================= Number of Files : %d \n", nFile); for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].c_str()); printf("=========================================\n"); - printf(" Include Trace = %s\n", "No"); printf(" Batch size = %d events/file\n", batchSize); printf(" Out file name = %s \n", outFileName.c_str()); printf(" Is tar output = %s \n", tarFlag ? "Yes" : "No"); @@ -167,12 +166,27 @@ int main(int argc, char **argv) { } + if( hitList[g0][evID[g0]].energy2 > 0 ) header += 4; + if( hitList[g0][evID[g0]].traceLength > 0 ) header += 8; + if( hitList[g0][evID[g0]].pileUp ) flags += 0x8000; + if( hitList[g0][evID[g0]].fineTime > 0 ) flags += 0x4000; + fwrite(&(header), 2, 1, outFile); fwrite(&(hitList[g0][evID[g0]].sn), 2, 1, outFile); fwrite(&(hitList[g0][evID[g0]].ch), 2, 1, outFile); - fwrite(&(hitList[g0][evID[g0]].timestamp), 8, 1, outFile); + unsigned psTimestamp = hitList[g0][evID[g0]].timestamp * 1000 + hitList[g0][evID[g0]].fineTime; + fwrite(&(psTimestamp), 8, 1, outFile); fwrite(&(hitList[g0][evID[g0]].energy), 2, 1, outFile); fwrite(&(flags), 4, 1, outFile); + if( hitList[g0][evID[g0]].traceLength > 0 ){ + char waveCode = 1; + fwrite(&(waveCode), 1, 1, outFile); + fwrite(&(hitList[g0][evID[g0]].traceLength), 4, 1, outFile); + + for( int i = 0; i < hitList[g0][evID[g0]].traceLength; i++ ){ + fwrite(&(hitList[g0][evID[g0]].trace[i]), 2, 1, outFile); + } + } evID[g0]++; if( hitProcessed == 0) tStart = hitList[g0][evID[g0]].timestamp; @@ -227,7 +241,7 @@ int main(int argc, char **argv) { printf("Error creating archive\n"); } } - + printf("============================================== end of program\n"); return 0; diff --git a/ClassData.h b/ClassData.h index 676cd19..cd07a35 100644 --- a/ClassData.h +++ b/ClassData.h @@ -884,7 +884,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe Energy[channel][DataIndex[channel]] = energy; Timestamp[channel][DataIndex[channel]] = timeStamp * tick2ns; - if(extra2Option == 2 ) fineTime[channel][DataIndex[channel]] = (extra2 & 0x03FF ); + if(extra2Option == 2 ) fineTime[channel][DataIndex[channel]] = (extra2 & 0x03FF ) * tick2ns; // in ps, the tick2ns is a conversion factor PileUp[channel][DataIndex[channel]] = pileUp; NumEventsDecoded[channel] ++; @@ -1087,7 +1087,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe Energy2[channel][DataIndex[channel]] = Qshort; Energy[channel][DataIndex[channel]] = Qlong; Timestamp[channel][DataIndex[channel]] = timeStamp * tick2ns; - if( extraOption == 2 ) fineTime[channel][DataIndex[channel]] = extra & 0x3FF; + if( extraOption == 2 ) fineTime[channel][DataIndex[channel]] = (extra & 0x3FF) * tick2ns; //in ps, tick2ns is justa conversion factor NumEventsDecoded[channel] ++; if( !pileup){