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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5.1 - (hide annotations) (download)
Sat Feb 4 12:37:45 2006 UTC (18 years, 10 months ago) by kusanagi
Branch: MAIN
Changes since 5.0: +74 -27 lines
File MIME type: text/plain
Several new features in this release:
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     * 12/9/2005 modified by david fedele to read buffer-data
3     * instead raw-data-file
4     **************************************************************
5     *
6 kusanagi 1.1 * include needed system headers
7     */
8     #include <stdio.h> /* include standard i/o library */
9     #include <stdlib.h> /* include standard library */
10     #include <string.h> /* include string library */
11     #include <unistd.h> /* include unix standard library */
12     #include <sys/types.h> /* */
13     #include <sys/stat.h> /* */
14     #include <fcntl.h> /* */
15     #include <errno.h> /* error simbol definitions */
16     #include <time.h> /* system time definitions */
17     #include <math.h> /* math library */
18 kusanagi 5.1 /************************************************************
19     * 12/9/2005 modified by david fedele
20     void hunpacker_(unsigned short *buffer, int *error, int *fd)*/
21     void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value);
22     void hunpacker_(unsigned short *header, int *error,char *buffer, int *len,int *curpos,int *startcrc)
23     /************************************************************/
24     {
25 kusanagi 1.1
26     int i;
27 kusanagi 5.1 int nhead;
28     unsigned int buffer_temp[13], *oo, *oi, *o1; //packed mode
29     /************************************************************
30     * 12/9/2005 modified by david fedele */
31     /* int nread,nhead; */
32     /* unsigned short word; */
33 kusanagi 1.1
34 kusanagi 5.1 /* ///\*** goes back a word***\/ */
35     /* // lseek(*fd, -2, SEEK_CUR); //SEEK_CUR ---> from current position */
36 kusanagi 1.1
37 kusanagi 5.1 /* *error=0; */
38    
39     /* /\*** read the buffer ***\/ */
40     /* nhead = 13; /\* packed *\/ */
41     /* nread=read(*fd, buffer_temp, 2*nhead); */
42     /* if( nread==0 ) { */
43     /* printf("hunpacker: Unexpected end of file %d at %d \n",*fd,nread); */
44     /* *error=1; */
45     /* return ; */
46     /* } */
47     /* if ( nread != 2*nhead) { */
48     /* printf("hunpacker: Error on reading: nread = %d \n",nread); */
49     /* *error=-1; */
50     /* return ; */
51     /* } */
52    
53     /* /\*** correct byte ***\/ //endianess... */
54     /* for(i=0; i<nhead; i++) { */
55     /* word = buffer_temp[i]; */
56     /* buffer_temp[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */
57     /* } */
58    
59     unsigned int word[16];
60     int nbytes2=2;
61     char *buff=buffer;
62 kusanagi 1.1 *error=0;
63     /*** read the buffer ***/
64     nhead = 13; /* packed */
65 kusanagi 5.1
66     *startcrc=*curpos;
67    
68     for (i=0;i<13;i++){
69     getbytes_(&nbytes2,buff,curpos,&buffer_temp[i]);
70    
71     if( *curpos-1>*len ) {
72     printf("hunpacker: Unexpected end of file\n");
73 kusanagi 1.1 *error=1;
74     return ;
75 kusanagi 5.1 }
76 kusanagi 1.1 }
77 kusanagi 5.1 /****************************************************************/
78    
79 kusanagi 1.1
80    
81    
82     /*** buffer unpacking ***/
83     if( nhead == 16 ) { // NO!???
84 kusanagi 5.1 /************************************************************
85     * 12/9/2005 modified by david fedele */
86     /* oo=buffer; /\* nopacking buffer *\/ */
87     oo=word;
88     /**********************************************************/
89 kusanagi 1.1 oi=buffer_temp;
90     for( i=0; i<nhead; i++) *oo++ = *oi++;
91     }
92     if( nhead == 13 ) {
93 kusanagi 5.1 /************************************************************
94     * 12/9/2005 modified by david fedele */
95     /* oo=buffer; /\* unpacking buffer *\/ */
96     oo=word;
97     /**********************************************************/
98 kusanagi 1.1 oi=buffer_temp;
99     o1 = oi++;
100     *oo++ = (*o1 & 0xfff8) >> 3;
101     *oo++ = ( (*o1 & 0x0007) << 10 ) | ( (*oi & 0xffc0) >> 6);
102     o1 = oi++;
103     *oo++ = ( (*o1 & 0x003f) << 7 ) | ( (*oi & 0xfe00) >> 9);
104     o1 = oi++;
105     *oo++ = ( (*o1 & 0x01ff) << 4 ) | ( (*oi & 0xf000) >> 12);
106     o1 = oi++;
107     *oo++ = ( (*o1 & 0x0fff) << 1 ) | ( (*oi & 0x8000) >> 15);
108     *oo++ = (*oi & 0x7ffc) >> 2;
109     o1 = oi++;
110     *oo++ = ( (*o1 & 0x0003) << 11 ) | ( (*oi & 0xffe0) >> 5);
111     o1 = oi++;
112     *oo++ = ( (*o1 & 0x001f) << 8 ) | ( (*oi & 0xff00) >> 8);
113     o1 = oi++;
114     *oo++ = ( (*o1 & 0x00ff) << 5 ) | ( (*oi & 0xf800) >> 11);
115     o1 = oi++;
116     *oo++ = ( (*o1 & 0x07ff) << 2 ) | ( (*oi & 0xc000) >> 14);
117     *oo++ = (*oi & 0x3ffe) >> 1;
118     o1 = oi++;
119     *oo++ = ( (*o1 & 0x0001) << 12 ) | ( (*oi & 0xfff0) >> 4);
120     o1 = oi++;
121     *oo++ = ( (*o1 & 0x000f) << 9 ) | ( (*oi & 0xff80) >> 7);
122     o1 = oi++;
123     *oo++ = ( (*o1 & 0x007f) << 6 ) | ( (*oi & 0xfc00) >> 10);
124     o1 = oi++;
125     *oo++ = ( (*o1 & 0x03ff) << 3 ) | ( (*oi & 0xe000) >> 13);
126     *oo++ = *oi++ & 0x1fff;
127     }
128    
129 kusanagi 5.1 /************************************************************
130     * 23/9/2005 modified by david fedele */
131     for( i=0; i<16; i++) {
132     header[i]=word[i];
133     /* printf("%x \n",word[i]);//??? */
134     /* printf("%x \n",header[i]);//??? */
135     }
136     /**************************************************************/
137 kusanagi 1.1 return;
138     }

  ViewVC Help
Powered by ViewVC 1.1.23