From 06cbb6890a669adff2f2b13b855a446139519c50 Mon Sep 17 00:00:00 2001 From: lietava Date: Thu, 20 Feb 2025 15:19:14 +0100 Subject: [PATCH 1/3] fix: adding return in orbit reset code --- Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx b/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx index 0f4203d994402..c27f12cbb6f11 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx @@ -76,6 +76,7 @@ int main(int argc, char** argv) std::cerr << e.what() << ", application will now exit" << std::endl; exit(2); } + int ret = 0; std::string action = vm["action"].as(); std::vector vect; std::string ccdbPath; @@ -120,10 +121,10 @@ int main(int argc, char** argv) int64_t runnum = vm["run-number"].as(); metadata["runNumber"] = std::to_string(runnum); std::cout << "Storing:" << ccdbPath << " " << metadata["runNumber"] << " tmin:" << tmin << " tmax:" << tmax << " ts:" << tt << std::endl; - api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax); + ret = api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax); } else { std::cout << "Storing:" << ccdbPath << " tmin:" << tmin << " tmax:" << tmax << " ts:" << tt << std::endl; - api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax); + ret = api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax); } } // @@ -132,7 +133,7 @@ int main(int argc, char** argv) TFile* f = TFile::Open(file.c_str(), "RECREATE"); if (f == nullptr) { std::cout << "Error: File" << file << " could not be open for writing !!!" << std::endl; - return 1; + ret++;; } else { std::cout << "File" << file << " being writen." << std::endl; f->WriteObject(&vect, "ccdb_object"); @@ -141,5 +142,5 @@ int main(int argc, char** argv) } else { std::cout << "No file created" << std::endl; } - return 0; + return ret; } From d51c7de2e35993d38b8adf52481316acdc712fd6 Mon Sep 17 00:00:00 2001 From: lietava Date: Thu, 20 Feb 2025 15:20:43 +0100 Subject: [PATCH 2/3] dev: adding consistency check classes vs inputs to readout --- .../include/DataFormatsCTP/Configuration.h | 1 + .../Detectors/CTP/src/Configuration.cxx | 11 ++++ .../CTPReconstruction/RawDataDecoder.h | 3 + .../CTP/reconstruction/src/RawDataDecoder.cxx | 61 +++++++++++++++++-- 4 files changed, 70 insertions(+), 6 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index e06c77ad3dfc2..4ff0256f33827 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -162,6 +162,7 @@ class CTPConfiguration int getInputIndex(const std::string& name) const; std::string getClassNameFromIndex(int index) { return mCTPClasses[index].name; }; std::string getClassNameFromHWIndex(int index); + const CTPClass* getCTPClassFromHWIndex(const int index) const; bool isMaskInInputs(const uint64_t& mask) const; bool isBCMaskInConfig(const std::string maskname) const; const BCMask* isBCMaskInConfigP(const std::string bcmask) const; diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 2ae8fc1b03ffc..a1b82a08c6910 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -790,6 +790,17 @@ std::string CTPConfiguration::getClassNameFromHWIndex(int index) std::string ret = "not found"; return ret; } +const CTPClass* CTPConfiguration::getCTPClassFromHWIndex(int index) const +{ + const CTPClass* clsfound = nullptr; + for(auto const& cls: mCTPClasses){ + if(index == cls.getIndex()){ + clsfound = &cls; + break; + } + } + return clsfound; +} bool CTPConfiguration::isMaskInInputs(const uint64_t& mask) const { for (auto const& inp : mInputs) { diff --git a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h index 16a8ec6a6bef1..fd5a0b6082788 100644 --- a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h +++ b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h @@ -45,6 +45,7 @@ class RawDataDecoder void setMAXErrors(int m) { mErrorMax = m; } int setLumiInp(int lumiinp, std::string inp); void setCTPConfig(CTPConfiguration cfg) { mCTPConfig = std::move(cfg); }; + void setCheckConsistency( bool check ) { mCheckConsistency = check;} uint32_t getIRRejected() const { return mIRRejected; } uint32_t getTCRRejected() const { return mTCRRejected; } std::vector& getTFOrbits() { return mTFOrbits; } @@ -54,12 +55,14 @@ class RawDataDecoder int init(); static int shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit, std::bitset<48>& inpmask, int64_t shift, int level, std::map& digmap); static int shiftInputs(std::map& digitsMap, o2::pmr::vector& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff); + int checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask = 0xffffffffffffffff); private: static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800; static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2; // true: full inps decoding includine latency shifts here; false: latency shifts in CTF decoder bool mDecodeInps = false; + bool mCheckConsistency = false; // for digits bool mDoDigits = true; std::vector mOutputDigits; diff --git a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx index 74e5b7481163d..47dd5187735c3 100644 --- a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx +++ b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx @@ -79,13 +79,13 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d if (mErrorIR < mErrorMax) { LOG(error) << "Two CTP IRs with the same timestamp:" << ir.bc << " " << ir.orbit << " pld:" << pld << " dig:" << digits[ir]; } - ret = 2; + ret = 4; mErrorIR++; mStickyError = true; } } else { LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit; - ret = 2; + ret = 8; } } else if (linkCRU == o2::ctp::GBTLinkIDClassRec) { 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 mStickyError = true; } mErrorTCR++; - ret = 3; + ret = 16; } } else { LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit; - ret = 3; + ret = 32; } } else { LOG(error) << "Unxpected CTP CRU link:" << linkCRU; @@ -298,7 +298,11 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector& digit } digits.push_back(dig.second); } + int ret = 0; if (nTwoI) { // Trigger class wo Input LOG(error) << "LM:" << nLM << " L0:" << nL0 << " L1:" << nL1 << " TwI:" << nTwI << " Trigger classes wo input:" << nTwoI; + ret = 64; } if (nTwoIlost) { LOG(warn) << " Trigger classes wo input from diff latency 1:" << nTwoIlost; } - return 0; + return ret; +} +// +int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask) +{ + int ret = 0; + int lost = 0; + for(auto const& digit: digits) { + // if class mask => inps + for(int i = 0; i < digit.CTPClassMask.size(); i++){ + if(digit.CTPClassMask[i]){ + const CTPClass *cls = mCTPConfig.getCTPClassFromHWIndex(i); + uint64_t clsinpmask = cls->descriptor->getInputsMask(); + uint64_t diginpmask = digit.CTPInputMask.to_ullong(); + if(!((clsinpmask & diginpmask) == clsinpmask)) { + LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask; + ret = 128; + } + } + } + // if inps => class mask + for(auto const& cls: mCTPConfig.getCTPClasses()) { + uint64_t clsinpmask = cls.descriptor->getInputsMask(); + uint64_t diginpmask = digit.CTPInputMask.to_ullong(); + uint64_t digclsmask = digit.CTPClassMask.to_ullong(); + if((clsinpmask & diginpmask) == clsinpmask) { + if((cls.classMask & digclsmask) == 0) { + int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP]; + int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1; + offset = o2::constants::lhc::LHCMaxBunches - offset; + if(digit.intRecord.bc < offset) { + LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; + ret = 256; + } else { + lost++; + } + } + } + } + } + if(lost) { + LOG(info) << "LOST classes because of shift:" << lost; + } + return ret; } // int RawDataDecoder::setLumiInp(int lumiinp, std::string inp) From bba9742f01bffd896702e0c710242802c7846a63 Mon Sep 17 00:00:00 2001 From: lietava Date: Thu, 20 Feb 2025 15:22:58 +0100 Subject: [PATCH 3/3] clang --- .../Detectors/CTP/src/Configuration.cxx | 4 +-- .../CTPReconstruction/RawDataDecoder.h | 2 +- .../CTP/reconstruction/src/RawDataDecoder.cxx | 25 +++++++++---------- .../workflowScalers/src/ctp-ccdb-orbit.cxx | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index a1b82a08c6910..03f9b38db0e9f 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -793,8 +793,8 @@ std::string CTPConfiguration::getClassNameFromHWIndex(int index) const CTPClass* CTPConfiguration::getCTPClassFromHWIndex(int index) const { const CTPClass* clsfound = nullptr; - for(auto const& cls: mCTPClasses){ - if(index == cls.getIndex()){ + for (auto const& cls : mCTPClasses) { + if (index == cls.getIndex()) { clsfound = &cls; break; } diff --git a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h index fd5a0b6082788..7579e9dc1d6f5 100644 --- a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h +++ b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h @@ -45,7 +45,7 @@ class RawDataDecoder void setMAXErrors(int m) { mErrorMax = m; } int setLumiInp(int lumiinp, std::string inp); void setCTPConfig(CTPConfiguration cfg) { mCTPConfig = std::move(cfg); }; - void setCheckConsistency( bool check ) { mCheckConsistency = check;} + void setCheckConsistency(bool check) { mCheckConsistency = check; } uint32_t getIRRejected() const { return mIRRejected; } uint32_t getTCRRejected() const { return mTCRRejected; } std::vector& getTFOrbits() { return mTFOrbits; } diff --git a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx index 47dd5187735c3..faa3dbac3e934 100644 --- a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx +++ b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx @@ -299,10 +299,9 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector& digits, { int ret = 0; int lost = 0; - for(auto const& digit: digits) { + for (auto const& digit : digits) { // if class mask => inps - for(int i = 0; i < digit.CTPClassMask.size(); i++){ - if(digit.CTPClassMask[i]){ - const CTPClass *cls = mCTPConfig.getCTPClassFromHWIndex(i); + for (int i = 0; i < digit.CTPClassMask.size(); i++) { + if (digit.CTPClassMask[i]) { + const CTPClass* cls = mCTPConfig.getCTPClassFromHWIndex(i); uint64_t clsinpmask = cls->descriptor->getInputsMask(); uint64_t diginpmask = digit.CTPInputMask.to_ullong(); - if(!((clsinpmask & diginpmask) == clsinpmask)) { + if (!((clsinpmask & diginpmask) == clsinpmask)) { LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask; ret = 128; } } } // if inps => class mask - for(auto const& cls: mCTPConfig.getCTPClasses()) { + for (auto const& cls : mCTPConfig.getCTPClasses()) { uint64_t clsinpmask = cls.descriptor->getInputsMask(); uint64_t diginpmask = digit.CTPInputMask.to_ullong(); uint64_t digclsmask = digit.CTPClassMask.to_ullong(); - if((clsinpmask & diginpmask) == clsinpmask) { - if((cls.classMask & digclsmask) == 0) { + if ((clsinpmask & diginpmask) == clsinpmask) { + if ((cls.classMask & digclsmask) == 0) { int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP]; int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1; offset = o2::constants::lhc::LHCMaxBunches - offset; - if(digit.intRecord.bc < offset) { - LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; + if (digit.intRecord.bc < offset) { + LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; ret = 256; } else { lost++; @@ -667,7 +666,7 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, } } } - if(lost) { + if (lost) { LOG(info) << "LOST classes because of shift:" << lost; } return ret; diff --git a/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx b/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx index c27f12cbb6f11..7dedcacbf6047 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx @@ -133,7 +133,7 @@ int main(int argc, char** argv) TFile* f = TFile::Open(file.c_str(), "RECREATE"); if (f == nullptr) { std::cout << "Error: File" << file << " could not be open for writing !!!" << std::endl; - ret++;; + ret++; } else { std::cout << "File" << file << " being writen." << std::endl; f->WriteObject(&vect, "ccdb_object");