/[PAMELA software]/yoda/techmodel/forroutines/anticounter/ACphysics.c
ViewVC logotype

Annotation of /yoda/techmodel/forroutines/anticounter/ACphysics.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2.1 - (hide annotations) (download)
Sun Oct 17 12:28:41 2004 UTC (20 years, 1 month ago) by kusanagi
Branch: MAIN
CVS Tags: Rev041203
Changes since 2.0: +32 -24 lines
File MIME type: text/plain
*** empty log message ***

1 kusanagi 2.1 /*****************************************************************
2     Function to read AC physics data v1.1
3     Author: Petter Hofverberg, petter@particle.kth.se
4    
5     0408 v1.0 alive
6     0409 Added shifting operators to fix problem with odd data (BBAC|11DD)
7     -----
8     Errors: (returned to the main program as the variable "err")
9     err=
10     0 - Ok
11     1 - Data found, but corrupt
12     2 - Data dont found in buffer
13    
14     ToDo: i) do it endian-independent
15     ii) check for more events in the same file?
16     ******************************************************************/
17    
18 kusanagi 1.1 #include <stdio.h>
19 kusanagi 2.1 #include "AC.h"
20     int i,err,found,j;
21 kusanagi 1.1
22 kusanagi 2.1 int ACphysics(int length,unsigned short* datapointer,struct physicsstruct* physicspointer)
23     {
24     int iter=2;
25 kusanagi 1.1
26 kusanagi 2.1 *physicspointer=physicsdata;
27 kusanagi 1.2
28 kusanagi 1.1 //look for header AC11, then cut out the event to a temp buffer
29 kusanagi 1.2 while(found==0 && iter<length)
30 kusanagi 1.1 {
31     tmp1=*datapointer;
32     tmp2=*(datapointer+1);
33 kusanagi 2.1
34 kusanagi 1.1 if(tmp1==0x11AC)
35 kusanagi 2.1 //if(tmp1==0xAC11) //flipped
36 kusanagi 1.1 {
37     found=1;
38     for(i=0;i<64;i++)
39     {
40 kusanagi 2.1 buffer[i]=flip(*datapointer);
41 kusanagi 1.1 datapointer++;
42     }
43     tmp1=0x0000;
44     }
45 kusanagi 2.1 else if(((tmp1&0xFF00) >> 8 ) + ((tmp2&0x00FF) << 8 ) == 0x11AC)
46     //else if((tmp1&0x00FF) + (tmp2&0xFF00)==0xAC11) //flipped
47 kusanagi 1.1 {
48     found=1;
49     for(i=0;i<64;i++)
50     {
51 kusanagi 2.1 buffer[i]=flip(((tmp1&0xFF00) >> 8 ) + ((tmp2&0x00FF) << 8 ));
52     //buffer[i]=(tmp1&0x00FF) + (tmp2&0xFF00); //flipped
53 kusanagi 1.1 datapointer++;
54     tmp1=tmp2;
55     tmp2=*(datapointer+1);
56     }
57     }
58 kusanagi 1.2 else{
59     datapointer++;
60     iter=iter+2;}
61 kusanagi 1.1 }
62 kusanagi 1.2
63     //check errors
64 kusanagi 2.1 if(found==0)
65 kusanagi 1.2 err=2;
66 kusanagi 2.1 else if(buffer[1]==0x22AC || buffer[1]==0xAC22)
67 kusanagi 1.1 err=0;
68     else
69     err=1;
70    
71     //Fill physicsdata from buffer
72     for(i=0;i<2;i++) physicsdata.header[i]=buffer[i];
73     physicsdata.status=buffer[2];
74     physicsdata.hitmap=buffer[3];
75     for(i=0;i<6;i++) physicsdata.regist[i]=buffer[4+i];
76     for(i=0;i<16;i++) physicsdata.shift[i]=buffer[10+i];
77     for(i=0;i<16;i++) physicsdata.counters[i]=buffer[26+i];
78     for(i=0;i<8;i++) physicsdata.coinc[i]=buffer[42+i];
79     physicsdata.trigg=buffer[50];
80     for(i=0;i<2;i++) physicsdata.clock[i]=buffer[51+i];
81     for(i=0;i<2;i++) physicsdata.temp[i]=buffer[53+i];
82     for(i=0;i<8;i++) physicsdata.DAC[i]=buffer[55+i];
83     physicsdata.CRC=buffer[63];
84 kusanagi 1.2
85 kusanagi 1.1 return err;
86    
87     }
88    

  ViewVC Help
Powered by ViewVC 1.1.23