#include #include /* Event structure: 4 bytes event number 26 bytes DUT temperatures 5x 658 bytes motherboard data block: 6 bytes MAC header 2 bytes Status register 4 bytes Event number 4 bytes TDC value 320 bytes ADC values ASIC 0 320 bytes ADC values ASIC 1 2 bytes NTC reading */ #define ADlength 13 #define Nstations 5 #define MBlength 658 #define IPlength 6 #define SRlength 2 #define ENlength 4 #define TMlength 4 #define A0length 160 #define A1length 160 #define TTlength 2 #define BLlength (4 + 2*ADlength + Nstations * MBlength) unsigned Offset[] = { 127.94, 147.20, 153.55, 106.16, 139.55, 150.16, 141.81, 158.51, 122.72, 131.20, 160.81, 163.63, 0. }; unsigned char *buffer; unsigned char *Value; int main(int argc, char **argv) { FILE *fp; int ind; char *Fname; long lSize; size_t result; int Nblocks; if (argc!=2) {fputs ("enter file name\n", stderr); exit(0);} Fname = argv[1]; fp = fopen (Fname, "rb"); if (fp==NULL) {fputs ("File error", stderr); exit (1);} /* obtain file size */ fseek (fp , 0 , SEEK_END); lSize = ftell (fp); rewind (fp); /* allocate memory to contain one event */ buffer = (unsigned char*) malloc(sizeof(unsigned char)*BLlength); if (buffer==NULL) {fputs ("Memory error", stderr); exit (2);} /* Loop over the entire data sample */ Nblocks = lSize/BLlength; // integer division to cut off corrupted tail !!! for (ind=0; ind>1)&0x1; // printf(":%02X ", Status); // printf(":%02X ", Phase); // if (MBA==4) printf("\n"); /* Local event number */ Levt[3] = (int)*Value++; Levt[2] = (int)*Value++; Levt[1] = (int)*Value++; Levt[0] = (int)*Value++; Levent = Levt[3]<<24 | Levt[2]<<16 | Levt[1]<<8 | Levt[0]; if (MBA==0) printf("%d ", Gevent+1); printf("%d ", Levent); if (MBA==4) printf("\n"); /* TDC values */ TDC[3] = (int)*Value++; TDC[2] = (int)*Value++; TDC[1] = (int)*Value++; TDC[0] = (int)*Value++; Time = 2*(TDC[0] + TDC[1] + TDC[2] + TDC[3]) + Tcor; // printf("%d ", Time); // if (MBA==4) printf("\n"); /* Amplitudes */ for (i=0; i