@@ -294,13 +294,16 @@ 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 );
304+ ret = shiftInputs (digitsMap, digits, mTFOrbit );
302305 if (mCheckConsistency ) {
303- ret = checkReadoutConsistentncy (digits, trgclassmask);
306+ ret = checkReadoutConsistentncy (digits, trgclassmask, trgclassmaskNOTRGDet );
304307 }
305308 }
306309 if (mDoDigits && !mDecodeInps ) {
@@ -530,12 +533,6 @@ int RawDataDecoder::shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit
530533int RawDataDecoder::shiftInputs (std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask)
531534{
532535 // 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 ;
539536 std::map<o2::InteractionRecord, CTPDigit> digitsMapShifted;
540537 auto L0shift = o2::ctp::TriggerOffsetsParam::Instance ().LM_L0 ;
541538 auto L1shift = L0shift + o2::ctp::TriggerOffsetsParam::Instance ().L0_L1 ;
@@ -593,86 +590,77 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
593590 }
594591 }
595592 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- }
619593 digits.push_back (dig.second );
620594 }
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;
595+ return 0 ;
630596}
631597//
632- int RawDataDecoder::checkReadoutConsistentncy (o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask)
598+ int RawDataDecoder::checkReadoutConsistentncy (o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask, uint64_t trgclassmaskNoTrgDet )
633599{
600+ LOG (debug) << " Checking readout" ;
634601 int ret = 0 ;
635- int lost = 0 ;
602+ static int nerror = 0 ;
636603 for (auto const & digit : digits) {
637604 // if class mask => inps
638605 for (int i = 0 ; i < digit.CTPClassMask .size (); i++) {
639- if (digit.CTPClassMask [i] & trgclassmask) {
606+ bool trgcls = trgclassmask & (1ull << i);
607+ if (digit.CTPClassMask [i] & trgcls) {
640608 const CTPClass* cls = mCTPConfig .getCTPClassFromHWIndex (i);
641609 if (cls == nullptr ) {
642- LOG (error) << " Class mask index not found in CTP config:" << i;
610+ if (nerror < mErrorMax ) {
611+ LOG (error) << " Class mask index not found in CTP config:" << i;
612+ nerror++;
613+ }
643614 ret = 128 ;
644615 continue ;
645616 }
617+ mClassCountersA [i]++;
618+ if (cls->descriptor == nullptr )
619+ continue ;
646620 uint64_t clsinpmask = cls->descriptor ->getInputsMask ();
647621 uint64_t diginpmask = digit.CTPInputMask .to_ullong ();
648622 if (!((clsinpmask & diginpmask) == clsinpmask)) {
649- LOG (error) << " CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
623+ if (nerror < mErrorMax ) {
624+ LOG (error) << " Cls=>Inps: CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
625+ nerror++;
626+ }
627+ mClassErrorsA [i]++;
650628 ret = 128 ;
651629 }
652630 }
653631 }
654632 // if inps => class mask
655633 for (auto const & cls : mCTPConfig .getCTPClasses ()) {
656- uint64_t clsinpmask = cls.descriptor ->getInputsMask ();
634+ // cls.printStream(std::cout);
635+ if (cls.descriptor == nullptr )
636+ continue ;
637+ uint64_t clsinpmask = cls.descriptor ->getInputsMask (); // class definition
657638 uint64_t diginpmask = digit.CTPInputMask .to_ullong ();
658639 uint64_t digclsmask = digit.CTPClassMask .to_ullong ();
659640 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++;
641+ if (cls.classMask & trgclassmask) {
642+ mClassCountersB [cls.getIndex ()]++;
643+ if ((cls.classMask & digclsmask) == 0 ) {
644+ int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance ().customOffset [o2::detectors::DetID::CTP];
645+ int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance ().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance ().L0_L1_classes - 1 ;
646+ offset = o2::constants::lhc::LHCMaxBunches - offset;
647+ if (digit.intRecord .bc < offset) {
648+ if ((nerror < mErrorMax ) && (cls.classMask & ~trgclassmaskNoTrgDet)) {
649+ LOG (info) << " Inp=>Cls: CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
650+ nerror++;
651+ }
652+ mClassErrorsB [cls.getIndex ()]++;
653+ ret = 256 ;
654+ } else {
655+ mLostDueToShift ++;
656+ }
669657 }
670658 }
671659 }
672660 }
673661 }
674- if (lost ) {
675- LOG (info ) << " LOST classes because of shift:" << lost ;
662+ if (mLostDueToShift ) {
663+ LOG (debug ) << " LOST classes because of shift:" << mLostDueToShift ;
676664 }
677665 return ret;
678666}
0 commit comments