34 const int dataFormat = subBlock.
format();
39 if (sliceL != 1 || sliceF != 5)
return false;
45 std::vector<uint32_t> compStats(
s_formats);
46 std::vector<int> fadcDout(sliceF-1);
47 std::vector<int> fadcLens(sliceF-1);
49 std::vector<int> lutData;
50 std::vector<int> lutBcid;
51 std::vector<int> fadcData;
52 std::vector<int> fadcBcid;
53 subBlock.
ppmData(
chan, lutData, fadcData, lutBcid, fadcBcid);
55 int dataPresent = lutData[0] || lutBcid[0];
57 for (
int sl = 0; sl < sliceF; ++sl) {
58 if (fadcData[sl] >= fadcThreshold || fadcBcid[sl]) {
64 subBlock.
packer(dataPresent, 1);
65 if ( !dataPresent )
continue;
71 for (
int sl = 0; sl < sliceF; ++sl) {
72 if (sl == 0) minFadc = fadcData[sl];
73 if (fadcData[sl] < minFadc) {
74 minFadc = fadcData[sl];
77 if (fadcData[sl] != fadcData[0] || fadcBcid[sl] != 0) fadcSame =
false;
79 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
82 if (lutData[0] == 0 && lutBcid[0] == 0 && fadcSame) {
88 }
else subBlock.
packer(0, 1);
91 const bool minFadcInRange = minFadc >= fadcBaseline &&
96 for (
int sl = 0; sl < sliceF; ++sl) {
98 fadcDout[
idx] = fadcData[sl] - minFadc;
100 if (
idx == 0 || fadcLens[
idx] > maxFadcLen) {
101 maxFadcLen = fadcLens[
idx];
105 if (sl != trigOffset) anyFadcBcid |= fadcBcid[sl];
106 else if (fadcBcid[sl] != (lutBcid[0] & 0
x1)) anyFadcBcid |= 1;
108 if (lutData[0] == 0 && lutBcid[0] == 0 &&
109 !anyFadcBcid && minFadcInRange && maxFadcLen < 4) {
112 if (maxFadcLen == 3)
header += 5;
114 minFadc -= fadcBaseline;
115 subBlock.
packer(minFadc, 4);
116 if (maxFadcLen < 2) maxFadcLen = 2;
117 for (
int idx = 0;
idx < sliceF-1; ++
idx) {
118 subBlock.
packer(fadcDout[
idx], maxFadcLen);
121 }
else if (lutLen <= 3 && ((lutData[0] == 0 && lutBcid[0] == 0) ||
123 && !anyFadcBcid && minFadcInRange && maxFadcLen <= 4) {
125 const int header = minOffset + 10;
131 subBlock.
packer(lutData[0], 3);
132 }
else subBlock.
packer(0, 1);
133 minFadc -= fadcBaseline;
134 subBlock.
packer(minFadc, 4);
135 for (
int idx = 0;
idx < sliceF-1; ++
idx) {
140 const int header = minOffset + 10;
142 if ( !minFadcInRange) {
144 if (minFadcLen > maxFadcLen) maxFadcLen = minFadcLen;
147 if (maxFadcLen <= 8)
format = 4;
148 if (maxFadcLen <= 6)
format = 3;
150 if (lutData[0] || lutBcid[0]) subBlock.
packer(1, 1);
151 else subBlock.
packer(0, 1);
152 subBlock.
packer(anyFadcBcid, 1);
153 if (lutData[0] || lutBcid[0]) {
162 if (minFadcInRange) {
164 minFadc -= fadcBaseline;
165 subBlock.
packer(minFadc, 4);
170 for (
int idx = 0;
idx < sliceF-1; ++
idx) {
171 if (fadcLens[
idx] <= 4) {
192 if (
status[pin]) statusBit = 1;
193 if (
error[pin]) errorBit = 1;
195 subBlock.
packer(statusBit, 1);
196 subBlock.
packer(errorBit, 1);
197 if (statusBit || errorBit) {
200 else subBlock.
packer(0, 1);
219 switch (subBlock.
seqno()) {
249 if (sliceL != 1 || sliceF != 5) {
254 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;
268 const int minOffset =
header % 5;
271 lutData.push_back(0);
272 lutBcid.push_back(0);
275 for (
int sl = 0; sl < sliceF; ++sl) {
276 if (sl == minOffset) fadcData.push_back(minFadc);
278 fadcBcid.push_back(0);
282 const int minOffset =
header - 10;
284 const int anyLut = subBlock.
unpacker(1);
293 lutData.push_back(
lut);
294 lutBcid.push_back(
bcid);
297 for (
int sl = 0; sl < sliceF; ++sl) {
298 if (sl == minOffset) fadcData.push_back(minFadc);
300 fadcBcid.push_back(0);
304 const int anyBcid = subBlock.
unpacker(1);
310 lutData.push_back(
lut);
311 lutBcid.push_back(
bcid);
313 for (
int sl = 0; sl < sliceF; ++sl) {
315 if (sl == trigOffset) fbcid =
bcid & 0x1;
316 else if (anyBcid) fbcid = subBlock.
unpacker(1);
317 fadcBcid.push_back(fbcid);
322 for (
int sl = 0; sl < sliceF; ++sl) {
324 if (sl != minOffset) {
328 fadcData.push_back(fadc);
351 if (sliceL != 1 || sliceF != 5) {
356 const int pedestal = subBlock.
pedestal();
360 std::vector<uint32_t> compStats(
s_formats);
362 std::vector<int> lutData;
363 std::vector<int> lutBcid;
364 std::vector<int> fadcData;
365 std::vector<int> fadcBcid;
370 const int minOffset =
header % 5;
373 lutData.push_back(0);
374 lutBcid.push_back(0);
377 fadcData.push_back(minFadc);
378 fadcBcid.push_back(0);
379 for (
int sl = 1; sl < sliceF; ++sl) {
381 fadcBcid.push_back(0);
383 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
386 const int minOffset =
header - 10;
388 const int anyLut = subBlock.
unpacker(1);
397 lutData.push_back(
lut);
398 lutBcid.push_back(
bcid);
401 fadcData.push_back(minFadc);
402 fadcBcid.push_back(0);
403 for (
int sl = 1; sl < sliceF; ++sl) {
405 fadcBcid.push_back(0);
407 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
410 const int anyBcid = subBlock.
unpacker(1);
416 lutData.push_back(
lut);
417 lutBcid.push_back(
bcid);
419 for (
int sl = 0; sl < sliceF; ++sl) {
421 if (sl == trigOffset) fbcid =
bcid & 0x1;
422 else if (anyBcid) fbcid = subBlock.
unpacker(1);
423 fadcBcid.push_back(fbcid);
428 fadcData.push_back(minFadc);
429 for (
int sl = 1; sl < sliceF; ++sl) {
432 fadcData.push_back(subBlock.
unpacker(len) + minFadc);
434 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
440 lutData.push_back(0);
441 lutBcid.push_back(0);
445 for (
int sl = 0; sl < sliceF; ++sl) {
446 fadcData.push_back(fadc);
447 fadcBcid.push_back(0);
454 const int statusBit = subBlock.
unpacker(1);
455 const int errorBit = subBlock.
unpacker(1);
456 if (statusBit || errorBit) {
481 const int dataFormat = subBlock.
format();
487 const int compressionVersion = subBlock.
seqno();
492 if (compressionVersion == 5) {
494 if (run < 88701 || run > 88724) {
501 if (sliceL != 1 || sliceF != 5) {
510 std::vector<uint32_t> compStats(
s_formats);
513 if ( !subBlock.
unpacker(1) )
continue;
515 std::vector<int> lutData;
516 std::vector<int> lutBcid;
517 std::vector<int> fadcData;
518 std::vector<int> fadcBcid;
523 const int minOffset =
header % 5;
526 lutData.push_back(0);
527 lutBcid.push_back(0);
529 const int minFadc = subBlock.
unpacker(4) + fadcBaseline;
530 fadcData.push_back(minFadc);
531 fadcBcid.push_back(0);
532 for (
int sl = 1; sl < sliceF; ++sl) {
534 fadcBcid.push_back(0);
536 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
539 const int minOffset =
header - 10;
541 const int anyLut = subBlock.
unpacker(1);
550 lutData.push_back(
lut);
551 lutBcid.push_back(
bcid);
553 const int minFadc = subBlock.
unpacker(4) + fadcBaseline;
554 fadcData.push_back(minFadc);
555 fadcBcid.push_back(0);
556 for (
int sl = 1; sl < sliceF; ++sl) {
558 fadcBcid.push_back(0);
560 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
563 const int anyBcid = subBlock.
unpacker(1);
569 lutData.push_back(
lut);
570 lutBcid.push_back(
bcid);
572 for (
int sl = 0; sl < sliceF; ++sl) {
574 if (anyBcid) fbcid = subBlock.
unpacker(1);
575 else if (sl == trigOffset) fbcid =
bcid & 0x1;
576 fadcBcid.push_back(fbcid);
580 else minFadc = subBlock.
unpacker(4) + fadcBaseline;
581 fadcData.push_back(minFadc);
582 for (
int sl = 1; sl < sliceF; ++sl) {
585 fadcData.push_back(subBlock.
unpacker(len) + minFadc);
587 if (minOffset)
std::swap(fadcData[0], fadcData[minOffset]);
593 lutData.push_back(0);
594 lutBcid.push_back(0);
598 for (
int sl = 0; sl < sliceF; ++sl) {
599 fadcData.push_back(fadc);
600 fadcBcid.push_back(0);
607 const int statusBit = subBlock.
unpacker(1);
608 const int errorBit = subBlock.
unpacker(1);
609 const bool mcmAbsentIsError = compressionVersion < 4;
612 if (statusBit || errorBit) {