162 int rvcL1 = rdat[2] & 0x7ff;
165 int eventNumberL1 = (rdat[2] >> 12) & 0xfffff;
170 bool dataFormatKnown =
false;
173 int numberOfWindows = -1;
175 int dataFormatVersionExpected = -1;
177 int revoClockDeltaExpected = 4;
179 int cntr127DeltaExpected = 4;
191 dataFormatKnown =
true;
192 dataFormatVersionExpected = 0;
195 numberOfWindows = 24;
196 dataFormatKnown =
true;
197 dataFormatVersionExpected = 2;
200 numberOfWindows = 48;
201 dataFormatKnown =
true;
202 dataFormatVersionExpected = 1;
205 numberOfWindows = 48;
206 dataFormatKnown =
true;
207 dataFormatVersionExpected = 4;
210 numberOfWindows = 96;
211 dataFormatKnown =
true;
212 dataFormatVersionExpected = 5;
215 if (!dataFormatKnown) {
216 if (!m_reportedAlreadyRun_1) {
217 B2INFO(
"Unknown data format / error / exiting. This condition is reported only once per run.");
218 m_reportedAlreadyRun_1 =
true;
242 unsigned int testPattern;
244 int revoClockLast = -1;
245 int cntr127Last = -1;
247 bool performBufferAnalysis =
true;
248 bool reportAllErrors =
true;
252 int counterDummyWindows = 0;
253 unsigned int testPatternDummyEvent = 0xbbbb;
254 for (
int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
255 int index = iWindow * windowSize + 3;
256 testPattern = (rdat[index] >> 16) & 0xffff;
257 if (testPattern == testPatternDummyEvent) {
258 counterDummyWindows++;
261 if (!m_overrideControlBits) {
264 testPattern = (rdat[index + 2] >> 29) & 0x7;
265 if (testPattern & 0x1) performBufferAnalysis =
false;
266 if (testPattern & 0x2) reportAllErrors =
false;
272 if (counterDummyWindows == numberOfWindows) {
273 performBufferAnalysis =
false;
275 if (counterDummyWindows != 0) {
276 if (reportAllErrors) B2ERROR(
"Corrupted data? numberOfWindows = " << numberOfWindows <<
", counterDummyWindows = " <<
277 counterDummyWindows);
278 performBufferAnalysis =
false;
388 if (performBufferAnalysis) {
392 int slotSegmentLast[8];
394 int otherInformationLast[8];
397 int combinedT0RVC2GDLLast;
400 for (
int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
404 int clockCycle = iWindow * 4;
407 unsigned int errorCountWindow = 0;
410 int index = iWindow * windowSize + 3;
412 unsigned int testPatternExpected = 0;
413 if (dataFormatVersionExpected == 1) testPatternExpected = 0xbbba;
414 else if (dataFormatVersionExpected >= 2) testPatternExpected = 0xdddd;
416 testPattern = (rdat[index] >> 16) & 0xffff;
418 if (testPattern != testPatternExpected) {
419 if (reportAllErrors) B2ERROR(
"An unexpected test pattern: " << std::hex << testPattern << std::dec <<
", window " << iWindow <<
420 ", index = " << index);
424 int dataFormatVersionNow = (rdat[index] >> 11) & 0x1f;
426 if (dataFormatVersionNow == 3 && dataFormatVersionExpected == 2) {
427 dataFormatVersionExpected = 3;
429 if (dataFormatVersionNow == 4 && dataFormatVersionExpected == 2) {
430 dataFormatVersionExpected = 4;
432 if (dataFormatVersionNow == 5) {
433 dataFormatVersionExpected = 5;
436 if (dataFormatVersionNow != dataFormatVersionExpected) {
437 if (reportAllErrors) {
438 if (!m_reportedAlreadyRun_2) {
439 B2ERROR(
"An unexpected data format version: " << dataFormatVersionNow <<
", window " << iWindow <<
", index = " <<
441 m_reportedAlreadyRun_2 =
true;
448 int revoClockNow = rdat[index] & 0x7ff;
451 if (revoClockLast != -1) {
453 int revoClockDeltaNow = revoClockNow - revoClockLast;
454 if (revoClockDeltaNow != revoClockDeltaExpected) {
455 if (revoClockDeltaNow != -1276) {
456 if (reportAllErrors) B2INFO(
"rvc changed by an unexpected number of units (2): " << revoClockDeltaNow <<
", last rvc = " <<
458 ", current rvc = " << revoClockNow <<
", window " << iWindow <<
", index = " << index);
463 if (revoClockNow > 1279) {
464 if (reportAllErrors) B2ERROR(
"An unexpected rvc value = " << revoClockNow <<
", window " << iWindow <<
", index = " << index);
467 revoClockLast = revoClockNow;
469 int cntr127Now = (rdat[index + 1] >> 16) & 0xffff;
472 if (cntr127Last != -1) {
474 int cntr127DeltaNow = cntr127Now - cntr127Last;
475 if (cntr127DeltaNow != cntr127DeltaExpected) {
477 if (cntr127DeltaNow != 65444 && cntr127DeltaNow != -65532) {
478 if (reportAllErrors) B2INFO(
"cntr127 changed by an unexpected number of units (2): " << cntr127DeltaNow <<
", cntr127 last = " <<
480 ", cntr127 now = " << cntr127Now <<
", window " << iWindow <<
", index = " << index + 1);
485 cntr127Last = cntr127Now;
493 int otherInformation[8];
497 int combinedT0 = rdat[index + 2] & 0x3ffff;
498 int combinedT0RVC2GDL = (rdat[index + 2] >> 18) & 0x7ff;
499 int combinedT0ClockCycle = clockCycle;
501 slotT0[0] = (rdat[index + 4] >> 16) & 0xffff;
502 slotT0[1] = (rdat[index + 4]) & 0xffff;
503 slotT0[2] = (rdat[index + 5] >> 16) & 0xffff;
504 slotT0[3] = (rdat[index + 5]) & 0xffff;
505 slotT0[4] = (rdat[index + 6] >> 16) & 0xffff;
506 slotT0[5] = (rdat[index + 6]) & 0xffff;
507 slotT0[6] = (rdat[index + 7] >> 16) & 0xffff;
508 slotT0[7] = (rdat[index + 7]) & 0xffff;
510 slotNHit[0] = (rdat[index + 8] >> 20) & 0x3ff;
511 slotNHit[1] = (rdat[index + 8] >> 10) & 0x3ff;
512 slotNHit[2] = (rdat[index + 8]) & 0x3ff;
514 slotNHit[3] = (rdat[index + 9] >> 20) & 0x3ff;
515 slotNHit[4] = (rdat[index + 9] >> 10) & 0x3ff;
516 slotNHit[5] = (rdat[index + 9]) & 0x3ff;
518 slotNHit[6] = (rdat[index + 10] >> 10) & 0x3ff;
519 slotNHit[7] = (rdat[index + 10]) & 0x3ff;
521 slotSegment[0] = (rdat[index + 11] >> 28) & 0xf;
522 slotSegment[1] = (rdat[index + 11] >> 24) & 0xf;
523 slotSegment[2] = (rdat[index + 11] >> 20) & 0xf;
524 slotSegment[3] = (rdat[index + 11] >> 16) & 0xf;
525 slotSegment[4] = (rdat[index + 11] >> 12) & 0xf;
526 slotSegment[5] = (rdat[index + 11] >> 8) & 0xf;
527 slotSegment[6] = (rdat[index + 11] >> 4) & 0xf;
528 slotSegment[7] = (rdat[index + 11] >> 0) & 0xf;
531 otherInformation[0] = (rdat[index + 12] >> 16) & 0xffff;
532 otherInformation[1] = (rdat[index + 12]) & 0xffff;
533 otherInformation[2] = (rdat[index + 13] >> 16) & 0xffff;
534 otherInformation[3] = (rdat[index + 13]) & 0xffff;
535 otherInformation[4] = (rdat[index + 14] >> 16) & 0xffff;
536 otherInformation[5] = (rdat[index + 14]) & 0xffff;
537 otherInformation[6] = (rdat[index + 15] >> 16) & 0xffff;
538 otherInformation[7] = (rdat[index + 15]) & 0xffff;
544 if (combinedT0 != combinedT0Last ||
545 combinedT0RVC2GDL != combinedT0RVC2GDLLast
555 combinedT0ClockCycle,
561 m_TRGTOPCombinedT0DecisionArray.appendNew(combinedT0Decision);
576 combinedT0Last = combinedT0;
577 combinedT0RVC2GDLLast = combinedT0RVC2GDL;
581 for (
int i = 0; i < 8; i++) {
583 if (otherInformation[i] != otherInformationLast[i]) {
585 int slotOther = i + 1;
588 2 * otherInformation[i],
599 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
601 otherInformationLast[i] = otherInformation[i];
610 if (channel == 0) slotNow = 9;
612 for (
int i = 0; i < 8; i++) {
614 if (slotT0[i] != slotT0Last[i] ||
615 slotNHit[i] != slotNHitLast[i] ||
616 slotSegment[i] != slotSegmentLast[i]) {
651 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
665 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
672 slotT0Last[i] = slotT0[i];
673 slotNHitLast[i] = slotNHit[i];
674 slotSegmentLast[i] = slotSegment[i];
683 combinedT0Last = combinedT0;
684 for (
int i = 0; i < 8; i++) {
685 slotT0Last[i] = slotT0[i];
686 slotNHitLast[i] = slotNHit[i];
687 slotSegmentLast[i] = slotSegment[i];
688 otherInformationLast[i] = otherInformation[i];
690 combinedT0Last = combinedT0;
691 combinedT0RVC2GDLLast = combinedT0RVC2GDL;