503 switch (w & 0xF0000000)
507 printf(
"unit %d, word %5d: 0x%08x: Unknown data\n", unit, i, w);
512 uint32_t trigNo = w & 0x00FFFFFF;
513 printf(
"unit %d, word %5d: 0x%08x: Event header: unit %d, trigger %d\n", unit, i, w, unit, trigNo);
518 uint32_t ts = w&0x00FFFFFF;
519 printf(
"unit %d, word %5d: 0x%08x: Timestamp %d\n", unit, i, w, ts);
524 int group = (w&0x70)>>4;
525 int chan = (w&0x7) | (group<<3);
526 printf(
"unit %d, word %5d: 0x%08x: Group %d, Channel %2d\n", unit, i, w, group, chan);
533 printf(
"unit %d, word %5d: 0x%08x: 64-bit padding\n", unit, i, w);
537 int sample1 = w & 0x3FFF;
538 int sample2 = (w>>16) & 0x3FFF;
539 printf(
"unit %d, word %5d: 0x%08x: samples 0x%04x 0x%04x (%d %d)\n", unit, i, w, sample1, sample2, sample1, sample2);
544 int t = w & 0x00FFFFFF;
545 printf(
"unit %d, word %5d: 0x%08x: Time %d\n", unit, i, w, t);
550 int c = w & 0x00FFFFFF;
551 printf(
"unit %d, word %5d: 0x%08x: Charge %d\n", unit, i, w, c);
556 uint32_t trigNo2 = w & 0x00FFFFFF;
557 printf(
"unit %d, word %5d: 0x%08x: Event trailer: unit %d, trigger %d\n", unit, i, w, unit, trigNo2);
618 static bool swap =
SWAP;
627 printf(
"UnpackVF48A: UnpackEvent unit %d, group %d, wcount %d, first word: 0x%08x, last word: 0x%08x\n", unit, group, wcount, data[0], data[wcount-1]);
638 int headerTrigNo = -1;
639 int trailerTrigNo = -1;
641 int timestampCount = 0;
642 int timestampFlag = 0;
643 uint32_t timestamp1 = 0;
644 uint32_t timestamp2 = 0;
646 for (
int i=0; i<wcount; i++)
648 uint32_t w = data[i];
651 if (((w&0xF0FFFFFF)==0xF0FFFFFF) && (w != 0xFFFFFFFF))
654 if (swap && (w != 0xdeadbeef)) {
655 uint32_t w0 = w&0x000000FF;
656 uint32_t w1 = w&0x0000FF00;
657 uint32_t w2 = w&0x00FF0000;
658 uint32_t w3 = w&0xFF000000;
659 w = (w0<<(16+8)) | (w1<<8) | (w2>>8) | (w3>>(16+8));
664 switch (w & 0xF0000000)
671 printf(
"unit %d, word %5d: 0x%08x: reading from empty EB FIFO\n", unit, i, w);
678 printf(
"unit %d, word %5d: 0x%08x: DMA marker\n", unit, i, w);
688 printf(
"unit %d, word %5d: 0x%08x: unexpected data\n", unit, i, w);
694 printf(
"*** Unit %d, group %d, trigger %d: Unexpected data at %5d: 0x%08x, skipping to next event header\n", unit, group, headerTrigNo, i, w);
701 int group = (w & 0x00000007);
704 printf(
"unit %d, word %5d: 0x%08x: switch to data from group %d\n", unit, i, w, group);
711 uint32_t trigNo = w & 0x00FFFFFF;
714 printf(
"unit %d, word %5d: 0x%08x: Event header: unit %d, group %d, trigger %d\n", unit, i, w, unit, group, trigNo);
717 if (0 && trigNo > 1) {
718 if (trigNo != c->headerTrigNo+1) {
719 printf(
"*** Unit %d, group %d, trigger %d: Out of sequence trigger %d should be %d\n", unit, group, trigNo, trigNo, c->headerTrigNo+1);
725 headerTrigNo = trigNo;
734 uint32_t ts = w&0x00FFFFFF;
737 printf(
"unit %d, word %5d: 0x%08x: Timestamp %d, count %d\n", unit, i, w, ts, timestampCount);
739 if (timestampCount == 0)
741 else if (timestampCount == 1)
744 printf(
"*** Unit %d, group %d, trigger %d: Unexpected timestamp count: %d\n", unit, group, headerTrigNo, timestampCount);
758 int cgroup = (w&0x70)>>4;
764 printf(
"*** Unit %d, group %d, trigger %d: data at %5d: 0x%08x, Invalid cgroup number %d should be zero\n", unit, group, headerTrigNo, i, w, cgroup);
772 printf(
"*** Unit %d, group %d, trigger %d: data at %5d: 0x%08x, Invalid group number %d should be zero\n", unit, group, headerTrigNo, i, w, group);
779 chan = (w&0x7) | (cgroup<<3);
782 printf(
"unit %d, word %5d: 0x%08x: Group %d, Channel %2d\n", unit, i, w, cgroup, chan);
785 printf(
"*** Unit %d, group %d, trigger %d: data at %5d: 0x%08x, Bad channel number %d\n", unit, group, headerTrigNo, i, w, chan);
791 if (timestampCount) {
792 uint64_t ts48 = timestamp1 | (((uint64_t)timestamp2) << 24);
794 if (ts48 == 0 && headerTrigNo == 1 &&
ts_first[unit][group] != 0) {
795 printf(
"*** Unit %d, group %d, trigger %d: Group %d unexpected event counter and timestamp reset!\n", unit, group, headerTrigNo, group);
802 if (ts48 == 0 && headerTrigNo == 1)
814 if (ts48 ==
ts_last[unit][cgroup])
816 printf(
"*** Unit %d, group %d, trigger %d: Group %d has invalid timestamp %d, should be more than %d\n", unit, group, headerTrigNo, group, (
int)ts48, (
int)
ts_last[unit][cgroup]);
824 double timestamp = (ts48 -
ts_first[unit][group])/
fFreq[unit];
837 if (headerTrigNo < 4) {
838 printf(
"AAA unit %d, group %d, trigNo %d, ts 0x%x 0x%x, base 0x%08x, ts %f\n", unit, group, headerTrigNo, timestamp2, timestamp1, (uint32_t)(
ts_first[unit][group]&0xFFFFFFFF), timestamp);
840 if (headerTrigNo == 2)
845 m->
trigno[cgroup] = headerTrigNo;
855 printf(
"*** Unit %d, group %d, trigger %d: Duplicate data for channel %d: already have %d samples\n", unit, group, headerTrigNo, chan, m->
channels[chan].
numSamples);
877 printf(
"unit %d, word %5d: 0x%08x: out of sequence adc samples\n", unit, i, w);
882 printf(
"*** Unit %d, group %d, trigger %d: Unexpected adc samples data at %5d: 0x%08x (no module %p or bad channel number %d)\n", unit, group, headerTrigNo, i, w, m, chan);
890 int sample1 = w & 0x3FFF;
891 int sample2 = (w>>16) & 0x3FFF;
894 printf(
"unit %d, word %5d: 0x%08x: samples %4d: 0x%04x 0x%04x (%d %d)\n", unit, i, w, cc->
numSamples, sample1, sample2, sample1, sample2);
909 printf(
"*** Previously ignored %d out of sequence adc samples\n", xc);
911 printf(
"*** Unit %d, group %d, trigger %d: Out of sequence adc samples for channel %d at %d, word 0x%08x\n", unit, group, headerTrigNo, cc->
channel, i, w);
928 printf(
"*** Unit %d group %d channel %d has too many samples: %d\n", unit, group, chan, cc->
numSamples);
940 printf(
"unit %d, word %5d: 0x%08x: out of sequence data\n", unit, i, w);
945 printf(
"*** Unit %d, group %d, trigger %d: Unexpected time data at %5d: 0x%08x (no module %p or bad channel number %d)\n", unit, group, headerTrigNo, i, w, m, chan);
955 int t = w & 0x00FFFFFF;
957 printf(
"unit %d, word %5d: 0x%08x: Time %d\n", unit, i, w, t);
967 printf(
"unit %d, word %5d: 0x%08x: out of sequence data\n", unit, i, w);
972 printf(
"*** Unit %d, group %d, trigger %d: Unexpected charge data at %5d: 0x%08x (no module %p or bad channel number %d)\n", unit, group, headerTrigNo, i, w, m, chan);
981 int charge = w & 0x00FFFFFF;
983 printf(
"unit %d, word %5d: 0x%08x: Charge %d\n", unit, i, w, charge);
985 if ((w & 0x0F000000) == 0x00000000)
986 m->
hitMask[chan>>3] = w & 0xFF;
997 printf(
"unit %d, word %5d: 0x%08x: out of sequence data\n", unit, i, w);
1002 printf(
"*** Unit %d, group %d, trigger %d: Unexpected event trailer at %5d: 0x%08x (no module %p or bad channel number %d)\n", unit, group, headerTrigNo, i, w, m, chan);
1015 uint32_t trigNo = w & 0x00FFFFFF;
1017 trailerTrigNo = trigNo;
1020 printf(
"unit %d, word %5d: 0x%08x: Event trailer: unit %d, group %d, trigger %d, module complete mask 0x%x\n", unit, i, w, unit, group, trailerTrigNo, m->
completeGroupMask);
1024 if (trigNo != (uint32_t)headerTrigNo)
1026 printf(
"*** Unit %d, group %d, trigger %d: event trailer trigger mismatch: see %d, should be %d\n", unit, group, headerTrigNo, trigNo, m->
trigger);