165 int rvcL1 = rdat[2] & 0x7ff;
168 int eventNumberL1 = (rdat[2] >> 12) & 0xfffff;
173 bool dataFormatKnown =
false;
176 int numberOfWindows = -1;
178 int dataFormatVersionExpected = -1;
180 int revoClockDeltaExpected = 4;
182 int cntr127DeltaExpected = 4;
194 dataFormatKnown =
true;
195 dataFormatVersionExpected = 0;
198 numberOfWindows = 24;
199 dataFormatKnown =
true;
200 dataFormatVersionExpected = 2;
203 numberOfWindows = 48;
204 dataFormatKnown =
true;
205 dataFormatVersionExpected = 1;
208 numberOfWindows = 48;
209 dataFormatKnown =
true;
210 dataFormatVersionExpected = 4;
213 numberOfWindows = 96;
214 dataFormatKnown =
true;
215 dataFormatVersionExpected = 5;
218 if (!dataFormatKnown) {
219 if (!m_reportedAlreadyRun_1) {
220 B2INFO(
"Unknown data format / error / exiting. This condition is reported only once per run.");
221 m_reportedAlreadyRun_1 =
true;
245 unsigned int testPattern;
247 int revoClockLast = -1;
248 int cntr127Last = -1;
250 bool performBufferAnalysis =
true;
251 bool reportAllErrors =
true;
255 int counterDummyWindows = 0;
256 unsigned int testPatternDummyEvent = 0xbbbb;
257 for (
int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
258 int index = iWindow * windowSize + 3;
259 testPattern = (rdat[index] >> 16) & 0xffff;
260 if (testPattern == testPatternDummyEvent) {
261 counterDummyWindows++;
264 if (!m_overrideControlBits) {
267 testPattern = (rdat[index + 2] >> 29) & 0x7;
268 if (testPattern & 0x1) performBufferAnalysis =
false;
269 if (testPattern & 0x2) reportAllErrors =
false;
275 if (counterDummyWindows == numberOfWindows) {
276 performBufferAnalysis =
false;
278 if (counterDummyWindows != 0) {
279 if (reportAllErrors) B2ERROR(
"Corrupted data? numberOfWindows = " << numberOfWindows <<
", counterDummyWindows = " <<
280 counterDummyWindows);
281 performBufferAnalysis =
false;
391 if (performBufferAnalysis) {
395 int slotSegmentLast[8];
397 int otherInformationLast[8];
400 int combinedT0RVC2GDLLast;
403 for (
int iWindow = 0; iWindow < numberOfWindows; iWindow++) {
407 int clockCycle = iWindow * 4;
410 unsigned int errorCountWindow = 0;
413 int index = iWindow * windowSize + 3;
415 unsigned int testPatternExpected = 0;
416 if (dataFormatVersionExpected == 1) testPatternExpected = 0xbbba;
417 else if (dataFormatVersionExpected >= 2) testPatternExpected = 0xdddd;
419 testPattern = (rdat[index] >> 16) & 0xffff;
421 if (testPattern != testPatternExpected) {
422 if (reportAllErrors) B2ERROR(
"An unexpected test pattern: " << std::hex << testPattern << std::dec <<
", window " << iWindow <<
423 ", index = " << index);
427 int dataFormatVersionNow = (rdat[index] >> 11) & 0x1f;
429 if (dataFormatVersionNow == 3 && dataFormatVersionExpected == 2) {
430 dataFormatVersionExpected = 3;
432 if (dataFormatVersionNow == 4 && dataFormatVersionExpected == 2) {
433 dataFormatVersionExpected = 4;
435 if (dataFormatVersionNow == 5) {
436 dataFormatVersionExpected = 5;
439 if (dataFormatVersionNow != dataFormatVersionExpected) {
440 if (reportAllErrors) {
441 if (!m_reportedAlreadyRun_2) {
442 B2ERROR(
"An unexpected data format version: " << dataFormatVersionNow <<
", window " << iWindow <<
", index = " <<
444 m_reportedAlreadyRun_2 =
true;
451 int revoClockNow = rdat[index] & 0x7ff;
454 if (revoClockLast != -1) {
456 int revoClockDeltaNow = revoClockNow - revoClockLast;
457 if (revoClockDeltaNow != revoClockDeltaExpected) {
458 if (revoClockDeltaNow != -1276) {
459 if (reportAllErrors) B2INFO(
"rvc changed by an unexpected number of units (2): " << revoClockDeltaNow <<
", last rvc = " <<
461 ", current rvc = " << revoClockNow <<
", window " << iWindow <<
", index = " << index);
466 if (revoClockNow > 1279) {
467 if (reportAllErrors) B2ERROR(
"An unexpected rvc value = " << revoClockNow <<
", window " << iWindow <<
", index = " << index);
470 revoClockLast = revoClockNow;
472 int cntr127Now = (rdat[index + 1] >> 16) & 0xffff;
475 if (cntr127Last != -1) {
477 int cntr127DeltaNow = cntr127Now - cntr127Last;
478 if (cntr127DeltaNow != cntr127DeltaExpected) {
480 if (cntr127DeltaNow != 65444 && cntr127DeltaNow != -65532) {
481 if (reportAllErrors) B2INFO(
"cntr127 changed by an unexpected number of units (2): " << cntr127DeltaNow <<
", cntr127 last = " <<
483 ", cntr127 now = " << cntr127Now <<
", window " << iWindow <<
", index = " << index + 1);
488 cntr127Last = cntr127Now;
496 int otherInformation[8];
500 int combinedT0 = rdat[index + 2] & 0x3ffff;
501 int combinedT0RVC2GDL = (rdat[index + 2] >> 18) & 0x7ff;
502 int combinedT0ClockCycle = clockCycle;
504 slotT0[0] = (rdat[index + 4] >> 16) & 0xffff;
505 slotT0[1] = (rdat[index + 4]) & 0xffff;
506 slotT0[2] = (rdat[index + 5] >> 16) & 0xffff;
507 slotT0[3] = (rdat[index + 5]) & 0xffff;
508 slotT0[4] = (rdat[index + 6] >> 16) & 0xffff;
509 slotT0[5] = (rdat[index + 6]) & 0xffff;
510 slotT0[6] = (rdat[index + 7] >> 16) & 0xffff;
511 slotT0[7] = (rdat[index + 7]) & 0xffff;
513 slotNHit[0] = (rdat[index + 8] >> 20) & 0x3ff;
514 slotNHit[1] = (rdat[index + 8] >> 10) & 0x3ff;
515 slotNHit[2] = (rdat[index + 8]) & 0x3ff;
517 slotNHit[3] = (rdat[index + 9] >> 20) & 0x3ff;
518 slotNHit[4] = (rdat[index + 9] >> 10) & 0x3ff;
519 slotNHit[5] = (rdat[index + 9]) & 0x3ff;
521 slotNHit[6] = (rdat[index + 10] >> 10) & 0x3ff;
522 slotNHit[7] = (rdat[index + 10]) & 0x3ff;
524 slotSegment[0] = (rdat[index + 11] >> 28) & 0xf;
525 slotSegment[1] = (rdat[index + 11] >> 24) & 0xf;
526 slotSegment[2] = (rdat[index + 11] >> 20) & 0xf;
527 slotSegment[3] = (rdat[index + 11] >> 16) & 0xf;
528 slotSegment[4] = (rdat[index + 11] >> 12) & 0xf;
529 slotSegment[5] = (rdat[index + 11] >> 8) & 0xf;
530 slotSegment[6] = (rdat[index + 11] >> 4) & 0xf;
531 slotSegment[7] = (rdat[index + 11] >> 0) & 0xf;
534 otherInformation[0] = (rdat[index + 12] >> 16) & 0xffff;
535 otherInformation[1] = (rdat[index + 12]) & 0xffff;
536 otherInformation[2] = (rdat[index + 13] >> 16) & 0xffff;
537 otherInformation[3] = (rdat[index + 13]) & 0xffff;
538 otherInformation[4] = (rdat[index + 14] >> 16) & 0xffff;
539 otherInformation[5] = (rdat[index + 14]) & 0xffff;
540 otherInformation[6] = (rdat[index + 15] >> 16) & 0xffff;
541 otherInformation[7] = (rdat[index + 15]) & 0xffff;
547 if (combinedT0 != combinedT0Last ||
548 combinedT0RVC2GDL != combinedT0RVC2GDLLast
558 combinedT0ClockCycle,
564 m_TRGTOPCombinedT0DecisionArray.appendNew(combinedT0Decision);
579 combinedT0Last = combinedT0;
580 combinedT0RVC2GDLLast = combinedT0RVC2GDL;
584 for (
int i = 0; i < 8; i++) {
586 if (otherInformation[i] != otherInformationLast[i]) {
588 int slotOther = i + 1;
591 2 * otherInformation[i],
602 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
604 otherInformationLast[i] = otherInformation[i];
613 if (channel == 0) slotNow = 9;
615 for (
int i = 0; i < 8; i++) {
617 if (slotT0[i] != slotT0Last[i] ||
618 slotNHit[i] != slotNHitLast[i] ||
619 slotSegment[i] != slotSegmentLast[i]) {
654 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
668 m_TRGTOPSlotTimingArray.appendNew(slotTiming);
675 slotT0Last[i] = slotT0[i];
676 slotNHitLast[i] = slotNHit[i];
677 slotSegmentLast[i] = slotSegment[i];
686 combinedT0Last = combinedT0;
687 for (
int i = 0; i < 8; i++) {
688 slotT0Last[i] = slotT0[i];
689 slotNHitLast[i] = slotNHit[i];
690 slotSegmentLast[i] = slotSegment[i];
691 otherInformationLast[i] = otherInformation[i];
693 combinedT0Last = combinedT0;
694 combinedT0RVC2GDLLast = combinedT0RVC2GDL;