/***************************************************************** Function to read AC physics data v1.1 Author: Petter Hofverberg, petter@particle.kth.se 0408 v1.0 alive 0409 Added shifting operators to fix problem with odd data (BBAC|11DD) ----- Errors: (returned to the main program as the variable "err") err= 0 - Ok 1 - Data found, but corrupt 2 - Data dont found in buffer ToDo: i) do it endian-independent ii) check for more events in the same file? ******************************************************************/ #include #include "AC.h" int i,err,found,j; //unsigned short buffer[1000]; //unsigned short tmp1,tmp2; unsigned short buffer[1000]; unsigned short tmp1; struct physicsstruct physicsdata; struct physicsstruct *physicspointer; struct calibstruct calibdata; struct calibstruct *calibpointer; //int ACphysics(int length,unsigned short* datapointer,struct physicsstruct* physicspointer) int ACphysics(int length,unsigned char* datapointer,struct physicsstruct* physicspointer) { int iter=2; *physicspointer=physicsdata; //look for header AC11, then cut out the event to a temp buffer while(found==0 && iter> 8); return temp; }