@@ -294,13 +294,17 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
294294 }
295295 if (mDoDigits & mDecodeInps ) {
296296 uint64_t trgclassmask = 0xffffffffffffffff ;
297+ uint64_t trgclassmaskNOTRGDet = 0xffffffffffffffff ;
297298 if (mCTPConfig .getRunNumber () != 0 ) {
298- trgclassmask = mCTPConfig .getTriggerClassMask ();
299+ trgclassmask = mCTPConfig .getTriggerClassMaskWInputs ();
300+ trgclassmaskNOTRGDet = mCTPConfig .getTriggerClassMaskWInputsNoTrgDets ();
301+ // mCTPConfig.printStream(std::cout);
299302 }
300303 // std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
301- ret = shiftInputs (digitsMap, digits, mTFOrbit , trgclassmask);
302- if (mCheckConsistency ) {
303- ret = checkReadoutConsistentncy (digits, trgclassmask);
304+ ret = shiftInputs (digitsMap, digits, mTFOrbit );
305+ // if (mCheckConsistency) {
306+ if (1 ) {
307+ ret = checkReadoutConsistentncy (digits, trgclassmask, trgclassmaskNOTRGDet);
304308 }
305309 }
306310 if (mDoDigits && !mDecodeInps ) {
@@ -530,12 +534,6 @@ int RawDataDecoder::shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit
530534int RawDataDecoder::shiftInputs (std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask)
531535{
532536 // int nClasswoInp = 0; // counting classes without input which should never happen
533- int nLM = 0 ;
534- int nL0 = 0 ;
535- int nL1 = 0 ;
536- int nTwI = 0 ;
537- int nTwoI = 0 ;
538- int nTwoIlost = 0 ;
539537 std::map<o2::InteractionRecord, CTPDigit> digitsMapShifted;
540538 auto L0shift = o2::ctp::TriggerOffsetsParam::Instance ().LM_L0 ;
541539 auto L1shift = L0shift + o2::ctp::TriggerOffsetsParam::Instance ().L0_L1 ;
@@ -593,86 +591,77 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
593591 }
594592 }
595593 for (auto const & dig : digitsMapShifted) {
596- auto d = dig.second ;
597- if ((d.CTPInputMask & LMMASKInputs).count ()) {
598- nLM++;
599- }
600- if ((d.CTPInputMask & L0MASKInputs).count ()) {
601- nL0++;
602- }
603- if ((d.CTPInputMask & L1MASKInputs).count ()) {
604- nL1++;
605- }
606- if ((d.CTPClassMask ).to_ulong () & trgclassmask) {
607- if (d.CTPInputMask .count ()) {
608- nTwI++;
609- } else {
610- if (d.intRecord .bc == (o2::constants::lhc::LHCMaxBunches - L1shift)) { // input can be lost because latency class-l1input = 1
611- nTwoIlost++;
612- } else {
613- // LOG(error) << d.intRecord << " " << d.CTPClassMask << " " << d.CTPInputMask;
614- // std::cout << "ERROR:" << std::hex << d.CTPClassMask << " " << d.CTPInputMask << std::dec << std::endl;
615- nTwoI++;
616- }
617- }
618- }
619594 digits.push_back (dig.second );
620595 }
621- int ret = 0 ;
622- if (nTwoI) { // Trigger class wo Input
623- LOG (error) << " LM:" << nLM << " L0:" << nL0 << " L1:" << nL1 << " TwI:" << nTwI << " Trigger classes wo input:" << nTwoI;
624- ret = 64 ;
625- }
626- if (nTwoIlost) {
627- LOG (warn) << " Trigger classes wo input from diff latency 1:" << nTwoIlost;
628- }
629- return ret;
596+ return 0 ;
630597}
631598//
632- int RawDataDecoder::checkReadoutConsistentncy (o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask)
599+ int RawDataDecoder::checkReadoutConsistentncy (o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask, uint64_t trgclassmaskNoTrgDet )
633600{
601+ LOG (debug) << " Checking readout" ;
634602 int ret = 0 ;
635- int lost = 0 ;
603+ static int nerror = 0 ;
636604 for (auto const & digit : digits) {
637605 // if class mask => inps
638606 for (int i = 0 ; i < digit.CTPClassMask .size (); i++) {
639- if (digit.CTPClassMask [i] & trgclassmask) {
607+ bool trgcls = trgclassmask & (1ull << i);
608+ if (digit.CTPClassMask [i] & trgcls) {
640609 const CTPClass* cls = mCTPConfig .getCTPClassFromHWIndex (i);
641610 if (cls == nullptr ) {
642- LOG (error) << " Class mask index not found in CTP config:" << i;
611+ if (nerror < mErrorMax ) {
612+ LOG (error) << " Class mask index not found in CTP config:" << i;
613+ nerror++;
614+ }
643615 ret = 128 ;
644616 continue ;
645617 }
618+ mClassCountersA [i]++;
619+ if (cls->descriptor == nullptr )
620+ continue ;
646621 uint64_t clsinpmask = cls->descriptor ->getInputsMask ();
647622 uint64_t diginpmask = digit.CTPInputMask .to_ullong ();
648623 if (!((clsinpmask & diginpmask) == clsinpmask)) {
649- LOG (error) << " CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
624+ if (nerror < mErrorMax ) {
625+ LOG (error) << " Cls=>Inps: CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
626+ nerror++;
627+ }
628+ mClassErrorsA [i]++;
650629 ret = 128 ;
651630 }
652631 }
653632 }
654633 // if inps => class mask
655634 for (auto const & cls : mCTPConfig .getCTPClasses ()) {
656- uint64_t clsinpmask = cls.descriptor ->getInputsMask ();
635+ // cls.printStream(std::cout);
636+ if (cls.descriptor == nullptr )
637+ continue ;
638+ uint64_t clsinpmask = cls.descriptor ->getInputsMask (); // class definition
657639 uint64_t diginpmask = digit.CTPInputMask .to_ullong ();
658640 uint64_t digclsmask = digit.CTPClassMask .to_ullong ();
659641 if ((clsinpmask & diginpmask) == clsinpmask) {
660- if ((cls.classMask & digclsmask) == 0 ) {
661- int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance ().customOffset [o2::detectors::DetID::CTP];
662- int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance ().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance ().L0_L1_classes - 1 ;
663- offset = o2::constants::lhc::LHCMaxBunches - offset;
664- if (digit.intRecord .bc < offset) {
665- LOG (error) << " CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
666- ret = 256 ;
667- } else {
668- lost++;
642+ if (cls.classMask & trgclassmask) {
643+ mClassCountersB [cls.getIndex ()]++;
644+ if ((cls.classMask & digclsmask) == 0 ) {
645+ int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance ().customOffset [o2::detectors::DetID::CTP];
646+ int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance ().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance ().L0_L1_classes - 1 ;
647+ offset = o2::constants::lhc::LHCMaxBunches - offset;
648+ if (digit.intRecord .bc < offset) {
649+ if ((nerror < mErrorMax ) && (cls.classMask & ~trgclassmaskNoTrgDet)) {
650+ LOG (info) << " Inp=>Cls: CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
651+ nerror++;
652+ }
653+ mClassErrorsB [cls.getIndex ()]++;
654+ ret = 256 ;
655+ } else {
656+ mLostDueToShift ++;
657+ }
669658 }
670659 }
671660 }
672661 }
673662 }
674- if (lost ) {
675- LOG (info ) << " LOST classes because of shift:" << lost ;
663+ if (mLostDueToShift ) {
664+ LOG (debug ) << " LOST classes because of shift:" << mLostDueToShift ;
676665 }
677666 return ret;
678667}
0 commit comments