Skip to content

Commit d51c7de

Browse files
committed
dev: adding consistency check classes vs inputs to readout
1 parent 06cbb68 commit d51c7de

File tree

4 files changed

+70
-6
lines changed

4 files changed

+70
-6
lines changed

DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class CTPConfiguration
162162
int getInputIndex(const std::string& name) const;
163163
std::string getClassNameFromIndex(int index) { return mCTPClasses[index].name; };
164164
std::string getClassNameFromHWIndex(int index);
165+
const CTPClass* getCTPClassFromHWIndex(const int index) const;
165166
bool isMaskInInputs(const uint64_t& mask) const;
166167
bool isBCMaskInConfig(const std::string maskname) const;
167168
const BCMask* isBCMaskInConfigP(const std::string bcmask) const;

DataFormats/Detectors/CTP/src/Configuration.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,17 @@ std::string CTPConfiguration::getClassNameFromHWIndex(int index)
790790
std::string ret = "not found";
791791
return ret;
792792
}
793+
const CTPClass* CTPConfiguration::getCTPClassFromHWIndex(int index) const
794+
{
795+
const CTPClass* clsfound = nullptr;
796+
for(auto const& cls: mCTPClasses){
797+
if(index == cls.getIndex()){
798+
clsfound = &cls;
799+
break;
800+
}
801+
}
802+
return clsfound;
803+
}
793804
bool CTPConfiguration::isMaskInInputs(const uint64_t& mask) const
794805
{
795806
for (auto const& inp : mInputs) {

Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class RawDataDecoder
4545
void setMAXErrors(int m) { mErrorMax = m; }
4646
int setLumiInp(int lumiinp, std::string inp);
4747
void setCTPConfig(CTPConfiguration cfg) { mCTPConfig = std::move(cfg); };
48+
void setCheckConsistency( bool check ) { mCheckConsistency = check;}
4849
uint32_t getIRRejected() const { return mIRRejected; }
4950
uint32_t getTCRRejected() const { return mTCRRejected; }
5051
std::vector<uint32_t>& getTFOrbits() { return mTFOrbits; }
@@ -54,12 +55,14 @@ class RawDataDecoder
5455
int init();
5556
static int shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit, std::bitset<48>& inpmask, int64_t shift, int level, std::map<o2::InteractionRecord, CTPDigit>& digmap);
5657
static int shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff);
58+
int checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask = 0xffffffffffffffff);
5759

5860
private:
5961
static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800;
6062
static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2;
6163
// true: full inps decoding includine latency shifts here; false: latency shifts in CTF decoder
6264
bool mDecodeInps = false;
65+
bool mCheckConsistency = false;
6366
// for digits
6467
bool mDoDigits = true;
6568
std::vector<CTPDigit> mOutputDigits;

Detectors/CTP/reconstruction/src/RawDataDecoder.cxx

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d
7979
if (mErrorIR < mErrorMax) {
8080
LOG(error) << "Two CTP IRs with the same timestamp:" << ir.bc << " " << ir.orbit << " pld:" << pld << " dig:" << digits[ir];
8181
}
82-
ret = 2;
82+
ret = 4;
8383
mErrorIR++;
8484
mStickyError = true;
8585
}
8686
} else {
8787
LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit;
88-
ret = 2;
88+
ret = 8;
8989
}
9090
} else if (linkCRU == o2::ctp::GBTLinkIDClassRec) {
9191
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
@@ -113,11 +113,11 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d
113113
mStickyError = true;
114114
}
115115
mErrorTCR++;
116-
ret = 3;
116+
ret = 16;
117117
}
118118
} else {
119119
LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit;
120-
ret = 3;
120+
ret = 32;
121121
}
122122
} else {
123123
LOG(error) << "Unxpected CTP CRU link:" << linkCRU;
@@ -298,7 +298,11 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
298298
trgclassmask = mCTPConfig.getTriggerClassMask();
299299
}
300300
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
301-
shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
301+
ret = shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
302+
if(mCheckConsistency) {
303+
ret = checkReadoutConsistentncy(digits, trgclassmask);
304+
}
305+
302306
}
303307
if (mDoDigits && !mDecodeInps) {
304308
for (auto const& dig : digitsMap) {
@@ -615,13 +619,58 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
615619
}
616620
digits.push_back(dig.second);
617621
}
622+
int ret = 0;
618623
if (nTwoI) { // Trigger class wo Input
619624
LOG(error) << "LM:" << nLM << " L0:" << nL0 << " L1:" << nL1 << " TwI:" << nTwI << " Trigger classes wo input:" << nTwoI;
625+
ret = 64;
620626
}
621627
if (nTwoIlost) {
622628
LOG(warn) << " Trigger classes wo input from diff latency 1:" << nTwoIlost;
623629
}
624-
return 0;
630+
return ret;
631+
}
632+
//
633+
int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask)
634+
{
635+
int ret = 0;
636+
int lost = 0;
637+
for(auto const& digit: digits) {
638+
// if class mask => inps
639+
for(int i = 0; i < digit.CTPClassMask.size(); i++){
640+
if(digit.CTPClassMask[i]){
641+
const CTPClass *cls = mCTPConfig.getCTPClassFromHWIndex(i);
642+
uint64_t clsinpmask = cls->descriptor->getInputsMask();
643+
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
644+
if(!((clsinpmask & diginpmask) == clsinpmask)) {
645+
LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
646+
ret = 128;
647+
}
648+
}
649+
}
650+
// if inps => class mask
651+
for(auto const& cls: mCTPConfig.getCTPClasses()) {
652+
uint64_t clsinpmask = cls.descriptor->getInputsMask();
653+
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
654+
uint64_t digclsmask = digit.CTPClassMask.to_ullong();
655+
if((clsinpmask & diginpmask) == clsinpmask) {
656+
if((cls.classMask & digclsmask) == 0) {
657+
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
658+
int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1;
659+
offset = o2::constants::lhc::LHCMaxBunches - offset;
660+
if(digit.intRecord.bc < offset) {
661+
LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
662+
ret = 256;
663+
} else {
664+
lost++;
665+
}
666+
}
667+
}
668+
}
669+
}
670+
if(lost) {
671+
LOG(info) << "LOST classes because of shift:" << lost;
672+
}
673+
return ret;
625674
}
626675
//
627676
int RawDataDecoder::setLumiInp(int lumiinp, std::string inp)

0 commit comments

Comments
 (0)