Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
decoding_routines.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file decoding_routines.cc
1 
2 // --------- all decoding routines -----------
3 
4 // decode the ID4EVT data format
5 
6 
7 #include "decoding_routines.h"
8 
9 int decode_id4evt( int iarr[]
10  ,int *SubeventData
11  ,int dlength
12  ,int nlen
13  ,int *olength)
14 {
15 
16  if ( SubeventData == 0) return -1;
17 
18  int i;
19 
20  // we clear the output vector if NLEN is not 0
21  if (nlen > 0)
22  {
23  for (i=0; i<nlen;) iarr[i++]=0;
24  }
25 
26  int *sptr = SubeventData;
27 
28  int nrl = 0;
29  for (i=0; i < dlength ; i++)
30  {
31  /*
32  test if i is greater than NLEN; we exceed the
33  allowed space in ARR then
34  */
35  if (nlen > 0 && i >= nlen)
36  {
37  *olength = i+1;
38  return -1;
39  }
40  iarr[i] = *sptr++;
41  nrl = i;
42  }
43  *olength = nrl+1;
44  return 0;
45 }
46 
47 
48 
49 // decode the ID2EVT data format
50 
51 int decode_id2evt( int iarr[]
52  ,short *SubeventData
53  ,int dlength
54  ,int nlen
55  ,int *olength)
56 {
57  if ( SubeventData == 0) return -1;
58  int i;
59  // we clear the output vector if NLEN is not 0
60  if (nlen > 0)
61  {
62  for (i=0; i<nlen;) iarr[i++]=0;
63  }
64 
65  short *sptr = SubeventData;
66 
67  int nrl=0;
68  for (i=0; i < dlength ; i++)
69  {
70  /*
71  test if i is greater than NLEN; we exceed the
72  allowed space in ARR then
73  */
74  if (nlen > 0 && i >= nlen)
75  {
76  *olength = i+1;
77  return -1;
78  }
79  iarr[i] = *sptr++;
80  nrl = i;
81  }
82  *olength = nrl+1;
83  return 0;
84 }
85 
86 // the hammond device format
87 int decode_idhammond( int iarr[]
88  ,int *SubeventData
89  ,int dlength
90  ,int nlen
91  ,int *olength)
92 {
93  if ( SubeventData == 0) return -1;
94  int i;
95 
96  //COUT << "in std::decode_idhammond" << std::endl;
97 
98  // we clear the output vector if NLEN is not 0
99  if (nlen > 0)
100  {
101  for (i=0; i<nlen;) iarr[i++]=0;
102  }
103 
104  int *sptr = SubeventData;
105 
106  int out_channel = 0;
107  int is, k, h1, h2;
108 
109  for (i=0; i < dlength ; i+=2)
110  {
111  /*
112  test if i is greater than NLEN; we exceed the
113  allowed space in ARR then
114  */
115 
116 
117  h1 = *sptr++;
118  h2 = *sptr++;
119 
120  for ( k = 0; k<30; k+=5)
121  {
122  if (nlen > 0 && out_channel >= nlen)
123  {
124  *olength = out_channel+1;
125  return -1;
126  }
127  iarr[out_channel++] = ((h1>>k) & 0x1f) ;
128  }
129 
130  is = ((h1>>30) & 3) | ( h2 << 2);
131 
132  for (k = 0; k<10; k+=5)
133  {
134  if (nlen > 0 && out_channel >= nlen)
135  {
136  *olength = out_channel+1;
137  return -1;
138  }
139  iarr[out_channel++] = ((is>>k) & 0x1f) ;
140  }
141 
142  //----------------------
143  }
144  *olength = out_channel;
145  return 0;
146 }
147 
148 // the hammondsetup device format
149 int decode_idhammondset( int iarr[]
150  ,int *SubeventData
151  ,int dlength
152  ,int nlen
153  ,int *olength)
154 {
155  if ( SubeventData == 0) return -1;
156  int i;
157 
158  // we clear the output vector if NLEN is not 0
159  if (nlen > 0)
160  {
161  for (i=0; i<nlen;) iarr[i++]=0;
162  }
163 
164  int *sptr = SubeventData;
165 
166  int nrl = 0;
167  for (i=0; i < dlength ; i++)
168  {
169  /*
170  test if i is greater than NLEN; we exceed the
171  allowed space in ARR then
172  */
173  if (nlen > 0 && i >= nlen)
174  {
175  *olength = i+1;
176  return -1;
177  }
178  iarr[i] = *sptr++;
179  nrl = i;
180  }
181  *olength = nrl+1;
182  return 0;
183 }
184 
185 int decode_idtecfem( int iarr[]
186  ,int *SubeventData
187  ,int dlength
188  ,int nlen
189  ,int *olength)
190 {
191  if ( SubeventData == 0) return -1;
192  int i, istart;
193 
194  // we clear the output vector if NLEN is not 0
195  if (nlen > 0)
196  {
197  for (i=0; i<nlen;) iarr[i++]=0;
198  }
199 
200  int *sptr = SubeventData;
201 
202  i = 0;
203 
204  istart = 8;
205 
206  int j;
207  int b20;
208  int nrl = 0;
209  for (i=istart; i < dlength ; i++)
210  {
211  /*
212  test if i is greater than NLEN; we exceed the
213  allowed space in ARR then
214  */
215 
216  // COUT << "in loop, i= " << i << " " << nrl <<" "
217  // << std::hex << sptr[i] << std::dec << std::endl;
218 
219  if (nlen > 0 && nrl >= nlen)
220  {
221  *olength = nrl;
222  return -1;
223  }
224 
225  b20 = sptr[i]; // these are the 20 bits in one 32 bit word.
226 
227  // then bits 0-4...
228  j = 0;
229  iarr[nrl++] = (b20 >>j ) & 0x1f;
230 
231  // and finally bits 5-9.
232  j=5;
233  iarr[nrl++] = (b20 >>j ) & 0x1f;
234 
235  // get bits 10-14 first
236  j =10;
237  iarr[nrl++] = (b20 >>j ) & 0x1f;
238 
239  // then bits 15-19...
240  j =15;
241  iarr[nrl++] = (b20 >>j ) & 0x1f;
242 
243 
244  }
245  *olength = nrl;
246  return 0;
247 }
248 
249 
250 #include <mizar.h>
251 
252 int decode_idmiznhc( int parr[]
253  ,int *SubeventData
254  ,int dlength
255  ,int nlen
256  ,int *olength)
257 {
258  if ( SubeventData == 0) return -1;
259  int i;
260 
261 
262  // we clear the output vector if NLEN is not 0
263  if (nlen > 0)
264  {
265  for (i=0; i<nlen;) parr[i++]=0;
266  }
267 
268  miz_irdg iarr = ( miz_irdg ) parr;
269 
270  int ipos,isdm,index,adr,len,len_adc;
272 
273  ipos = 2;
274  for(isdm=0;isdm<11;isdm++)
275  {
276  sdm = (sdm_c_block) &SubeventData[ipos];
277  len = (sdm->sdmlength & 0x0000ffff);
278  // COUT << "sdm " << isdm << " len " << len << " ipos " << ipos << std::endl;
279 
280  if ((sdm->sdmlength & 0x20000000)) /* this indicates the byte error */
281  {
282  iarr->out[isdm].byte_err = 1;
283  }
284  else
285  {
286  iarr->out[isdm].write_cell = (sdm->conv1_info & 0xf0000000)>>28;
287  iarr->out[isdm].c1_cell = (sdm->conv1_info & 0x0f000000)>>24;
288  iarr->out[isdm].c2_cell = (sdm->conv2_info & 0x0f000000)>>24;
289  iarr->out[isdm].board_adr = (sdm->conv1_info & 0x0000ff00)>>8;
290  iarr->out[isdm].ser_ret = (sdm->conv1_info & 0x000000ff);
291 
292  /* iarr->out[isdm].socket = (sdm->dspmap & 0x000000ff);
293  iarr->out[isdm].port = (sdm->dspmap & 0x0000ff00)>>8;
294  iarr->out[isdm].dsp = (sdm->dspmap & 0x00ff0000)>>16;
295  */
296  iarr->out[isdm].words = len;
297 
298  /* len_adc = len -4; */
299  len_adc = len -6;
300  index = 0;
301  while (index<len_adc)
302  {
303  if (sdm->array[index] & 0x80000000)
304  {
305 
306  adr = ( (sdm->array[index]>>20) & 0x7ff ) ;
307  iarr->out[isdm].conv1_high[adr] = (sdm->array[index] & 0x3ff);
308  iarr->out[isdm].conv1_low[adr] = ((sdm->array[index]>>10) & 0x3ff);
309  iarr->out[isdm].conv2_high[adr] = (sdm->array[index+1] & 0x3ff);
310  iarr->out[isdm].conv2_low[adr] = ((sdm->array[index+1]>>10) & 0x3ff);
311  iarr->out[isdm].tac[adr] = ((sdm->array[index+1]>>20) & 0x3ff);
312  index += 2;
313  }
314 
315  } /* end while index < len_adc */
316  } /* end if byte err is set */
317  ipos += len;
318  } /* end for isdm */
319 
320  *olength = sizeof(*iarr)/4;
321  return 0;
322 }
323 
324 // the SAM5305 device format
325 int decode_idsam( int iarr[]
326  ,int *SubeventData
327  ,int dlength
328  ,int nlen
329  ,int *olength)
330 {
331  if ( SubeventData == 0) return -1;
332  int i, istat;
333 
334  // the format is essentially the ID4EVT format, the only
335  // difference is that we have to convert the number into
336  // millivolts (divide by 20).
337  // we call decode_id4evt to do the work for us
338  istat = decode_id4evt(iarr, SubeventData, dlength, nlen, olength);
339 
340  // and then we scale by 1/20.
341  for (i=0; i < *olength ; i++)
342  {
343  iarr[i] /= 20;
344  }
345 
346  // we return the status of decode_id4evt.
347  return istat;
348 }
349 
350 int decode_iddcfem( int iarr[]
351  ,int *SubeventData
352  ,int dlength
353  ,int nlen
354  ,int *olength)
355 {
356  int i, istart;
357 
358  // we clear the output vector if NLEN is not 0
359  if (nlen > 0)
360  {
361  for (i=0; i<nlen;) iarr[i++]=0;
362  }
363 
364  int *sptr = SubeventData;
365 
366  i = 0;
367  while (sptr[i] != 0xdc111 && i++ < dlength ){}
368  // COUT << "index: " << i << "value " << std::hex << sptr[i] << " " << sptr[i+1]
369  // << std::dec << std::endl;
370  // COUT << "dlength = " << dlength << "nlen= " << nlen << std::endl;
371  istart = i + 5;
372 
373  int j;
374  int b20;
375  int nrl = 0;
376  for (i=istart; i < dlength ; i++)
377  {
378  /*
379  test if i is greater than NLEN; we exceed the
380  allowed space in ARR then
381  */
382 
383  // COUT << "in loop, i= " << i << " " << nrl <<" "
384  // << std::hex << sptr[i] << std::dec << std::endl;
385 
386  if (nlen > 0 && nrl >= nlen)
387  {
388  *olength = nrl;
389  return -1;
390  }
391 
392  if (sptr[i] == 0xff444)
393  {
394  *olength = nrl;
395  return 0;
396  }
397 
398  b20 = sptr[i]; // these are the 20 bits in one 32 bit word.
399 
400  // get bits 10-14 first
401  j =10;
402  iarr[nrl++] = (b20 >>j ) & 0x1f;
403 
404  // then bits 15-19...
405  j =15;
406  iarr[nrl++] = (b20 >>j ) & 0x1f;
407 
408  // then bits 0-4...
409  j = 0;
410  iarr[nrl++] = (b20 >>j ) & 0x1f;
411 
412  // and finally bits 5-9.
413  j=5;
414  iarr[nrl++] = (b20 >>j ) & 0x1f;
415 
416  }
417 
418  *olength = nrl;
419  return 0;
420 }
421 
422 
423 int decode_bbc_dcm0( int iarr[]
424  ,int *packetData
425  ,int dlength
426  ,int nlen
427  ,int *olength)
428 {
429  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
430 }
431 
432 
433 int decode_mvd_dcm0( int iarr[]
434  ,int *packetData
435  ,int dlength
436  ,int nlen
437  ,int *olength)
438 {
439  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
440 }
441 
442 
443 int decode_dch_dcm0( int iarr[]
444  ,int *packetData
445  ,int dlength
446  ,int nlen
447  ,int *olength)
448 {
449  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
450 }
451 
452 
453 int decode_pc_dcm0( int iarr[]
454  ,int *packetData
455  ,int dlength
456  ,int nlen
457  ,int *olength)
458 {
459  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
460 }
461 
462 
463 int decode_tec_dcm0( int iarr[]
464  ,int *packetData
465  ,int dlength
466  ,int nlen
467  ,int *olength)
468 {
469 
470  if ( packetData == 0) return -1;
471  int i;
472 
473  // we clear the output vector if NLEN is not 0
474  if (nlen > 0)
475  {
476  for (i=0; i<nlen;) iarr[i++]=0;
477  }
478 
479  int *sptr = &packetData[5];
480 
481 
482  // COUT << "index: " << i << "value " << std::hex << sptr[i] << " " << sptr[i+1]
483  // << std::dec << std::endl;
484  // COUT << "dlength = " << dlength << "nlen= " << nlen << std::endl;
485 
486  int j;
487  int b20;
488  int nrl = 0;
489 
490  i = 0;
491  //COUT << "first word " << std::hex << sptr[i] << std::dec << std::endl;
492  while ( (sptr[i] & 0x80000000) == 0)
493  {
494  // COUT << i << " " << std::hex << sptr[i] << std::dec << std::endl;
495  if ( i > dlength -5) break;
496  /*
497  test if i is greater than NLEN; we exceed the
498  allowed space in ARR then
499  */
500 
501  // COUT << "in loop, i= " << i << " " << nrl <<" "
502  // << std::hex << sptr[i] << std::dec << std::endl;
503 
504  b20 = sptr[i] & 0xfffff; // these are the 20 bits in one 32 bit word.
505 
506  int upperbits = (sptr[i] >> 20 ) & 0xfff;
507  int wordnr = upperbits & 0x01f;
508  int channel = (upperbits >> 5 ) & 0x3f;
509 
510  //if (channel < 5 ) COUT << "found channel" << channel << " wordnr " << wordnr << std::endl;
511  nrl = channel * 80 + wordnr *4;
512  // get bits 0...4 first
513  j = 0;
514  iarr[nrl++] = (b20 >>j ) & 0x1f;
515  //if (channel < 5 ) COUT << "-- " << channel << " " << nrl-1<< " " << iarr[nrl-1] << std::endl;
516 
517  // then bits 5,,,,9...
518  j = 5;
519  iarr[nrl++] = (b20 >>j ) & 0x1f;
520  //if (channel < 5 ) COUT << "-- " << channel << " " << nrl-1 << " " << iarr[nrl-1] << std::endl;
521 
522  // then bits 10.. 14...
523  j = 10;
524  iarr[nrl++] = (b20 >>j ) & 0x1f;
525  //if (channel < 5 ) COUT << "-- " << channel << " " <<nrl-1 << " " << iarr[nrl-1] << std::endl;
526 
527  // and finally bits 15-19.
528  j = 15;
529  iarr[nrl++] = (b20 >>j ) & 0x1f;
530  //if (channel < 5 ) COUT << "-- " << channel << " " << nrl-1 << " " << iarr[nrl-1] << std::endl;
531 
532  i++;
533 
534 
535  }
536 
537  *olength = 64 * 80 ;
538  return 0;
539 
540 }
541 
542 
543 int decode_rich_dcm0( int iarr[]
544  ,int *packetData
545  ,int dlength
546  ,int nlen
547  ,int *olength)
548 {
549  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
550 }
551 
552 
553 int decode_tof_dcm0( int iarr[]
554  ,int *packetData
555  ,int dlength
556  ,int nlen
557  ,int *olength)
558 {
559  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
560 }
561 
562 // ------------------------------------------------------------
563 int decode_pbsc_dcm0( int iarr[]
564  ,int *packetData
565  ,int dlength
566  ,int nlen
567  ,int *olength)
568 {
569 
570  if ( packetData == 0) return -1;
571  typedef struct {
572  int post;
573  int pre;
574  int timing;
575  } *emchannel;
576 
577  int i;
578 
579  // we clear the output vector if NLEN is not 0
580  for (i=0; i<nlen;) iarr[i++]=0;
581 
582  emchannel emc = (emchannel) &packetData[8];
583 
584  int channel;
585 
586  for (i=0; i < 144 ; i++)
587  {
588  /*
589  test if i is greater than NLEN; we exceed the
590  allowed space in ARR then
591  */
592 
593  channel= ( emc->timing >> 20) & 0xff;
594 
595  if (nlen > 0 && 5*channel >= nlen)
596  {
597  COUT << "too short" << ENDL;
598  *olength = (channel+1)*5;
599  return -1;
600  }
601 
602 
603  if ( (emc->timing & 0x90000 && emc->post &0xc0000 && emc->pre & 0xa0000 )
604  && channel >= 0 && channel < 144 )
605  {
606 
607  if ( emc->post & 0x8000) // high!
608  {
609  iarr[channel] = (emc->timing & 0xfff);
610  iarr[channel+1] = 0;
611  iarr[channel+2] = (emc->post & 0xfff);
612  iarr[channel+3] = 0;
613  iarr[channel+4] = (emc->pre & 0xfff);
614  }
615 
616  else
617  {
618  iarr[channel] = (emc->timing & 0xfff);
619  iarr[channel+1] = (emc->post & 0xfff);
620  iarr[channel+2] = 0;
621  iarr[channel+3] = (emc->pre & 0xfff);
622  iarr[channel+4] = 0;
623  }
624  }
625 
626  emc++;
627  }
628  *olength = 144*5;
629  return 0;
630 }
631 //------------------------------------------------------------
632 int decode_pbsc_dcm32( int iarr[]
633  ,int *packetData
634  ,int dlength
635  ,int nlen
636  ,int *olength)
637 {
638  if ( packetData == 0) return -1;
639 
640  typedef struct {
641  int timing;
642  int higain_post;
643  int logain_post;
644  int higain_pre;
645  int logain_pre;
646  } *emchannel;
647 
648  int i;
649 
650  // we clear the output vector if NLEN is not 0
651  if (nlen > 0)
652  {
653  for (i=0; i<nlen;) iarr[i++]=0;
654  }
655 
656  emchannel emc = (emchannel) &packetData[9];
657 
658  int nrl = 0;
659  int j = 0;
660 
661  for (i=0; i < 192 ; i++)
662  {
663  /*
664  test if i is greater than NLEN; we exceed the
665  allowed space in ARR then
666  */
667  if (nlen > 0 && j >= nlen)
668  {
669  COUT << "too short" << ENDL;
670  *olength = j+1;
671  return -1;
672  }
673 
674  iarr[j++] = (emc->timing & 0xfff);
675  iarr[j++] = (emc->higain_post & 0xfff);
676  iarr[j++] = (emc->logain_post & 0xfff);
677  iarr[j++] = (emc->higain_pre & 0xfff);
678  iarr[j++] = (emc->logain_pre & 0xfff);
679 
680  nrl = j;
681  emc++;
682  }
683  *olength = nrl+1;
684  return 0;
685 }
686 
687 // ------------------------------------------------------------
688 
689 int decode_pbgl_dcm0( int iarr[]
690  ,int *packetData
691  ,int dlength
692  ,int nlen
693  ,int *olength)
694 {
695  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
696 }
697 
698 
699 int decode_muta_dcm0( int iarr[]
700  ,int *packetData
701  ,int dlength
702  ,int nlen
703  ,int *olength)
704 {
705  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
706 }
707 
708 
709 // ------------------------------------------------------------
710 // ------------------------------------------------------------
711 // modefied for mutr 2023 words format
712 int decode_mutc_dcm0( int iarr[]
713  ,int *packetData
714  ,int dlength
715  ,int nlen
716  ,int *olength)
717 {
718  if ( packetData == 0) return -1;
719 
720  int i;
721 
722  // we clear the output vector if NLEN is not 0
723  if (nlen > 0)
724  {
725  for (i=0; i<nlen;) iarr[i++]=0;
726  }
727 
728  // int *ic = &packetData[10];
729  int *ic = &packetData[5]; // start from k[5], missing 4 cells and one header word
730 
731  int j = 0;
732 
733  // if (nlen > 0 && nlen < 4*128)
734  if (nlen > 0 && nlen < 63*32) // 63 samples , 32 channels
735  {
736  COUT << "too short" << ENDL;
737  *olength = 0;
738  return -1;
739  }
740 
741  // for (i=0; i < 4*128 ; i++)
742  for (i=0; i < 63*32 ; i++)
743  {
744 
745  iarr[j++] = ic[i];
746 
747  }
748  // *olength = 4*128;
749  *olength = 63*32;
750  return 0;
751 
752 }
753 
754 
755 
756 int decode_muid_dcm0( int iarr[]
757  ,int *packetData
758  ,int dlength
759  ,int nlen
760  ,int *olength)
761 {
762  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
763 }
764 
765 int decode_zdc_dcm0( int iarr[]
766  ,int *packetData
767  ,int dlength
768  ,int nlen
769  ,int *olength)
770 {
771  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
772 }
773 
774 
775 int decode_rich_ll1( int iarr[]
776  ,int *packetData
777  ,int dlength
778  ,int nlen
779  ,int *olength)
780 {
781  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
782 }
783 
784 int decode_mvd_ll1( int iarr[]
785  ,int *packetData
786  ,int dlength
787  ,int nlen
788  ,int *olength)
789 {
790  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
791 }
792 
793 int decode_bbc_ll1( int iarr[]
794  ,int *packetData
795  ,int dlength
796  ,int nlen
797  ,int *olength)
798 {
799  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
800 }
801 
802 int decode_ntczdc_ll1( int iarr[]
803  ,int *packetData
804  ,int dlength
805  ,int nlen
806  ,int *olength)
807 {
808  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
809 }
810 
811 int decode_big_ll1( int iarr[]
812  ,int *packetData
813  ,int dlength
814  ,int nlen
815  ,int *olength)
816 {
817  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
818 }
819 
820 int decode_tof_ll1( int iarr[]
821  ,int *packetData
822  ,int dlength
823  ,int nlen
824  ,int *olength)
825 {
826  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
827 }
828 
829 int decode_muid_ll1( int iarr[]
830  ,int *packetData
831  ,int dlength
832  ,int nlen
833  ,int *olength)
834 {
835  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
836 }
837 
838 int decode_ert_ll1( int iarr[]
839  ,int *packetData
840  ,int dlength
841  ,int nlen
842  ,int *olength)
843 {
844  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
845 }
846 
847 int decode_pbgl_ll1( int iarr[]
848  ,int *packetData
849  ,int dlength
850  ,int nlen
851  ,int *olength)
852 {
853  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
854 }
855 
856 int decode_pbsc_ll1( int iarr[]
857  ,int *packetData
858  ,int dlength
859  ,int nlen
860  ,int *olength)
861 {
862  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
863 }
864 
865 int decode_gl1( int iarr[]
866  ,int *packetData
867  ,int dlength
868  ,int nlen
869  ,int *olength)
870 {
871  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
872 }
873 
874 
875 int decode_gl1p( int iarr[]
876  ,int *packetData
877  ,int dlength
878  ,int nlen
879  ,int *olength)
880 {
881  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
882 }
883 
884 
885 int decode_bbc_dcm1( int iarr[]
886  ,int *packetData
887  ,int dlength
888  ,int nlen
889  ,int *olength)
890 {
891  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
892 }
893 
894 
895 int decode_mvd_dcm1( int iarr[]
896  ,int *packetData
897  ,int dlength
898  ,int nlen
899  ,int *olength)
900 {
901  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
902 }
903 
904 
905 int decode_dch_dcm1( int iarr[]
906  ,int *packetData
907  ,int dlength
908  ,int nlen
909  ,int *olength)
910 {
911  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
912 }
913 
914 
915 int decode_pc_dcm1( int iarr[]
916  ,int *packetData
917  ,int dlength
918  ,int nlen
919  ,int *olength)
920 {
921  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
922 }
923 
924 
925 int decode_tec_dcm1( int iarr[]
926  ,int *packetData
927  ,int dlength
928  ,int nlen
929  ,int *olength)
930 {
931  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
932 }
933 
934 
935 int decode_rich_dcm1( int iarr[]
936  ,int *packetData
937  ,int dlength
938  ,int nlen
939  ,int *olength)
940 {
941  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
942 }
943 
944 
945 int decode_tof_dcm1( int iarr[]
946  ,int *packetData
947  ,int dlength
948  ,int nlen
949  ,int *olength)
950 {
951  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
952 }
953 
954 
955 int decode_pbsc_dcm1( int iarr[]
956  ,int *packetData
957  ,int dlength
958  ,int nlen
959  ,int *olength)
960 {
961  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
962 }
963 
964 
965 int decode_pbgl_dcm1( int iarr[]
966  ,int *packetData
967  ,int dlength
968  ,int nlen
969  ,int *olength)
970 {
971  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
972 }
973 
974 
975 int decode_muta_dcm1( int iarr[]
976  ,int *packetData
977  ,int dlength
978  ,int nlen
979  ,int *olength)
980 {
981  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
982 }
983 
984 
985 
986 // ----- modefied for mutr 532 words format, place holder, for MC
987 int decode_mutc_dcm1( int iarr[]
988  ,int *packetData
989  ,int dlength
990  ,int nlen
991  ,int *olength)
992 {
993  if ( packetData == 0) return -1;
994  int i;
995 
996  // we clear the output vector if NLEN is not 0
997  if (nlen > 0){
998  for (i=0; i<nlen;) iarr[i++]=0;
999  }
1000 
1001  // int *ic = &packetData[10];
1002  int *ic = &packetData[10]; // start from k[10]
1003 
1004  int j = 0;
1005 
1006 
1007  // if (nlen > 0 && nlen < 128) // 1 sample , 128 channels
1008  if (nlen > 0 && nlen < 512){ // 4 samples, 128 channels
1009 
1010  COUT << "too short" << ENDL;
1011  *olength = 0;
1012  return -1;
1013  }
1014 
1015  // for (i=0; i < 128 ; i++)
1016  for (i=0; i < 512 ; i++) {
1017  iarr[j++] = ic[i];
1018  }
1019  *olength = 512;
1020  // *olength = 128;
1021  return 0;
1022 }
1023 
1024 int decode_muid_dcm1( int iarr[]
1025  ,int *packetData
1026  ,int dlength
1027  ,int nlen
1028  ,int *olength)
1029 {
1030  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1031 }
1032 
1033 int decode_zdc_dcm1( int iarr[]
1034  ,int *packetData
1035  ,int dlength
1036  ,int nlen
1037  ,int *olength)
1038 {
1039  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1040 }
1041 
1042 int decode_bbc_dcm2( int iarr[]
1043  ,int *packetData
1044  ,int dlength
1045  ,int nlen
1046  ,int *olength)
1047 {
1048  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1049 }
1050 
1051 
1052 int decode_mvd_dcm2( int iarr[]
1053  ,int *packetData
1054  ,int dlength
1055  ,int nlen
1056  ,int *olength)
1057 {
1058  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1059 }
1060 
1061 
1062 int decode_dch_dcm2( int iarr[]
1063  ,int *packetData
1064  ,int dlength
1065  ,int nlen
1066  ,int *olength)
1067 {
1068  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1069 }
1070 
1071 
1072 int decode_pc_dcm2( int iarr[]
1073  ,int *packetData
1074  ,int dlength
1075  ,int nlen
1076  ,int *olength)
1077 {
1078  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1079 }
1080 
1081 int decode_pc_dcm3( int iarr[]
1082  ,int *packetData
1083  ,int dlength
1084  ,int nlen
1085  ,int *olength)
1086 {
1087  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1088 }
1089 
1090 
1091 int decode_tec_dcm2( int iarr[]
1092  ,int *packetData
1093  ,int dlength
1094  ,int nlen
1095  ,int *olength)
1096 {
1097  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1098 }
1099 
1100 
1101 int decode_rich_dcm2( int iarr[]
1102  ,int *packetData
1103  ,int dlength
1104  ,int nlen
1105  ,int *olength)
1106 {
1107  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1108 }
1109 
1110 
1111 int decode_tof_dcm2( int iarr[]
1112  ,int *packetData
1113  ,int dlength
1114  ,int nlen
1115  ,int *olength)
1116 {
1117  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1118 }
1119 
1120 
1121 int decode_pbsc_dcm2( int iarr[]
1122  ,int *packetData
1123  ,int dlength
1124  ,int nlen
1125  ,int *olength)
1126 {
1127  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1128 }
1129 
1130 
1131 int decode_pbgl_dcm2( int iarr[]
1132  ,int *packetData
1133  ,int dlength
1134  ,int nlen
1135  ,int *olength)
1136 {
1137  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1138 }
1139 
1140 
1141 int decode_muta_dcm2( int iarr[]
1142  ,int *packetData
1143  ,int dlength
1144  ,int nlen
1145  ,int *olength)
1146 {
1147  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1148 }
1149 
1150 // ----- modefied for mutr 532 words format, pass-through mode
1151 int decode_mutc_dcm2( int iarr[]
1152  ,int *packetData
1153  ,int dlength
1154  ,int nlen
1155  ,int *olength)
1156 {
1157  if ( packetData == 0) return -1;
1158  int i;
1159 
1160  // we clear the output vector if NLEN is not 0
1161  if (nlen > 0){
1162  for (i=0; i<nlen;) iarr[i++]=0;
1163  }
1164 
1165  // int *ic = &packetData[10];
1166  int *ic = &packetData[10]; // start from k[10]
1167 
1168  int j = 0;
1169 
1170  if (nlen > 0 && nlen < 512){ // 4 samples , 128 channels
1171  COUT << "too short" << ENDL;
1172  *olength = 0;
1173  return -1;
1174  }
1175 
1176  for (i=0; i < 512 ; i++) {
1177  iarr[j++] = ic[i];
1178  }
1179 
1180  *olength = 512;
1181  return 0;
1182 
1183 }
1184 
1185 int decode_muid_dcm2( int iarr[]
1186  ,int *packetData
1187  ,int dlength
1188  ,int nlen
1189  ,int *olength)
1190 {
1191  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1192 }
1193 
1194 int decode_zdc_dcm2( int iarr[]
1195  ,int *packetData
1196  ,int dlength
1197  ,int nlen
1198  ,int *olength)
1199 {
1200  return decode_id4evt( iarr, packetData, dlength, nlen, olength);
1201 }
1202 
1203 
1204 int decode_pbsc_dcms( int iarr[]
1205 
1206  ,int *packetData
1207  ,int dlength
1208  ,int nlen
1209  ,int *olength)
1210 {
1211 
1212  if ( packetData == 0) return -1;
1213  typedef struct
1214  {
1215  int timing;
1216  int post;
1217  int pre;
1218  } *emchannel;
1219 
1220  int i;
1221 
1222  // we clear the output vector if NLEN is not 0
1223  if (nlen > 0)
1224  {
1225  for (i=0; i<nlen;) iarr[i++]=0;
1226  }
1227 
1228  emchannel emc = (emchannel) &packetData[9];
1229 
1230  int nrl = 0;
1231  int j = 0;
1232 
1233  for (i=0; i < 144 ; i++)
1234  {
1235  /*
1236  test if i is greater than NLEN; we exceed the
1237  allowed space in ARR then
1238  */
1239  if (nlen > 0 && j >= nlen)
1240  {
1241  COUT << "too short" << ENDL;
1242  *olength = j+1;
1243  return -1;
1244  }
1245 
1246  if ( emc->post & 0x1000) // high!
1247  {
1248  iarr[j++] = (emc->timing & 0xfff);
1249  iarr[j++] = 0;
1250  iarr[j++] = (emc->post & 0xfff);
1251  iarr[j++] = 0;
1252  iarr[j++] = (emc->pre & 0xfff);
1253  }
1254 
1255  else
1256  {
1257  iarr[j++] = (emc->timing & 0xfff);
1258  iarr[j++] = (emc->post & 0xfff);
1259  iarr[j++] = 0;
1260  iarr[j++] = (emc->pre & 0xfff);
1261  iarr[j++] = 0;
1262  }
1263 
1264  nrl = j;
1265  emc++;
1266  }
1267  *olength = nrl+1;
1268  return 0;
1269 }
1270 
1271 // ----- modefied for mutr 532 words format, pass-through mode
1272 int decode_mutc_dcm3( int iarr[]
1273  ,int *packetData
1274  ,int dlength
1275  ,int nlen
1276  ,int *olength)
1277 {
1278  if ( packetData == 0) return -1;
1279  int i;
1280 
1281  // we clear the output vector if NLEN is not 0
1282  if (nlen > 0){
1283  for (i=0; i<nlen;) iarr[i++]=0;
1284  }
1285 
1286  // int *ic = &packetData[10];
1287  int *ic = &packetData[10]; // start from k[10]
1288 
1289  int j = 0;
1290 
1291  if (nlen > 0 && nlen < 512){ // 4 samples , 128 channels
1292  COUT << "too short" << ENDL;
1293  *olength = 0;
1294  return -1;
1295  }
1296 
1297  for (i=0; i < 512 ; i++) {
1298  iarr[j++] = ic[i];
1299  }
1300 
1301  *olength = 512;
1302  return 0;
1303 
1304 }
1305 
1306 
1307 
1308