From a138fafe36290c8579679e8857fd60ac87fc2472 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Mon, 17 Jul 2023 14:40:17 +0200 Subject: [PATCH] ctpdev: dump raw on error (#11657) * dev: raw data dump if error * clang * dev: dumping raw data * clang * dev: debugs removed, error output decreased. * clang * dev: option for max errors added * clang * fix: small * fix: in return vals --- .../CTPReconstruction/RawDataDecoder.h | 5 ++ .../CTP/reconstruction/src/RawDataDecoder.cxx | 65 ++++++++++++------- Detectors/CTP/workflow/src/RawDecoderSpec.cxx | 5 +- .../CTP/workflow/src/ctp-raw-decoder.cxx | 1 + 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h index b5134338aed79..ecea1479a9691 100644 --- a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h +++ b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h @@ -41,6 +41,7 @@ class RawDataDecoder void setDoLumi(bool lumi) { mDoLumi = lumi; } void setDoDigits(bool digi) { mDoDigits = digi; } void setVerbose(bool v) { mVerbose = v; } + void setMAXErrors(int m) { mErrorMax = m; } uint32_t getIRRejected() const { return mIRRejected; } uint32_t getTCRRejected() const { return mTCRRejected; } std::vector& getTFOrbits() { return mTFOrbits; } @@ -64,6 +65,10 @@ class RawDataDecoder bool mPadding = true; uint32_t mTFOrbit = 0; std::vector mTFOrbits; + // error verbosness + int mErrorIR = 0; + int mErrorTCR = 0; + int mErrorMax = 3; }; } // namespace ctp } // namespace o2 diff --git a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx index 1830cd3b275fc..89d7916a38d98 100644 --- a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx +++ b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx @@ -11,7 +11,7 @@ /// \file RawDataDecoder.cxx /// \author Roman Lietava - +#include #include "DetectorsRaw/RDHUtils.h" #include "CTPReconstruction/RawDataDecoder.h" @@ -39,6 +39,7 @@ void RawDataDecoder::makeGBTWordInverse(std::vector& diglets, gbtwo } int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& diglet, gbtword80_t& pldmask, std::map& digits) { + int ret = 0; gbtword80_t pld = (diglet & pldmask); if (pld.count() == 0) { return 0; @@ -70,10 +71,15 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d digits[ir].setInputMask(pld); LOG(debug) << bcid << " inputs bcid vase 1 orbit " << orbit << " pld:" << pld; } else { - LOG(error) << "Two CTP IRs with the same timestamp:" << ir.bc << " " << ir.orbit << " pld:" << pld << " dig:" << digits[ir]; + if (mErrorIR < mErrorMax) { + LOG(error) << "Two CTP IRs with the same timestamp:" << ir.bc << " " << ir.orbit << " pld:" << pld << " dig:" << digits[ir]; + } + ret = 2; + mErrorIR++; } } else { LOG(error) << "Two digits with the same rimestamp:" << ir.bc << " " << ir.orbit; + ret = 2; } } else if (linkCRU == o2::ctp::GBTLinkIDClassRec) { int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1 - 1; @@ -95,18 +101,26 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d digits[ir].setClassMask(pld); LOG(debug) << bcid << " class bcid case 1 orbit " << orbit << " pld:" << pld; } else { - LOG(error) << "Two CTP Class masks for same timestamp"; + if (mErrorTCR < mErrorMax) { + LOG(error) << "Two CTP Class masks for same timestamp"; + } + mErrorTCR++; + ret = 3; } } else { + LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit; + ret = 3; } } else { LOG(error) << "Unxpected CTP CRU link:" << linkCRU; } - return 0; + return ret; } // int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector& filter, std::vector& digits, std::vector& lumiPointsHBF1) { + int ret = 0; + static int nwrites = 0; uint64_t countsMBT = 0; uint64_t countsMBV = 0; std::map digitsMap; @@ -193,6 +207,7 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector 0)) { gbtwords80.push_back(gbtWord80); - /*uint64_t bcid = (gbtWord80 & bcmask).to_ullong(); - if (bcid < 279) - bcid += 3564 - 279; - else - bcid += -279; - std::string ss = fmt::format("{:x}", bcid); - LOG(info) << "w80l:" << gbtWord80 << " " << ss; */ } // decode 80 bits payload for (auto word : gbtwords80) { @@ -254,7 +254,7 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector 0) && stopBit) { @@ -272,7 +272,7 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector("ntf-to-average"); mVerbose = ctx.options().get("use-verbose-mode"); + int maxerrors = ctx.options().get("print-errors-num"); mDecoder.setVerbose(mVerbose); mDecoder.setDoLumi(mDoLumi); mDecoder.setDoDigits(mDoDigits); - LOG(info) << "CTP reco init done. DoLumi:" << mDoLumi << " DoDigits:" << mDoDigits << " NTF:" << mNTFToIntegrate; + mDecoder.setMAXErrors(maxerrors); + LOG(info) << "CTP reco init done. DoLumi:" << mDoLumi << " DoDigits:" << mDoDigits << " NTF:" << mNTFToIntegrate << " Max errors:" << maxerrors; } void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec) { @@ -170,5 +172,6 @@ o2::framework::DataProcessorSpec o2::ctp::reco_workflow::getRawDecoderSpec(bool o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(digits, lumi)}, o2::framework::Options{ {"ntf-to-average", o2::framework::VariantType::Int, 90, {"Time interval for averaging luminosity in units of TF"}}, + {"print-errors-num", o2::framework::VariantType::Int, 3, {"Max number of errors to print"}}, {"use-verbose-mode", o2::framework::VariantType::Bool, false, {"Verbose logging"}}}}; } diff --git a/Detectors/CTP/workflow/src/ctp-raw-decoder.cxx b/Detectors/CTP/workflow/src/ctp-raw-decoder.cxx index 31b9647972c79..2d12cc9df47ac 100644 --- a/Detectors/CTP/workflow/src/ctp-raw-decoder.cxx +++ b/Detectors/CTP/workflow/src/ctp-raw-decoder.cxx @@ -30,6 +30,7 @@ void customize(std::vector& workflowOptions) {"no-lumi", o2::framework::VariantType::Bool, false, {"do not produce luminosity output"}}, {"no-digits", o2::framework::VariantType::Bool, false, {"do not produce digits output"}}, {"disable-root-output", o2::framework::VariantType::Bool, false, {"disable root-files output writer"}}, + {"print-errors-number", o2::framework::VariantType::Int, 3, {"number of error to print by CTP raw decoder"}}, {"configKeyValues", o2::framework::VariantType::String, "", {"Semicolon separated key=value strings ..."}}}; std::swap(workflowOptions, options); }