/[PAMELA software]/yoda/techmodel/forroutines/tracker/readraw/readbad.c
ViewVC logotype

Annotation of /yoda/techmodel/forroutines/tracker/readraw/readbad.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.0 - (hide annotations) (download)
Tue Feb 7 17:11:11 2006 UTC (18 years, 10 months ago) by kusanagi
Branch: MAIN
CVS Tags: yodaPreTermistors2_1/00, YODA6_2/01, YODA6_2/00, YODA6_1/00, YODA6_0/00, YODA6_3/00, YODA6_3/01, YODA6_3/02, YODA6_3/03, yodaPreTermistores2_0/00
Changes since 5.1: +0 -0 lines
File MIME type: text/plain
Several new features in this revision:
a) all the packets are conform to the Mass Memory Format specifications (http://people.roma2.infn.it/~cpu/Mass_Memory_Format.html)
b) unpacking either using the old files structure OR the new one file unpacking.
c) parametrized root files compression factor
d) deleting of the following packet: TofTest, TrkTest, TrkEvent.
e) the Tracker routines now work without the use of temp files.

The point a) allow Yoda to unpack in the root file all the packets generated by the CPU. According to the MassMemoryFormat; that is three possible data are available:

1) almost explicit structure of the packet (like for Log, Tracker, Mcmd, etc....);
2) dummy data collection structure (InitHeader, InitTrailer, CalibHeader, CalibTrailer);
3) just the data of the packet (almost all Alarm and Init procedures). The class regarding this packets have only one parameters, a TArrayC class, which contain the data-block included in the packet (tat is the data below the packet Header).

The point b) has been implemented as a consequence of an agreement about a more compact structure of the unpacked data. Up to now the structure of each unpacked data consisted of a folder, named after the packet type, and three files: xxx.Header.root, xxx.NamePacket.root, xxx.Registry.root.
Starting from this release YODA, by default will unpack the data in a unique root file. The structure of this file will consist of:
- several TTree(s) named after the packet type;
- into each TTree are foreseen three TBranche(s):
    - 'Header'  (the old xxx.Header.root file)
    - 'NameOfThePacket' (the old xxx.Event.root file or the xxx.Event.DETECTOR.root)
    - 'Registry' (the old xxx.Registry.root file)

Anyway is still possible, but deprecated, to unpack using the old structure, passing to the "yoda" command the optional parameter "-multifile"

The point c) has been implemented because is well know that writing time in a TTree is as much fast as much lower is the compression factor for the root file; anyway for a PAMELA dat file, a compression equal to 0 will generate a root file which will be more than two times the original size. To modify the compression parameter just add the optional parameter "-c [0-9]" to the yoda command line.

