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

Annotation of /yoda/techmodel/forroutines/tracker/readraw/dunpacker.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    
18     void unpacking(int ndata, unsigned short *output);
19    
20 kusanagi 5.1 /************************************************************
21     * 20/9/2005 modified by david fedele */
22     /* void dunpacker_(int *l_buffer, unsigned short *buffer, int *error, int *fd) */
23     void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
24 kusanagi 1.1
25 kusanagi 5.1 void dunpacker_(int *l_buffer, unsigned short *buff, int *error,char *buffer, int *len,int *curpos)
26     /**************************************************************/
27 kusanagi 1.1 {
28     int i;
29 kusanagi 5.1 int nhead;
30 kusanagi 1.1
31     nhead = 13; /* packed */
32 kusanagi 5.1 *error=0;
33     /************************************************************
34     * 20/9/2005 modified by david fedele */
35     /* int nread; */
36     /* unsigned int word; */
37    
38     /* nread=read(*fd, buffer, 2**l_buffer); */
39    
40     /* if( nread==0 ) { */
41     /* printf("dunpacker: Unexpected end of file %d at %d \n",*fd,nread); */
42     /* *error=1; */
43     /* return ; */
44     /* } */
45     /* if ( nread != 2**l_buffer) { */
46     /* printf("dunpacker: Error on reading: nread = %d \n",nread); */
47     /* *error=-1; */
48     /* return ; */
49     /* } */
50    
51    
52     /* /\*** correct byte ***\/ */
53     /* for(i=0; i<*l_buffer; i++) { */
54     /* word = buffer[i]; */
55     /* buffer[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
56     /* } */
57     int nbytes2=2;
58     unsigned int word_temp;
59     unsigned short word[10000];
60    
61     for(i=0;i<*l_buffer;i++){
62     getbytes_(&nbytes2,buffer,curpos,&word_temp);
63     word[i]=word_temp;
64     buff[i]=word[i];
65 kusanagi 1.1 }
66 kusanagi 5.1
67    
68    
69     if( *curpos-1>*len ) {
70     printf("dunpacker: Unexpected end of file\n");
71     *error=1;
72     return ;
73 kusanagi 1.1 }
74     /*** unpacking buffer data ***/
75 kusanagi 5.1 /************************************************************
76     * 20/9/2005 modified by david fedele */
77     /* if( nhead == 13) unpacking(*l_buffer, buffer); */
78     if( nhead == 13) unpacking(*l_buffer, buff);
79     /**************************************************************/
80    
81    
82     /* int num = (*l_buffer-13-1)/13*16+3;//??? */
83     /* for( i=0; i<num; i++) printf("%i %x \n",i,buffer[i]);//??? */
84 kusanagi 1.1
85 kusanagi 5.1 /*** Checksum ***/
86     /* *oi = buffer; */
87 kusanagi 1.1 /* word = 0; */
88 kusanagi 5.1 /* for( i=0; i<*l_buffer; ++i) */
89     /* word = (word + *oi++)& 0x03ff; */
90 kusanagi 1.1 /* if( word == ( header[6] & 0x03ff ) ) */
91     /* /\* printf("Check Sum OK \n")*\/ ; */
92     /* else */
93     /* printf("Wrong Check Sum: %x, %x \n",word,header[6]&0x03ff); */
94    
95     }
96    
97     /*========================================================= */
98     /*========================================================= */
99     /*
100     * Routine to unpacking buffer file
101     *
102     */
103     /*========================================================= */
104     /*========================================================= */
105     void unpacking(int nwords, unsigned short *output) {
106     unsigned short out[10000];
107     int k;
108     unsigned short *oi, *oo, *o1;
109    
110     for( k=0; k<10000; ++k)
111     out[k]=0;
112     oo=output;
113     oi=out;
114     for( k=0; k<nwords; ++k) {
115     *oi++ = *oo;
116     *oo++ = 0;
117     }
118    
119     oo=output;
120     oi=out;
121    
122     for(k=0; k<nwords; k+=13) {
123     o1 = oi++;
124     *oo++ = (*o1 & 0xfff8) >> 3;
125     *oo++ = ( (*o1 & 0x0007) << 10 ) | ( (*oi & 0xffc0) >> 6);
126     o1 = oi++;
127     *oo++ = ( (*o1 & 0x003f) << 7 ) | ( (*oi & 0xfe00) >> 9);
128     o1 = oi++;
129     *oo++ = ( (*o1 & 0x01ff) << 4 ) | ( (*oi & 0xf000) >> 12);
130     o1 = oi++;
131     *oo++ = ( (*o1 & 0x0fff) << 1 ) | ( (*oi & 0x8000) >> 15);
132     *oo++ = (*oi & 0x7ffc) >> 2;
133     o1 = oi++;
134     *oo++ = ( (*o1 & 0x0003) << 11 ) | ( (*oi & 0xffe0) >> 5);
135     o1 = oi++;
136     *oo++ = ( (*o1 & 0x001f) << 8 ) | ( (*oi & 0xff00) >> 8);
137     o1 = oi++;
138     *oo++ = ( (*o1 & 0x00ff) << 5 ) | ( (*oi & 0xf800) >> 11);
139     o1 = oi++;
140     *oo++ = ( (*o1 & 0x07ff) << 2 ) | ( (*oi & 0xc000) >> 14);
141     *oo++ = (*oi & 0x3ffe) >> 1;
142     o1 = oi++;
143     *oo++ = ( (*o1 & 0x0001) << 12 ) | ( (*oi & 0xfff0) >> 4);
144     o1 = oi++;
145     *oo++ = ( (*o1 & 0x000f) << 9 ) | ( (*oi & 0xff80) >> 7);
146     o1 = oi++;
147     *oo++ = ( (*o1 & 0x007f) << 6 ) | ( (*oi & 0xfc00) >> 10);
148     o1 = oi++;
149     *oo++ = ( (*o1 & 0x03ff) << 3 ) | ( (*oi & 0xe000) >> 13);
150     *oo++ = *oi++ & 0x1fff;
151     }
152    
153    
154     return;
155     }

  ViewVC Help
Powered by ViewVC 1.1.23