diff --git a/Aux/EventBuilder.cpp b/Aux/EventBuilder.cpp index 803f92c..41ff87c 100644 --- a/Aux/EventBuilder.cpp +++ b/Aux/EventBuilder.cpp @@ -73,6 +73,8 @@ int main(int argc, char **argv) { outFileFullName = outFileName + ".bin"; } + uint16_t header = 0; // for caen bin + printf("-------> Out file name : %s \n", outFileFullName.Data()); printf("========================================= Number of Files : %d \n", nFile); for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].Data()); @@ -321,8 +323,17 @@ int main(int argc, char **argv) { // tree->Write(); }else{ if( caen ) { + + if( header == 0 ){ + header = 0xCAE1; // default to have the energy only + if( events[0].energy2 > 0 ) header += 0x4; + if( events[0].traceLength > 0 && traceOn ) header += 0x8; + size_t dummy = fwrite(&header, 2, 1, caen); + if( dummy != 1 ) printf("file write error.\n"); + } + for( size_t gg = 0; gg < events.size(); gg++ ){ - events[gg].WriteHitsToCAENBinary(caen, traceOn); + events[gg].WriteHitsToCAENBinary(caen, header); } } } diff --git a/Aux/Makefile b/Aux/Makefile index 9b731a9..8d51ec9 100644 --- a/Aux/Makefile +++ b/Aux/Makefile @@ -5,8 +5,8 @@ CC = g++ -#COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread -COPTS = -fPIC -DLINUX -g -O0 -Wall -std=c++17 -lpthread +COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread +# COPTS = -fPIC -DLINUX -g -O0 -Wall -std=c++17 -lpthread CAENLIBS = -lCAENDigitizer -lCAENVME diff --git a/Hit.h b/Hit.h index 6d8950a..2154f9e 100644 --- a/Hit.h +++ b/Hit.h @@ -48,19 +48,17 @@ public: } - void WriteHitsToCAENBinary(FILE * file, bool withTrace){ + void WriteHitsToCAENBinary(FILE * file, uint32_t header){ if( file == nullptr ) return; - uint16_t header = 0xCAE1; // default to have the energy only uint32_t flag = 0; uint8_t waveFormCode = 1; // input + // uint16_t header = 0xCAE1; // default to have the energy only + // if( energy2 > 0 ) header += 0x4; + // if( traceLength > 0 && withTrace ) header += 0x8; + size_t dummy; - - if( energy2 > 0 ) header += 0x4; - if( traceLength > 0 && withTrace ) header += 0x8; - - dummy = fwrite(&header, 2, 1, file); dummy = fwrite(&sn, 2, 1, file); dummy = fwrite(&ch, 2, 1, file); @@ -69,11 +67,11 @@ public: dummy = fwrite(&energy, 2, 1, file); - if( energy2 > 0 ) dummy = fwrite(&energy2, 2, 1, file); + if( (header & 0x4) ) dummy = fwrite(&energy2, 2, 1, file); dummy = fwrite(&flag, 4, 1, file); - if( traceLength > 0 && withTrace ){ + if( traceLength > 0 && (header & 0x8) ){ dummy = fwrite(&waveFormCode, 1, 1, file); dummy = fwrite(&traceLength, 4, 1, file); for( int j = 0; j < traceLength; j++ ){