1 kusanagi 5.1 /************************************************************
2     * 20/9/2005 modified by david fedele to read buffer-data
3     * instead raw-data-file
4     **************************************************************
5 kusanagi 1.1 * include needed system headers
6     */
7     #include <stdio.h> /* include standard i/o library */
8     #include <stdlib.h> /* include standard library */
9     #include <string.h> /* include string library */
10     #include <unistd.h> /* include unix standard library */
11     #include <sys/types.h> /* */
12     #include <sys/stat.h> /* */
13     #include <fcntl.h> /* */
14     #include <errno.h> /* error simbol definitions */
15     #include <time.h> /* system time definitions */
16     #include <math.h> /* math library */
17 kusanagi 5.1 /************************************************************
18     * 20/9/2005 modified by david fedele */
19     /* void readbad_(unsigned short *bad_buf, int *error, int *fd) */
20     void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
21 kusanagi 1.1
22 kusanagi 5.1 void readbad_(unsigned short *bad_buf, int *error,char *buffer, int *len,int *curpos)
23     /**************************************************************/
24 kusanagi 1.1 {
25     int i,j,ii,jj;
26 kusanagi 5.1 unsigned int word;
27     unsigned int skip;
28     unsigned int bad_buf_temp[64];
29 kusanagi 1.1
30     *error=0;
31 kusanagi 5.1 /************************************************************
32     * 20/9/2005 modified by david fedele */
33     /* int nread; */
34    
35     /* /\*** read the buffer ***\/ */
36     /* nread=read(*fd, bad_buf_temp, 2*64); */
37     /* if( nread==0 ) { */
38     /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
39     /* *error=1; */
40     /* return ; */
41     /* } */
42     /* if ( nread != 2*64) { */
43     /* printf("readbad: Error on reading: nread = %d \n",nread); */
44     /* *error=-1; */
45     /* return ; */
46     /* } */
47    
48    
49     /* /\*** correct byte ***\/ //endianess... */
50     /* for(i=0; i<64; i++) { */
51     /* word = bad_buf_temp[i]; */
52     /* bad_buf_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
53     /* } */
54    
55    
56     int nbytes2=2;
57     char *buff=buffer;
58 kusanagi 1.1
59 kusanagi 5.1 for(i=0; i<64; i++){
60     getbytes_(&nbytes2,buff,curpos,&bad_buf_temp[i]);
61    
62     if( *curpos-1>*len ) {
63     printf("readbad: Unexpected end of file \n");
64 kusanagi 1.1 *error=1;
65     return ;
66 kusanagi 5.1 }
67 kusanagi 1.1 }
68 kusanagi 5.1 /*****************************************************************/
69 kusanagi 1.1
70    
71     for(i=0; i<64; i++) {
72    
73     word = bad_buf_temp[i];
74    
75     for(j=0; j<16; j++) {
76    
77     jj=15-j;
78     ii=j+i*16;
79    
80     bad_buf[ii] = ( (word >> jj) & 0x0001 );
81    
82    
83    
84    
85     }
86     }
87    
88    
89     // for( i=0; i<64; i++) printf("%i %x \n",i,bad_buf_temp[i]);//??? */
90    
91     // printf("\n");//??? */
92    
93     // for( i=0; i<1024; i++) printf("%i %i \n",i,bad_buf[i]);//??? */
94    
95    
96    
97    
98    
99    
100    
101    
102    
103    
104    
105    
106     //legge la parola di fine ladder... per saltarla...
107 kusanagi 5.1 /************************************************************
108     * 20/9/2005 modified by david fedele */
109 kusanagi 1.1 /* /\*** read the buffer ***\/ */
110 kusanagi 5.1 /* nread=read(*fd, &skip, 2); */
111 kusanagi 1.1 /* if( nread==0 ) { */
112     /* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); */
113     /* *error=1; */
114     /* return ; */
115     /* } */
116 kusanagi 5.1 /* if ( nread != 2) { */
117 kusanagi 1.1 /* printf("readbad: Error on reading: nread = %d \n",nread); */
118     /* *error=-1; */
119     /* return ; */
120     /* } */
121    
122    
123    
124    
125 kusanagi 5.1 /* // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */
126    
127    
128    
129    
130     /* /\* *error=0; *\/ */
131    
132     /* /\* /\\*** read the buffer ***\\/ *\/ */
133     /* /\* nread=read(*fd, bad_buf, 2*64); *\/ */
134     /* /\* if( nread==0 ) { *\/ */
135     /* /\* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */
136     /* /\* *error=1; *\/ */
137     /* /\* return ; *\/ */
138     /* /\* } *\/ */
139     /* /\* if ( nread != 2*64) { *\/ */
140     /* /\* printf("readbad: Error on reading: nread = %d \n",nread); *\/ */
141     /* /\* *error=-1; *\/ */
142     /* /\* return ; *\/ */
143     /* /\* } *\/ */
144    
145    
146     /* /\* /\\*** correct byte ***\\/ //endianess... *\/ */
147     /* /\* for(i=0; i<64; i++) { *\/ */
148     /* /\* word = bad_buf[i]; *\/ */
149     /* /\* bad_buf[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); *\/ */
150     /* /\* } *\/ */
151    
152     /* /\* //legge la parola di fine ladder... per saltarla... *\/ */
153    
154     /* /\* /\\*** read the buffer ***\\/ *\/ */
155     /* /\* nread=read(*fd, &skip, 2); *\/ */
156     /* /\* if( nread==0 ) { *\/ */
157     /* /\* printf("readbad: Unexpected end of file %d at %d \n",*fd,nread); *\/ */
158     /* /\* *error=1; *\/ */
159     /* /\* return ; *\/ */
160     /* /\* } *\/ */
161     /* /\* if ( nread != 2) { *\/ */
162     /* /\* printf("readbad: Error on reading: nread = %d \n",nread); *\/ */
163     /* /\* *error=-1; *\/ */
164     /* /\* return ; *\/ */
165     /* /\* } *\/ */
166 kusanagi 1.1
167 kusanagi 5.1
168     getbytes_(&nbytes2,buff,curpos,&skip);
169    
170     if( *curpos-1>*len ) {
171     printf("readbad: Unexpected end of file \n");
172     *error=1;
173     return ;
174     }
175     /*****************************************************************/
176 kusanagi 1.1
177    
178    
179     /* // for( i=0; i<64; i++) printf("%x \n",bad_buf[i]);//??? */
180    
181     return;
182     }

  ViewVC Help
Powered by ViewVC 1.1.23