35 const int dataFormat = subBlock.
format();
40 if (sliceL != 1 || sliceF != 5)
return false;
46 std::vector<uint32_t> compStats(
s_formats);
47 std::vector<int> fadcDout(sliceF-1);
48 std::vector<int> fadcLens(sliceF-1);
50 std::vector<int> lutData;
51 std::vector<int> lutBcid;
52 std::vector<int> fadcData;
53 std::vector<int> fadcBcid;
54 subBlock.
ppmData(
chan, lutData, fadcData, lutBcid, fadcBcid);
56 int dataPresent = lutData[0] || lutBcid[0];
58 for (
int sl = 0; sl < sliceF; ++sl) {
59 if (fadcData[sl] >= fadcThreshold || fadcBcid[sl]) {
65 subBlock.
packer(dataPresent, 1);
66 if ( !dataPresent )
continue;
68 const int lutLen = subBlock.
minBits(lutData[0]);
72 for (
int sl = 0; sl < sliceF; ++sl) {
73 if (sl == 0) minFadc = fadcData[sl];
74 if (fadcData[sl] < minFadc) {
75 minFadc = fadcData[sl];
78 if (fadcData[sl] != fadcData[0] || fadcBcid[sl] != 0) fadcSame =
false;
80 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
83 if (lutData[0] == 0 && lutBcid[0] == 0 && fadcSame) {
89 }
else subBlock.
packer(0, 1);
92 const bool minFadcInRange = minFadc >= fadcBaseline &&
97 for (
int sl = 0; sl < sliceF; ++sl) {
99 fadcDout[
idx] = fadcData[sl] - minFadc;
101 if (
idx == 0 || fadcLens[
idx] > maxFadcLen) {
102 maxFadcLen = fadcLens[
idx];
106 if (sl != trigOffset) anyFadcBcid |= fadcBcid[sl];
107 else if (fadcBcid[sl] != (lutBcid[0] & 0
x1)) anyFadcBcid |= 1;
109 if (lutData[0] == 0 && lutBcid[0] == 0 &&
110 !anyFadcBcid && minFadcInRange && maxFadcLen < 4) {
113 if (maxFadcLen == 3)
header += 5;
115 minFadc -= fadcBaseline;
116 subBlock.
packer(minFadc, 4);
117 if (maxFadcLen < 2) maxFadcLen = 2;
118 for (
int idx = 0;
idx < sliceF-1; ++
idx) {
119 subBlock.
packer(fadcDout[
idx], maxFadcLen);
122 }
else if (lutLen <= 3 && ((lutData[0] == 0 && lutBcid[0] == 0) ||
124 && !anyFadcBcid && minFadcInRange && maxFadcLen <= 4) {
126 const int header = minOffset + 10;
132 subBlock.
packer(lutData[0], 3);
133 }
else subBlock.
packer(0, 1);
134 minFadc -= fadcBaseline;
135 subBlock.
packer(minFadc, 4);
136 for (
int idx = 0;
idx < sliceF-1; ++
idx) {
141 const int header = minOffset + 10;
143 if ( !minFadcInRange) {
144 const int minFadcLen = subBlock.
minBits(minFadc);
145 if (minFadcLen > maxFadcLen) maxFadcLen = minFadcLen;
148 if (maxFadcLen <= 8)
format = 4;
149 if (maxFadcLen <= 6)
format = 3;
151 if (lutData[0] || lutBcid[0]) subBlock.
packer(1, 1);
152 else subBlock.
packer(0, 1);
153 subBlock.
packer(anyFadcBcid, 1);
154 if (lutData[0] || lutBcid[0]) {
163 if (minFadcInRange) {
165 minFadc -= fadcBaseline;
166 subBlock.
packer(minFadc, 4);
171 for (
int idx = 0;
idx < sliceF-1; ++
idx) {
172 if (fadcLens[
idx] <= 4) {
193 if (
status[pin]) statusBit = 1;
194 if (
error[pin]) errorBit = 1;
196 subBlock.
packer(statusBit, 1);
197 subBlock.
packer(errorBit, 1);
198 if (statusBit || errorBit) {
201 else subBlock.
packer(0, 1);
220 switch (subBlock.
seqno()) {
250 if (sliceL != 1 || sliceF != 5) {
255 const int pedestal = subBlock.
pedestal();
260 std::vector<int> lutData;
261 std::vector<int> lutBcid;
262 std::vector<int> fadcData;
263 std::vector<int> fadcBcid;
273 const int minOffset =
header % 5;
276 lutData.push_back(0);
277 lutBcid.push_back(0);
280 for (
int sl = 0; sl < sliceF; ++sl) {
281 if (sl == minOffset) fadcData.push_back(minFadc);
283 fadcBcid.push_back(0);
287 const int minOffset =
header - 10;
289 const int anyLut = subBlock.
unpacker(1);
298 lutData.push_back(
lut);
299 lutBcid.push_back(
bcid);
302 for (
int sl = 0; sl < sliceF; ++sl) {
303 if (sl == minOffset) fadcData.push_back(minFadc);
305 fadcBcid.push_back(0);
309 const int anyBcid = subBlock.
unpacker(1);
315 lutData.push_back(
lut);
316 lutBcid.push_back(
bcid);
318 for (
int sl = 0; sl < sliceF; ++sl) {
320 if (sl == trigOffset) fbcid =
bcid & 0x1;
321 else if (anyBcid) fbcid = subBlock.
unpacker(1);
322 fadcBcid.push_back(fbcid);
327 for (
int sl = 0; sl < sliceF; ++sl) {
329 if (sl != minOffset) {
333 fadcData.push_back(fadc);
356 if (sliceL != 1 || sliceF != 5) {
361 const int pedestal = subBlock.
pedestal();
365 std::vector<uint32_t> compStats(
s_formats);
366 std::vector<int> lutData;
367 std::vector<int> lutBcid;
368 std::vector<int> fadcData;
369 std::vector<int> fadcBcid;
379 const int minOffset =
header % 5;
382 lutData.push_back(0);
383 lutBcid.push_back(0);
386 fadcData.push_back(minFadc);
387 fadcBcid.push_back(0);
388 for (
int sl = 1; sl < sliceF; ++sl) {
390 fadcBcid.push_back(0);
392 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
395 const int minOffset =
header - 10;
397 const int anyLut = subBlock.
unpacker(1);
406 lutData.push_back(
lut);
407 lutBcid.push_back(
bcid);
410 fadcData.push_back(minFadc);
411 fadcBcid.push_back(0);
412 for (
int sl = 1; sl < sliceF; ++sl) {
414 fadcBcid.push_back(0);
416 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
419 const int anyBcid = subBlock.
unpacker(1);
425 lutData.push_back(
lut);
426 lutBcid.push_back(
bcid);
428 for (
int sl = 0; sl < sliceF; ++sl) {
430 if (sl == trigOffset) fbcid =
bcid & 0x1;
431 else if (anyBcid) fbcid = subBlock.
unpacker(1);
432 fadcBcid.push_back(fbcid);
437 fadcData.push_back(minFadc);
438 for (
int sl = 1; sl < sliceF; ++sl) {
441 fadcData.push_back(subBlock.
unpacker(len) + minFadc);
443 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
449 lutData.push_back(0);
450 lutBcid.push_back(0);
454 for (
int sl = 0; sl < sliceF; ++sl) {
455 fadcData.push_back(fadc);
456 fadcBcid.push_back(0);
463 const int statusBit = subBlock.
unpacker(1);
464 const int errorBit = subBlock.
unpacker(1);
465 if (statusBit || errorBit) {
490 const int dataFormat = subBlock.
format();
496 const int compressionVersion = subBlock.
seqno();
501 if (compressionVersion == 5) {
503 if (run < 88701 || run > 88724) {
510 if (sliceL != 1 || sliceF != 5) {
519 std::vector<uint32_t> compStats(
s_formats);
520 std::vector<int> lutData;
521 std::vector<int> lutBcid;
522 std::vector<int> fadcData;
523 std::vector<int> fadcBcid;
526 if ( !subBlock.
unpacker(1) )
continue;
536 const int minOffset =
header % 5;
539 lutData.push_back(0);
540 lutBcid.push_back(0);
542 const int minFadc = subBlock.
unpacker(4) + fadcBaseline;
543 fadcData.push_back(minFadc);
544 fadcBcid.push_back(0);
545 for (
int sl = 1; sl < sliceF; ++sl) {
547 fadcBcid.push_back(0);
549 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
552 const int minOffset =
header - 10;
554 const int anyLut = subBlock.
unpacker(1);
563 lutData.push_back(
lut);
564 lutBcid.push_back(
bcid);
566 const int minFadc = subBlock.
unpacker(4) + fadcBaseline;
567 fadcData.push_back(minFadc);
568 fadcBcid.push_back(0);
569 for (
int sl = 1; sl < sliceF; ++sl) {
571 fadcBcid.push_back(0);
573 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
576 const int anyBcid = subBlock.
unpacker(1);
582 lutData.push_back(
lut);
583 lutBcid.push_back(
bcid);
585 for (
int sl = 0; sl < sliceF; ++sl) {
587 if (anyBcid) fbcid = subBlock.
unpacker(1);
588 else if (sl == trigOffset) fbcid =
bcid & 0x1;
589 fadcBcid.push_back(fbcid);
593 else minFadc = subBlock.
unpacker(4) + fadcBaseline;
594 fadcData.push_back(minFadc);
595 for (
int sl = 1; sl < sliceF; ++sl) {
598 fadcData.push_back(subBlock.
unpacker(len) + minFadc);
600 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
606 lutData.push_back(0);
607 lutBcid.push_back(0);
611 for (
int sl = 0; sl < sliceF; ++sl) {
612 fadcData.push_back(fadc);
613 fadcBcid.push_back(0);
620 const int statusBit = subBlock.
unpacker(1);
621 const int errorBit = subBlock.
unpacker(1);
622 const bool mcmAbsentIsError = compressionVersion < 4;
625 if (statusBit || errorBit) {