From d5d4e7149dde34be129e297368536785a7b97106 Mon Sep 17 00:00:00 2001 From: Lucia Anna Tarasovicova Date: Thu, 15 May 2025 08:36:27 +0200 Subject: [PATCH 1/3] fix for replay, confing read-out from ctx --- Modules/CTP/include/CTP/RawDataQcTask.h | 4 + Modules/CTP/src/RawDataQcTask.cxx | 115 ++++++++++++++++-------- Modules/CTP/src/qc-ctp.json | 10 ++- 3 files changed, 90 insertions(+), 39 deletions(-) diff --git a/Modules/CTP/include/CTP/RawDataQcTask.h b/Modules/CTP/include/CTP/RawDataQcTask.h index 3f8445ebdc..27696518d6 100644 --- a/Modules/CTP/include/CTP/RawDataQcTask.h +++ b/Modules/CTP/include/CTP/RawDataQcTask.h @@ -70,6 +70,10 @@ class CTPRawDataReaderTask final : public TaskInterface std::string classNames[nclasses]; int mIndexMBclass = -1; // index for the MB ctp class, which is used as scaling for the ratios bool mConsistCheck = 0; + bool mReadCTPconfigInMonitorData = 0; + const o2::ctp::CTPConfiguration* mCTPconfig = nullptr; + std::string mMBclassName; + std::array mClassErrorsA; }; } // namespace o2::quality_control_modules::ctp diff --git a/Modules/CTP/src/RawDataQcTask.cxx b/Modules/CTP/src/RawDataQcTask.cxx index 1a3421e935..311704a7bf 100644 --- a/Modules/CTP/src/RawDataQcTask.cxx +++ b/Modules/CTP/src/RawDataQcTask.cxx @@ -51,7 +51,7 @@ void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/) mHistoBCMinBias2 = std::make_unique("bcMinBias2", "BC position MB2", norbits, 0, norbits); mHistoInputRatios = std::make_unique("inputRatio", "Input Ratio to MTVX; Input; Ratio;", ninps, 0, ninps, true); mHistoClassRatios = std::make_unique("classRatio", "Class Ratio to MB; Class; Ratio", nclasses, 0, nclasses, true); - mHistoDecodeError = std::make_unique("decodeError", "Errors from decoder", 10, 1, 11); + mHistoDecodeError = std::make_unique("decodeError", "Errors from decoder", nclasses, 0, nclasses); getObjectsManager()->startPublishing(mHistoInputs.get()); getObjectsManager()->startPublishing(mHistoClasses.get()); getObjectsManager()->startPublishing(mHistoClassRatios.get()); @@ -84,7 +84,12 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity) mRunNumber = activity.mId; mTimestamp = activity.mValidity.getMin(); - auto MBclassName = getFromExtendedConfig(activity, mCustomParameters, "MBclassName", "CMTVX-B-NOPF"); + std::string readCTPConfig = getFromExtendedConfig(activity, mCustomParameters, "readCTPconfigInMonitorData", "false"); + if (readCTPConfig == "true") { + mReadCTPconfigInMonitorData = true; + } + + mMBclassName = getFromExtendedConfig(activity, mCustomParameters, "MBclassName", "CMTVX-B-NOPF"); std::string run = std::to_string(mRunNumber); std::string ccdbName = mCustomParameters["ccdbName"]; @@ -93,40 +98,42 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity) } /// the ccdb reading to be futher discussed // o2::ctp::CTPRunManager::setCCDBHost(ccdbName); - bool ok; - // o2::ctp::CTPConfiguration CTPconfig = o2::ctp::CTPRunManager::getConfigFromCCDB(mTimestamp, run, ok); - auto& mgr = o2::ccdb::BasicCCDBManager::instance(); - mgr.setURL(ccdbName); - map metadata; // can be empty - metadata["runNumber"] = run; - auto ctpconfigdb = mgr.getSpecific(o2::ctp::CCDBPathCTPConfig, mTimestamp, metadata); - if (ctpconfigdb == nullptr) { - LOG(info) << "CTP config not in database, timestamp:" << mTimestamp; - ok = 0; - } else { - // ctpconfigdb->printStream(std::cout); - LOG(info) << "CTP config found. Run:" << run; - ok = 1; - } - if (ok) { - // get the index of the MB reference class - ILOG(Info, Support) << "CTP config found, run:" << run << ENDM; - std::vector ctpcls = ctpconfigdb->getCTPClasses(); - for (size_t i = 0; i < ctpcls.size(); i++) { - classNames[i] = ctpcls[i].name.c_str(); - if (ctpcls[i].name.find(MBclassName) != std::string::npos) { - mIndexMBclass = ctpcls[i].getIndex() + 1; - break; + if (!mReadCTPconfigInMonitorData) { + bool ok; + auto& mgr = o2::ccdb::BasicCCDBManager::instance(); + mgr.setURL(ccdbName); + map metadata; // can be empty + metadata["runNumber"] = run; + auto ctpconfigdb = mgr.getSpecific(o2::ctp::CCDBPathCTPConfig, mTimestamp, metadata); + if (ctpconfigdb == nullptr) { + LOG(info) << "CTP config not in database, timestamp:" << mTimestamp; + ok = 0; + } else { + LOG(info) << "CTP config found. Run:" << run; + ok = 1; + } + if (ok) { + // get the index of the MB reference class + ILOG(Info, Support) << "CTP config found, run:" << run << ENDM; + std::vector ctpcls = ctpconfigdb->getCTPClasses(); + for (size_t i = 0; i < ctpcls.size(); i++) { + classNames[i] = ctpcls[i].name.c_str(); + if (ctpcls[i].name.find(mMBclassName) != std::string::npos) { + mIndexMBclass = ctpcls[i].getIndex() + 1; + break; + } } + mDecoder.setCTPConfig(*ctpconfigdb); + } else { + ILOG(Warning, Support) << "CTP config not found, run:" << run << ENDM; } - mDecoder.setCTPConfig(*ctpconfigdb); - } else { - ILOG(Warning, Support) << "CTP config not found, run:" << run << ENDM; - } - if (mIndexMBclass == -1) { - MBclassName = "CMBV0 (default)"; - mIndexMBclass = 1; + if (mIndexMBclass == -1) { + mMBclassName = "CMBV0 (default)"; + mIndexMBclass = 1; + } + mHistoClassRatios->SetTitle(Form("Class Ratio to %s", mMBclassName.c_str())); } + std::string nameInput1 = getFromExtendedConfig(activity, mCustomParameters, "MB1inputName", "MTVX"); std::string nameInput2 = getFromExtendedConfig(activity, mCustomParameters, "MB2inputName", "MT0A"); @@ -201,7 +208,6 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity) titleX2 += Form(" - %d", mShiftInput2); } mHistoBCMinBias2->SetTitle(Form("%s; %s; %s", title2.Data(), titleX2.Data(), titley2.Data())); - mHistoClassRatios->SetTitle(Form("Class Ratio to %s", MBclassName.c_str())); mHistoInputRatios->SetTitle(Form("Input Ratio to %s", nameInput1.c_str())); std::string performConsistencyCheck = getFromExtendedConfig(activity, mCustomParameters, "consistencyCheck", "true"); @@ -226,10 +232,47 @@ void CTPRawDataReaderTask::monitorData(o2::framework::ProcessingContext& ctx) std::vector lumiPointsHBF1; std::vector outputDigits; + if (mReadCTPconfigInMonitorData) { + if (mCTPconfig == nullptr) { + mCTPconfig = ctx.inputs().get("ctp-config").get(); + // mCTPconfig = ctpConfigPtr.get(); + if (mCTPconfig != nullptr) { + ILOG(Info, Support) << "CTP config found" << ENDM; + std::vector ctpcls = mCTPconfig->getCTPClasses(); + for (size_t i = 0; i < ctpcls.size(); i++) { + classNames[i] = ctpcls[i].name.c_str(); + if (ctpcls[i].name.find(mMBclassName) != std::string::npos) { + mIndexMBclass = ctpcls[i].getIndex() + 1; + break; + } + } + mDecoder.setCTPConfig(*mCTPconfig); + } + } + for (int i = 0; i < nclasses; i++) { + if (classNames[i] == "") { + mHistoClasses.get()->GetXaxis()->SetBinLabel(i + 1, Form("%i", i + 1)); + mHistoClassRatios.get()->GetXaxis()->SetBinLabel(i + 1, Form("%i", i + 1)); + } else { + mHistoClasses.get()->GetXaxis()->SetBinLabel(i + 1, Form("%s", classNames[i].c_str())); + mHistoClassRatios.get()->GetXaxis()->SetBinLabel(i + 1, Form("%s", classNames[i].c_str())); + } + } + + if (mIndexMBclass == -1) { + mMBclassName = "CMBV0 (default)"; + mIndexMBclass = 1; + } + mHistoClassRatios->SetTitle(Form("Class Ratio to %s", mMBclassName.c_str())); + } + o2::framework::InputRecord& inputs = ctx.inputs(); int ret = mDecoder.decodeRaw(inputs, filter, outputDigits, lumiPointsHBF1); - if (ret > 0) { - mHistoDecodeError->Fill(log2(ret) + 1.5); + mClassErrorsA = mDecoder.getClassErrorsA(); + for (size_t i = 0; i < o2::ctp::CTP_NCLASSES; i++) { + if (mClassErrorsA[i] > 0) { + mHistoDecodeError->Fill(i, mClassErrorsA[i]); + } } // reading the ctp inputs and ctp classes diff --git a/Modules/CTP/src/qc-ctp.json b/Modules/CTP/src/qc-ctp.json index 61a969abf4..43b82c517f 100644 --- a/Modules/CTP/src/qc-ctp.json +++ b/Modules/CTP/src/qc-ctp.json @@ -38,10 +38,13 @@ "detectorName": "CTP", "cycleDurationSeconds": "60", "resetAfterCycles": "1", - "dataSource": { + "dataSources": [{ "type": "dataSamplingPolicy", "name": "ctp-raw" - }, + },{ + "type": "direct", + "query": "ctp-config:CTP/CONFIG/0?lifetime=condition&ccdb-path=CTP/Config/Config&ccdb-run-dependent=1s" + }], "extendedTaskParameters": { "default": { "default": { @@ -49,7 +52,8 @@ "MBclassName" : "CMTVX-B-NOPF", "MB1inputName" : "MTVX", "MB2inputName" : "MVBA", - "consistencyCheck" : "false" + "consistencyCheck" : "true", + "readCTPconfigInMonitorData": "true" } }, "PHYSICS": { From ffaa43cd01f7304edfdc5c92bb25162c50634c7f Mon Sep 17 00:00:00 2001 From: Lucia Anna Tarasovicova Date: Thu, 15 May 2025 14:54:40 +0200 Subject: [PATCH 2/3] fix clang --- Modules/CTP/src/RawDataQcTask.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/CTP/src/RawDataQcTask.cxx b/Modules/CTP/src/RawDataQcTask.cxx index 311704a7bf..0842e77c7d 100644 --- a/Modules/CTP/src/RawDataQcTask.cxx +++ b/Modules/CTP/src/RawDataQcTask.cxx @@ -102,8 +102,8 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity) bool ok; auto& mgr = o2::ccdb::BasicCCDBManager::instance(); mgr.setURL(ccdbName); - map metadata; // can be empty - metadata["runNumber"] = run; + map metadata; // can be empty + metadata["runNumber"] = run; auto ctpconfigdb = mgr.getSpecific(o2::ctp::CCDBPathCTPConfig, mTimestamp, metadata); if (ctpconfigdb == nullptr) { LOG(info) << "CTP config not in database, timestamp:" << mTimestamp; From 27140df1a78f1f16775b4577a5b06b959b190422 Mon Sep 17 00:00:00 2001 From: Lucia Anna Tarasovicova Date: Fri, 16 May 2025 13:45:19 +0200 Subject: [PATCH 3/3] fix DecodeInps for Consistency Check --- Modules/CTP/src/RawDataQcTask.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CTP/src/RawDataQcTask.cxx b/Modules/CTP/src/RawDataQcTask.cxx index 0842e77c7d..05f01c2601 100644 --- a/Modules/CTP/src/RawDataQcTask.cxx +++ b/Modules/CTP/src/RawDataQcTask.cxx @@ -61,7 +61,6 @@ void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/) getObjectsManager()->startPublishing(mHistoDecodeError.get()); mDecoder.setDoLumi(1); - mDecoder.setDecodeInps(1); mDecoder.setDoDigits(1); for (size_t i = 0; i < nclasses; i++) { classNames[i] = ""; @@ -213,6 +212,7 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity) std::string performConsistencyCheck = getFromExtendedConfig(activity, mCustomParameters, "consistencyCheck", "true"); if (performConsistencyCheck == "true") { mDecoder.setCheckConsistency(1); + mDecoder.setDecodeInps(1); } else { mDecoder.setCheckConsistency(0); }