ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
packet_gl1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file packet_gl1.cc
1 #include <packet_gl1.h>
2 #include <string.h>
3 
5  : Packet_w4 (data){sgl1=0;}
6 
8 {
9  if(sgl1)delete sgl1;
10 }
11 
12 int *Packet_gl1::decode ( int *nwout)
13 {
14  int *p,*k;
15  int olength;
16  int temp[MAX_OUTLENGTH];
17  int i;
18  int dlength = getDataLength();
19 
20  int status = decode_gl1( temp
21  ,(int *) findPacketDataStart(packet)
22  ,dlength
23  ,MAX_OUTLENGTH, &olength);
24 
25  if (status || olength<=0 ) return NULL;
26 
27  p = new int[olength];
28  k = p;
29  for (i =0; i<olength; i++) *k++ = temp[i];
30  *nwout = olength;
31  return p;
32 }
33 
34 int Packet_gl1::iValue(const int ich, const char *what)
35 {
36 
37 
38  if(!sgl1) demangle();
39  if(!sgl1){
40  COUT<<"Failed to fill data structure"<<std::endl;
41  return 0;
42  }
43  // GL1-3
44  if (strcmp(what,"HEADER3")==0)
45  {
46  return sgl1->gl3_payload.gl3_header;
47  }
48  /* return time */
49  else if ( strcmp(what,"YEAR")==0)
50  {
52  }
53  else if ( strcmp(what,"MONTH")==0)
54  {
56  }
57  else if ( strcmp(what,"DATE")==0)
58  {
60  }
61  else if ( strcmp(what,"DAY")==0)
62  {
63  return sgl1->gl3_payload.timestamp.day;
64  }
65  else if ( strcmp(what,"HOUR")==0)
66  {
68  }
69  else if ( strcmp(what,"MIN")==0)
70  {
71  return sgl1->gl3_payload.timestamp.min;
72  }
73  else if ( strcmp(what,"SEC")==0)
74  {
75  return sgl1->gl3_payload.timestamp.sec;
76  }
77 
78  else if (strcmp(what,"ALIGNMENT")==0)
79  {
80  return sgl1->gl3_payload.alignment;
81  }
82  else if ( strcmp(what,"CROSSCTR")==0)
83  {
85  }
86  else if ( strcmp(what,"BEAMCTR0")==0)
87  {
89  }
90  else if ( strcmp(what,"BEAMCTR1")==0)
91  {
93  }
94  else if ( strcmp(what,"GACCEPT")==0)
95  {
97  }
98  else if (strcmp(what,"ACPTORINP")==0)
99  {
101  }
102  else if ( strcmp(what,"ACPTCTR")==0)
103  {
105  }
106  else if ( strcmp(what,"GRANCTR")==0)
107  {
108  if( (ich<0) || (ich>31) ) {
109  return 0;
110  }
111  else{
112  return sgl1->gl3_payload.granule_accept[ich];
113  }
114  }
115  else if ( strcmp(what,"GDISABLE")==0)
116  {
118  }
119  else if ( strcmp(what,"FACCEPT")==0)
120  {
122  }
123  // GL1-2
124  else if (strcmp(what,"HEADER2")==0)
125  {
126  return sgl1->gl2_payload.gl2_header;
127  }
128  else if ( strcmp(what,"PACCEPT")==0)
129  {
131  }
132  else if (strcmp(what,"MODEBITS")==0)
133  {
134  return sgl1->gl2_payload.mode_bits;
135  }
136  else if ( strcmp(what,"RBITS0")==0)
137  {
138  return sgl1->gl2_payload.reduced_bits[0];
139  }
140  else if ( strcmp(what,"RBITS1")==0)
141  {
142  return sgl1->gl2_payload.reduced_bits[1];
143  }
144  else if ( strcmp(what,"DCMFULL")==0)
145  {
147  }
148  else if ( strcmp(what,"FEMUNREL")==0)
149  {
151  }
152  else if ( strcmp(what,"GBUSY")==0)
153  {
154  return sgl1->gl2_payload.granule_busy;
155  }
156  else if ( strcmp(what,"PXBAR")==0)
157  {
159  }
160  else if ( strcmp(what,"PBUSY")==0)
161  {
163  }
164 
165  // GL1-1
166  else if (strcmp(what,"HEADER1")==0)
167  {
168  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
169  return 0;
170  }
171  else{
172  return sgl1->gl1_payload[ich].gl1_header;
173  }
174  }
175  else if ( strcmp(what,"LUTINPUT")==0)
176  {// it is supposed that lut input is defined as: ich= i*8+lutinput,
177  // were i is GL1-1 board number
178  if( (ich<0) || (ich>=8*sgl1->gl1_boards) ) {
179  return 0;
180  }
181  else{
182  return sgl1->gl1_payload[ich/8].lut_input[ich%8];
183  }
184  }
185  else if ( strcmp(what,"RAWTRIG")==0)
186  {
187  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
188  return 0;
189  }
190  else{
191  return sgl1->gl1_payload[ich].lut_output;
192  }
193  }
194  else if ( strcmp(what,"TRIGBUSY")==0)
195  {
196  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
197  return 0;
198  }
199  else{
200  return sgl1->gl1_payload[ich].trigger_busy;
201  }
202  }
203  else if ( strcmp(what,"LIVETRIG")==0)
204  {
205  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
206  return 0;
207  }
208  else{
209  return sgl1->gl1_payload[ich].live_trig_out;
210  }
211  }
212  else if ( strcmp(what,"SCALEDTRIG")==0)
213  {
214  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
215  return 0;
216  }
217  else{
218  return sgl1->gl1_payload[ich].scaled_trig_out;
219  }
220  }
221  else if ( strcmp(what,"TRIGPARXBAR")==0)
222  {
223  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
224  return 0;
225  }
226  else{
227  return sgl1->gl1_payload[ich].trig_part_xbar_out;
228  }
229  }
230 
231 
232  else return 0;
233 
234 }
235 int Packet_gl1::iValue(const int ich, const int what)
236 {
237 
238 
239  if(!sgl1) demangle();
240  if(!sgl1){
241  std::cout<<"Failed to fill data structure"<<std::endl;
242  return 0;
243  }
244  switch (what) {
245  // GL1-3
246  case HEADER3:
247  {
248  return sgl1->gl3_payload.gl3_header;
249  }
250  /* return time */
251  case YEAR:
252  {
253  return sgl1->gl3_payload.timestamp.year;
254  }
255  case MONTH:
256  {
258  }
259  case DATE:
260  {
261  return sgl1->gl3_payload.timestamp.date;
262  }
263  case DAY:
264  {
265  return sgl1->gl3_payload.timestamp.day;
266  }
267  case HOUR:
268  {
269  return sgl1->gl3_payload.timestamp.hour;
270  }
271  case MIN:
272  {
273  return sgl1->gl3_payload.timestamp.min;
274  }
275  case SECGL1:
276  {
277  return sgl1->gl3_payload.timestamp.sec;
278  }
279 
280  case ALIGNMENT:
281  {
282  return sgl1->gl3_payload.alignment;
283  }
284  case CROSSCTR:
285  {
287  }
288  case BEAMCTR0:
289  {
291  }
292  case BEAMCTR1:
293  {
295  }
296  case GACCEPT:
297  {
299  }
300  case ACPTORINP:
301  {
303  }
304  case ACPTCTR:
305  {
307  }
308  case GRANCTR:
309  {
310  if( (ich<0) || (ich>31) ) {
311  return 0;
312  }
313  else{
314  return sgl1->gl3_payload.granule_accept[ich];
315  }
316  }
317  case GDISABLE:
318  {
320  }
321  case FACCEPT:
322  {
324  }
325  // GL1-2
326  case HEADER2:
327  {
328  return sgl1->gl2_payload.gl2_header;
329  }
330  case PACCEPT:
331  {
333  }
334  case MODEBITS:
335  {
336  return sgl1->gl2_payload.mode_bits;
337  }
338  case RBITS0:
339  {
340  return sgl1->gl2_payload.reduced_bits[0];
341  }
342  case RBITS1:
343  {
344  return sgl1->gl2_payload.reduced_bits[1];
345  }
346  case DCMFULL:
347  {
349  }
350  case FEMUNREL:
351  {
353  }
354  case GBUSY:
355  {
356  return sgl1->gl2_payload.granule_busy;
357  }
358  case PXBAR:
359  {
361  }
362  case PBUSY:
363  {
365  }
366 
367  // GL1-1
368  case HEADER1:
369  {
370  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
371  return 0;
372  }
373  else{
374  return sgl1->gl1_payload[ich].gl1_header;
375  }
376  }
377  case LUTINPUT:
378  {// it is supposed that lut input is defined as: ich= i*8+lutinput,
379  // were i is GL1-1 board number
380  if( (ich<0) || (ich>=8*sgl1->gl1_boards) ) {
381  return 0;
382  }
383  else{
384  return sgl1->gl1_payload[ich/8].lut_input[ich%8];
385  }
386  }
387  case RAWTRIG:
388  {
389  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
390  return 0;
391  }
392  else{
393  return sgl1->gl1_payload[ich].lut_output;
394  }
395  }
396  case TRIGBUSY:
397  {
398  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
399  return 0;
400  }
401  else{
402  return sgl1->gl1_payload[ich].trigger_busy;
403  }
404  }
405  case LIVETRIG:
406  {
407  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
408  return 0;
409  }
410  else{
411  return sgl1->gl1_payload[ich].live_trig_out;
412  }
413  }
414  case SCALEDTRIG:
415  {
416  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
417  return 0;
418  }
419  else{
420  return sgl1->gl1_payload[ich].scaled_trig_out;
421  }
422  }
423  case TRIGPARXBAR:
424  {
425  if( (ich<0) || (ich>=sgl1->gl1_boards) ) {
426  return 0;
427  }
428  else{
429  return sgl1->gl1_payload[ich].trig_part_xbar_out;
430  }
431  }
432  default:
433  {
434  return 0;
435  }
436  }
437 
438  return 0;
439 
440 }
441 
443 {
444  int i,j,l,m,dlength;
445  dlength = getDataLength();
446 
447  this->identify(os);
448  if(!sgl1) demangle();
449  if(!sgl1){
450  os<<"Failed to fill sgl1. Exit"<<std::endl;
451  return;
452  }
453 
454  // output some useful information:
455  const char* days[]={
456  "Non",
457  "Sun",
458  "Mon",
459  "Tue",
460  "Wed",
461  "Thu",
462  "Fri",
463  "Sat"
464  };
465  std::ios::fmtflags oldFlags = os.flags();
466  char oldFill;
467  oldFill=os.fill('0');
468  for(m=0;m<54;m++) os<<"=";
469  os << std::endl;
470  os << "GL1 data packet:" << std::endl;
471  os << "Detected " << std::dec << sgl1->gl1_boards << " GL1-1 boards in the data packet." <<std::endl;
472  os << "--> GL1-3 <--"<<std::endl;
473  os << "GL1-3 header word = 0x" << std::hex << SETW(4) << sgl1->gl3_payload.gl3_header << std::endl;
474  os << "Time: " <<std::dec<<SETW(2)<<(sgl1->gl3_payload.timestamp.hour)<<":"<<SETW(2)<<(sgl1->gl3_payload.timestamp.min)<<":"
475  <<SETW(2)<<(sgl1->gl3_payload.timestamp.sec)<<" "<<SETW(2)<<days[(sgl1->gl3_payload.timestamp.day)]
476  <<", "<<(sgl1->gl3_payload.timestamp.month)<<"/"<<SETW(2)<<(sgl1->gl3_payload.timestamp.date)<<"/"
477  <<SETW(4)<<(sgl1->gl3_payload.timestamp.year)<<std::endl;
478  os <<"Alignment = 0x"<<std::hex<<SETW(4)<<sgl1->gl3_payload.alignment<<std::endl;
479  os << "Beam Cross. Counter = 0x" << SETW(8)
481  os << SETW(8)
482  << sgl1->gl3_payload.beam_crossing_counter[0] << std::endl;
483  os << "Bunch Cross. Counter = 0x" << SETW(4) << sgl1->gl3_payload.bunch_crossing_counter << std::endl;
484  os << "Granule Accept Vector = 0x" << SETW(8) << sgl1->gl3_payload.granule_accept_vector << std::endl;
485  os << "Accept OR input = 0x" << SETW(8) << sgl1->gl3_payload.accept_or_input << std::endl;
486 // os.flags(std::ios::right|(oldFlags^std::ios::left));
487 // os.fill(' ');
488  os << "Accept Counter = " << sgl1->gl3_payload.gl1_accept_counter << std::endl;
489  os << "Granule Accept Counters:"<< std::endl;
490 
491  for(i=3;i>=0;i--)
492  {
493  for(j=7;j>=0;j--)
494  {
495  l=i*8+j;
496  if(l<10) os <<" ["<< std::dec<<SETW(1)<<l<<"]=0x"<<std::hex<<SETW(4)<<sgl1->gl3_payload.granule_accept[l]<<" ";
497  else os <<"["<< std::dec<<SETW(2)<<l<<"]=0x"<<std::hex<<SETW(4)<<sgl1->gl3_payload.granule_accept[l]<<" ";
498  }
499  os<<std::endl;
500  }
501  os.flags(oldFlags);
502  os.fill('0');
503  os << "Granule Disables = 0x" << std::hex << SETW(8) << sgl1->gl3_payload.granule_disables << std::endl;
504  os << "Forced Accepts = 0x" << SETW(8) << sgl1->gl3_payload.forced_accepts << std::endl;
505  os << "--> GL1-2 <--"<<std::endl;
506  os << "GL1-2 header word = 0x" << SETW(4) << sgl1->gl2_payload.gl2_header << std::endl;
507  os << "Partition Accept Vector = 0x" << SETW(8) << sgl1->gl2_payload.partition_accept << std::endl;
508  os << "Mode bits = 0x"<< SETW(4) << sgl1->gl2_payload.mode_bits << std::endl;
509  os << "Reduced bits = 0x" << SETW(8)<<sgl1->gl2_payload.reduced_bits[1]
510  << sgl1->gl2_payload.reduced_bits[0] << std::endl;
511  os << "DCM Full/FEM Busy Vector = 0x" << SETW(8) << sgl1->gl2_payload.dcm_full_fem_busy << std::endl;
512  os << "FEM Unreliable Vector = 0x" << SETW(8) << sgl1->gl2_payload.fem_unreliable << std::endl;
513  os << "Granule busy = 0x" << SETW(8) << sgl1->gl2_payload.granule_busy << std::endl;
514  os << "Partition busy Xbar Out = 0x" << SETW(8) << sgl1->gl2_payload.part_busy_xbar_out << std::endl;
515  os << "Partition busy bus = 0x" << SETW(8) << sgl1->gl2_payload.part_busy_bus << std::endl;
516  for(i=0;i<sgl1->gl1_boards;i++)
517  {
518  os << std::dec << SETW(1) << "--> GL1-1[" << i << "] <--" << std::endl;
519  os << SETW(1) << "GL1-1[" << i << "] header word = 0x" << std::hex << SETW(4) << sgl1->gl1_payload[i].gl1_header << std::endl;
520  os << "LUT inputs ";
521  for(j=7;j>=0;j--)
522  os << "["<< std::dec << SETW(1) << j <<"]<-0x"<< std::hex << SETW(5) <<sgl1->gl1_payload[i].lut_input[j]<<" ";
523  os <<std::endl;
524  os << "LUT Out (Raw Triggers) = 0x" << std::hex << SETW(8) << sgl1->gl1_payload[i].lut_output << std::endl;
525  os << "Trigger busy input = 0x" << SETW(8) << sgl1->gl1_payload[i].trigger_busy << std::endl;
526  os << "Live Triggers = 0x" << SETW(8) << sgl1->gl1_payload[i].live_trig_out << std::endl;
527  os << "Scaled Triggers = 0x" << SETW(8) << sgl1->gl1_payload[i].scaled_trig_out << std::endl;
528  os << "Trig->Part Xbar Out = 0x" << SETW(8) << sgl1->gl1_payload[i].trig_part_xbar_out << std::endl;
529  os << std::dec << std::endl;
530  }
531 
532  // Finally, a generic HEX dump:
533 
534  j = 0;
535  int* k=( int *) findPacketDataStart(packet);
536  if ( k ==0 ) return;
537 
538  while (1)
539  {
540  os << std::endl << std::dec << SETW(5) << j << " | ";
541  for (l=0;l<4;l++)
542  {
543  os << std::hex << SETW(8) << k[j++] << " ";
544  if (j>=dlength) break;
545  }
546  if (j>=dlength) break;
547  }
548  os << std::endl;
549  for(m=0;m<54;m++) os<<"=";
550  os << std::dec << std::endl;
551  os.fill(oldFill);
552 }
553 
555 {
556 
557  /*
558  The job of this routine is to demangle the data into something
559  that can be more properly addressed - the data is copied
560  into a GL1 data structure that can be addressed properly.
561  */
562  int check_length;
563  if(sgl1) delete sgl1;
564  sgl1=new GL1_EVENT_DATA;
565  if(!sgl1){
566  COUT<<"can't allocate memory for GL1_EVENT_DATA structure "<<std::endl;
567  return;
568  }
569  int dlength = getDataLength();
570 
571  // First board will have 21 16-bit words in readout to keep the total number even at 46.
572  // If there is an even number of GL1-1 boards total (or an odd number of additional
573  // GL1-1 boards) then the last GL1-1 board will have to read out 22
574  // 16-bit words to keep the total an intergral number of 16-bit words.
575 
576  sgl1->gl1_boards = 1;
577  check_length = 2*(dlength-46); // remaining 16-bit words
578  while( check_length>=21 ){
579  (sgl1->gl1_boards)++;
580  check_length-=21;
581  }
582 
584  {
586  }
587  unsigned int* buf = (unsigned int *) findPacketDataStart(packet);
588  if (buf == 0) return;
589 
590  // unpack the data into a GL1 structure:
591 
592 
593  unsigned int idx;
594  /* GL1-3 data */
595 
596  sgl1->gl3_payload.gl3_header = buf[0]&0xFFFF;
597  sgl1->gl3_payload.timestamp.year = 2000 + (10*((buf[0]>>20)&0xF) + ((buf[0]>>16)&0xF));
598  sgl1->gl3_payload.timestamp.month = 10*((buf[1]>>12)&0xF) + ((buf[1]>>8)&0xF);
599  sgl1->gl3_payload.timestamp.date = 10*((buf[1]>>4)&0xF) + (buf[1]&0xF);
600  sgl1->gl3_payload.timestamp.day = (buf[1]>>24)&0x7;
601  sgl1->gl3_payload.timestamp.hour = 10*((buf[1]>>20)&0xF) + ((buf[1]>>16)&0xF);
602  sgl1->gl3_payload.timestamp.min = 10*((buf[2]>>12)&0xF) + ((buf[2]>>8)&0xF) ;
603  sgl1->gl3_payload.timestamp.sec = 10*((buf[2]>>4)&0xF) + (buf[2]&0xF);
604 
605  sgl1->gl3_payload.alignment = (buf[2]&0xFFFF0000)>>16;
606 
608  ((buf[3]&0xFFFF)<<16) + ((buf[3]&0xFFFF0000)>>16);
610  ((buf[4]&0xFFFF)<<16) + ((buf[4]&0xFFFF0000)>>16);
611 
612  sgl1->gl3_payload.bunch_crossing_counter = (buf[5]&0xFFFF);
613  sgl1->gl3_payload.granule_accept_vector = (buf[5]&0xFFFF0000) + (buf[6]&0xFFFF);
614  sgl1->gl3_payload.accept_or_input = (buf[6]&0xFFFF0000)+(buf[7]&0xFFFF);
615  sgl1->gl3_payload.gl1_accept_counter = (buf[7]&0xFFFF0000)+(buf[8]&0xFFFF);
616  for(unsigned int j=0;j<32;j+=2){
617  sgl1->gl3_payload.granule_accept[31-j] = (buf[8+(j/2)]&0xFFFF0000)>>16;
618  sgl1->gl3_payload.granule_accept[31-(j+1)] = buf[8+(j/2)+1]&0xFFFF;
619  }
620  sgl1->gl3_payload.granule_disables = (buf[24]&0xFFFF0000)+(buf[25]&0xFFFF);
621  sgl1->gl3_payload.forced_accepts = (buf[25]&0xFFFF0000)+(buf[26]&0xFFFF);
622 
623  /* GL1-2 */
624 
625  sgl1->gl2_payload.gl2_header = (buf[26]&0xFFFF0000)>>16;
626  sgl1->gl2_payload.partition_accept = ((buf[27]&0xFFFF)<<16) + ((buf[27]&0xFFFF0000)>>16);
627  sgl1->gl2_payload.mode_bits = (buf[28]&0xFFFF);
628 
630  (buf[28]&0xFFFF0000)+(buf[29]&0xFFFF);
632  (buf[29]&0xFFFF0000)+(buf[30]&0xFFFF);
633 
634  sgl1->gl2_payload.dcm_full_fem_busy = (buf[30]&0xFFFF0000) + (buf[31]&0xFFFF);
635  sgl1->gl2_payload.fem_unreliable = (buf[31]&0xFFFF0000) + (buf[32]&0xFFFF);
636  sgl1->gl2_payload.granule_busy = (buf[32]&0xFFFF0000) + (buf[33]&0xFFFF);
637  sgl1->gl2_payload.part_busy_xbar_out = (buf[33]&0xFFFF0000) + (buf[34]&0xFFFF);
638  sgl1->gl2_payload.part_busy_bus = (buf[34]&0xFFFF0000) + (buf[35]&0xFFFF);
639 
640  /* GL1 data */
641 
642  idx = 35;
643  for(int i=0; i<sgl1->gl1_boards;i++){
644 
645  if( (i%2)==0 ) { // even numbered boards
646 
647  sgl1->gl1_payload[i].gl1_header = (buf[idx]&0xFFFF0000)>>16;
648  idx++;
649 
650  /* Note the complicated way in which the 20-bit LUT inputs are packed */
651 
652  sgl1->gl1_payload[i].lut_input[7] = ((buf[idx]&0xFFFF)<<4)+((buf[idx]&0xF0000000)>>28);
653  sgl1->gl1_payload[i].lut_input[6] = ((buf[idx]&0x0FFF0000)>>8)+((buf[idx+1]&0xFF00)>>8);
654  sgl1->gl1_payload[i].lut_input[5] = ((buf[idx+1]&0xFF)<<12)+((buf[idx+1]&0xFFF00000)>>20);
655  sgl1->gl1_payload[i].lut_input[4] = ((buf[idx+1]&0xF0000)<<16)+(buf[idx+2]&0xFFFF);
656  sgl1->gl1_payload[i].lut_input[3] = ((buf[idx+2]&0xFFFF0000)>>12)+((buf[idx+3]&0xF000)>>12);
657  sgl1->gl1_payload[i].lut_input[2] = ((buf[idx+3]&0xFFF)<<8)+((buf[idx+3]&0xFF000000)>>24);
658  sgl1->gl1_payload[i].lut_input[1] = ((buf[idx+3]&0xFF0000)>>4)+((buf[idx+4]&0xFFF0)>>4);
659  sgl1->gl1_payload[i].lut_input[0] = ((buf[idx+4]&0xF)<<16)+((buf[idx+4]&0xFFFF0000)>>16);
660  idx+=5;
661 
662  sgl1->gl1_payload[i].lut_output = ((buf[idx]&0xFFFF0000)>>16) + ((buf[idx]&0xFFFF)<<16);
663  idx++;
664  sgl1->gl1_payload[i].trigger_busy = ((buf[idx]&0xFFFF0000)>>16) + ((buf[idx]&0xFFFF)<<16);
665  idx++;
666  sgl1->gl1_payload[i].live_trig_out = ((buf[idx]&0xFFFF0000)>>16) + ((buf[idx]&0xFFFF)<<16);
667  idx++;
668  sgl1->gl1_payload[i].scaled_trig_out = ((buf[idx]&0xFFFF0000)>>16) + ((buf[idx]&0xFFFF)<<16);
669  idx++;
670  sgl1->gl1_payload[i].trig_part_xbar_out = ((buf[idx]&0xFFFF0000)>>16) + ((buf[idx]&0xFFFF)<<16);
671  idx++;
672 
673  }
674  else // odd numbered boards
675  {
676 
677  sgl1->gl1_payload[i].gl1_header = buf[idx]&0xFFFF;
678 
679  /* Note the complicated way in which the 20-bit LUT inputs are packed */
680 
681  sgl1->gl1_payload[i].lut_input[7] = ((buf[idx]&0xFFFF0000)>>12)+((buf[idx+1]&0xF000)>>12);
682  sgl1->gl1_payload[i].lut_input[6] = ((buf[idx+1]&0x0FFF)<<8) + ((buf[idx+1]&0xFF000000)>>24);
683  sgl1->gl1_payload[i].lut_input[5] = ((buf[idx+1]&0xFF0000)>>4) + ((buf[idx+2]&0xFFF0)>>4);
684  sgl1->gl1_payload[i].lut_input[4] = ((buf[idx+2]&0xF)<<16) + ((buf[idx+2]&0xFFFF0000)>>16);
685  sgl1->gl1_payload[i].lut_input[3] = ((buf[idx+3]&0xFFFF)<<4) + ((buf[idx+3]&0xF0000000)>>28);
686  sgl1->gl1_payload[i].lut_input[2] = ((buf[idx+3]&0xFFF0000)>>8) + ((buf[idx+4]&0xFF00)>>8);
687  sgl1->gl1_payload[i].lut_input[1] = ((buf[idx+4]&0xFF)<<12) + ((buf[idx+4]&0xFFF00000)>>20);
688  sgl1->gl1_payload[i].lut_input[0] = ((buf[idx+4]&0xF0000)) + ((buf[idx+5]&0xFFFF));
689  idx+=5;
690 
691  sgl1->gl1_payload[i].lut_output = ((buf[idx]&0xFFFF0000)) + ((buf[idx+1]&0xFFFF));
692  idx++;
693  sgl1->gl1_payload[i].trigger_busy = ((buf[idx]&0xFFFF0000)) + ((buf[idx+1]&0xFFFF));
694  idx++;
695  sgl1->gl1_payload[i].live_trig_out = ((buf[idx]&0xFFFF0000)) + ((buf[idx+1]&0xFFFF));
696  idx++;
697  sgl1->gl1_payload[i].scaled_trig_out = ((buf[idx]&0xFFFF0000)) + ((buf[idx+1]&0xFFFF));
698  idx++;
699  sgl1->gl1_payload[i].trig_part_xbar_out = ((buf[idx]&0xFFFF0000)) + ((buf[idx+1]&0xFFFF));
700  idx++;
701 
702  }
703 
704  }
705 
706 }
707 
708 
709 
710 
711 
712 
713