6 #include <rtsSystems.h>
12 inline float fswap(
float swapped)
14 unsigned int* uintptr = (
unsigned int*) &swapped;
15 unsigned int uintvar = l2h32(*uintptr);
16 float* floatvar = (
float*)&uintvar;
21 #ifdef RTS_LITTLE_ENDIAN
22 #define l2hfloat(x) (x)
25 #define l2hfloat(x) (fswap(x))
30 int l3_reader(
char *m,
struct l3_t *l3, u_int driver)
35 char *l3_gtd_start = 0 ;
38 l3->max_channels = 1280000 ;
46 l3->xVertex = -1000.0 ;
47 l3->yVertex = -1000.0 ;
48 l3->zVertex = -1000.0 ;
51 if(datap == NULL)
return 0 ;
62 len = ntohl(datap->det[L3_ID].len) * 4 ;
63 if(len == 0)
return 0 ;
65 off = ntohl(datap->det[L3_ID].off) ;
66 if(off == 0)
return 0 ;
68 l3p = (
struct L3_P *)((u_int *)m+off) ;
74 LOG(DBG,
"L3_P bytes %d",len,0,0,0) ;
76 if(checkBank(l3p->bh.bank_type,(
char *)
"L3_P") < 0) {
81 if(l3p->tracks.len && l3p->tracks.off){
82 l3_gtd_start = ((
char*)l3p + l2h32(l3p->tracks.off)*4) ;
87 if(!l3_gtd_start)
return 0 ;
96 if(checkBank(l3gtd->bh.bank_type,(
char *)
"L3_GTD") < 0) {
101 l3->mode = l2h32(l3gtd->bh.crc) ;
102 l3->channels = l2h32(l3gtd->bh.w9) ;
105 l3->tracks_num = l2h32(l3gtd->nTracks);
106 l3->cluster_num = l2h32(l3gtd->nHits);
107 l3->xVertex = l2hfloat(l3gtd->xVert);
108 l3->yVertex = l2hfloat(l3gtd->yVert);
109 l3->zVertex = l2hfloat(l3gtd->zVert);
112 if(l3->tracks_num >= L3_MAX_NR_TRACKS) {
113 LOG(ERR,
"L3 track number %d > %d! Maxing them out...",l3->tracks_num,L3_MAX_NR_TRACKS ,0,0,0) ;
114 l3->tracks_num = L3_MAX_NR_TRACKS ;
118 for (
unsigned int i=0; i<l3->tracks_num; i++) {
121 l3->track[i].id = l2h32(tr->id);
123 #ifndef UNIX_LITTLE_ENIDAN
124 l3->track[i].flag = tr->flag;
125 l3->track[i].innerMostRow = tr->innerMostRow;
126 l3->track[i].outerMostRow = tr->outerMostRow;
128 l3->track[i].nHits = tr->nHits;
129 l3->track[i].ndedx = tr->ndedx;
130 l3->track[i].q = tr->q;
132 l3->track[i].flag = ( ((
unsigned short)tr->innerMostRow) |
133 ((
unsigned short)tr->outerMostRow)<<8);
134 l3->track[i].innerMostRow = (char)( tr->flag & 0x00ff );
135 l3->track[i].outerMostRow = (char)((tr->flag & 0xff00)>>8);
137 l3->track[i].nHits = (
unsigned char)tr->q;
138 l3->track[i].reserved = (
char)tr->ndedx;
139 l3->track[i].ndedx = (
unsigned char)tr->reserved;
140 l3->track[i].q = (
char)tr->nHits;
142 l3->track[i].chi2[0] = l2hfloat(tr->chi2[0]);
143 l3->track[i].chi2[1] = l2hfloat(tr->chi2[1]);
144 l3->track[i].dedx = l2hfloat(tr->dedx);
145 l3->track[i].pt = l2hfloat(tr->pt);
146 l3->track[i].phi0 = l2hfloat(tr->phi0);
147 l3->track[i].psi = l2hfloat(tr->psi);
148 l3->track[i].r0 = l2hfloat(tr->r0);
149 l3->track[i].tanl = l2hfloat(tr->tanl);
150 l3->track[i].z0 = l2hfloat(tr->z0);
151 l3->track[i].length = l2hfloat(tr->length);
152 l3->track[i].dpt = l2hfloat(tr->dpt);
153 l3->track[i].dpsi = l2hfloat(tr->dpsi);
154 l3->track[i].dz0 = l2hfloat(tr->dz0);
155 l3->track[i].dtanl = l2hfloat(tr->dtanl);
163 #ifdef SHOW_DEBUG_INFO
165 #ifdef UNIX_LITTLE_ENDIAN
166 printf(
"Running on LITTLE endian machine\n");
168 printf(
"Running on BIG endian machine\n");
171 printf(
"\nVertex: (%6.2f/%6.2f/%6.2f)\n",
172 l3->xVertex, l3->yVertex, l3->zVertex);
174 printf(
"Tracks: %5d Clusters %7d\n",
175 l3->tracks_num, l3->cluster_num);
177 for (
unsigned int i=0; i<l3->tracks_num; i++) {
178 printf(
"%5d: pt=%5.3f z0=%7.2f q=%2d nHits=%2d ndedx=%2d ",
179 i, l3->track[i].pt, l3->track[i].z0, l3->track[i].q,
180 l3->track[i].nHits, l3->track[i].ndedx);
182 printf(
"flag=0x%04x iRow=%2d oRow=%2d\n",
183 l3->track[i].flag, l3->track[i].innerMostRow,
184 l3->track[i].outerMostRow);