fix CAEN format. the header only at the beginning of the binary file
This commit is contained in:
parent
84bb439ff3
commit
c4263ab06c
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
16
Hit.h
16
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++ ){
|
||||
|
|
Loading…
Reference in New Issue
Block a user