From d195ab58038f69b91603466a35a0e5aa9fb8ba26 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Mon, 11 Oct 2021 16:30:07 +0200 Subject: [PATCH 1/4] [QC-667] Add the detector name to the CheckRunner --- Framework/include/QualityControl/Check.h | 1 + Framework/include/QualityControl/CheckRunner.h | 5 +++++ Framework/src/CheckRunner.cxx | 18 ++++++++++++++++++ Framework/test/testCheckRunner.cxx | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/Framework/include/QualityControl/Check.h b/Framework/include/QualityControl/Check.h index e3ea9e217f..430328a4cb 100644 --- a/Framework/include/QualityControl/Check.h +++ b/Framework/include/QualityControl/Check.h @@ -64,6 +64,7 @@ class Check const std::string& getName() const { return mCheckConfig.name; }; o2::framework::OutputSpec getOutputSpec() const { return mCheckConfig.qoSpec; }; o2::framework::Inputs getInputs() const { return mCheckConfig.inputSpecs; }; + const std::string& getDetector() const { return mCheckConfig.detectorName; }; //TODO: Unique Input string static o2::header::DataDescription createCheckDataDescription(const std::string& checkName); diff --git a/Framework/include/QualityControl/CheckRunner.h b/Framework/include/QualityControl/CheckRunner.h index 53479160ce..b89dfb691d 100644 --- a/Framework/include/QualityControl/CheckRunner.h +++ b/Framework/include/QualityControl/CheckRunner.h @@ -121,6 +121,11 @@ class CheckRunner : public framework::Task static std::string createSinkCheckRunnerName(o2::framework::InputSpec input); static std::string createCheckRunnerFacility(std::string deviceName); + /// \brief Compute the detector name to be used in the infologger for this checkrunner. + /// Compute the detector name to be used in the infologger for this checkrunner. + /// If all checks belong to the same detector we use it, otherwise we use "MANY" + static std::string getDetectorName(std::vector checks); + private: /** * \brief Evaluate the quality of a MonitorObject. diff --git a/Framework/src/CheckRunner.cxx b/Framework/src/CheckRunner.cxx index cbf2ad96db..f6bceccf47 100644 --- a/Framework/src/CheckRunner.cxx +++ b/Framework/src/CheckRunner.cxx @@ -175,6 +175,7 @@ void CheckRunner::init(framework::InitContext& iCtx) mConfig.infologgerFilterDiscardDebug, mConfig.infologgerDiscardLevel, ilContext); + ILOG_INST.setDetector(CheckRunner::getDetectorName(mChecks)); initDatabase(); initMonitoring(); initServiceDiscovery(); @@ -454,4 +455,21 @@ void CheckRunner::reset() mTotalQOSent = 0; } +std::string CheckRunner::getDetectorName(std::vector checks) +{ + // determine the detector to be used in the infologger. + // if all checks belong to the same detector then we use it otherwise we use MANY + std::string detectorName; + for (auto& check : checks) { + const std::string& thisDetector = check.getDetector(); + if(detectorName != thisDetector && detectorName.length() != 0) { + detectorName = "MANY"; + break; + } else if (detectorName.length() == 0) { + detectorName = thisDetector; + } + } + return detectorName; +} + } // namespace o2::quality_control::checker diff --git a/Framework/test/testCheckRunner.cxx b/Framework/test/testCheckRunner.cxx index 2892a47eec..48050454a8 100644 --- a/Framework/test/testCheckRunner.cxx +++ b/Framework/test/testCheckRunner.cxx @@ -35,3 +35,21 @@ BOOST_AUTO_TEST_CASE(test_check_runner_static) BOOST_CHECK(CheckRunner::createCheckRunnerFacility(CheckRunner::createCheckRunnerIdString() + "-abcdefghijklmnopqrstuvwxyz") == "check/abcdefghijklmnopqrstuvwxyz"); BOOST_CHECK(CheckRunner::createCheckRunnerFacility(CheckRunner::createCheckRunnerIdString() + "-abcdefghijklmnopqrstuvwxyz123456789") == "check/abcdefghijklmnopqrstuvwxyz"); } + +BOOST_AUTO_TEST_CASE(test_getDetector) +{ + CheckConfig config; + config.detectorName = "TST"; + + vector checks; + BOOST_CHECK_EQUAL(CheckRunner::getDetectorName(checks), ""); + Check checkTST(config); + checks.push_back(checkTST); + BOOST_CHECK_EQUAL(CheckRunner::getDetectorName(checks), "TST"); + checks.push_back(checkTST); + BOOST_CHECK_EQUAL(CheckRunner::getDetectorName(checks), "TST"); + config.detectorName = "EMC"; + Check checkEMC(config); + checks.push_back(checkEMC); + BOOST_CHECK_EQUAL(CheckRunner::getDetectorName(checks), "MANY"); +} \ No newline at end of file From 82e203d85d720dc46e48322c8508ffb27196a182 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Mon, 11 Oct 2021 16:39:26 +0200 Subject: [PATCH 2/4] set detector name for the aggregatorRunner --- Framework/include/QualityControl/Aggregator.h | 1 + .../include/QualityControl/AggregatorRunner.h | 5 +++++ Framework/src/AggregatorRunner.cxx | 16 ++++++++++++++++ Framework/src/CheckRunner.cxx | 8 +++----- Framework/test/testAggregatorRunner.cxx | 18 ++++++++++++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Framework/include/QualityControl/Aggregator.h b/Framework/include/QualityControl/Aggregator.h index 22f48ca613..bc5fdbc141 100644 --- a/Framework/include/QualityControl/Aggregator.h +++ b/Framework/include/QualityControl/Aggregator.h @@ -72,6 +72,7 @@ class Aggregator bool getAllObjectsOption() const; std::vector getSources(); std::vector getSources(core::DataSourceType type); + const std::string& getDetector() const { return mAggregatorConfig.detectorName; }; static AggregatorConfig extractConfig(const core::CommonSpec&, const AggregatorSpec&); diff --git a/Framework/include/QualityControl/AggregatorRunner.h b/Framework/include/QualityControl/AggregatorRunner.h index d37551f456..a70852d03d 100644 --- a/Framework/include/QualityControl/AggregatorRunner.h +++ b/Framework/include/QualityControl/AggregatorRunner.h @@ -112,6 +112,11 @@ class AggregatorRunner : public framework::Task static std::string createAggregatorRunnerName(); static header::DataDescription createAggregatorRunnerDataDescription(const std::string& aggregatorName); + /// \brief Compute the detector name to be used in the infologger for this runner. + /// Compute the detector name to be used in the infologger for this runner. + /// If all checks belong to the same detector we use it, otherwise we use "MANY" + static std::string getDetectorName(std::vector aggregators); + private: /** * \brief For each aggregator, check if the data is ready and, if so, call its own aggregation method. diff --git a/Framework/src/AggregatorRunner.cxx b/Framework/src/AggregatorRunner.cxx index d77dd956ad..e6fa470983 100644 --- a/Framework/src/AggregatorRunner.cxx +++ b/Framework/src/AggregatorRunner.cxx @@ -96,6 +96,7 @@ void AggregatorRunner::init(framework::InitContext& iCtx) try { ILOG_INST.init("aggregator", mRunnerConfig.infologgerFilterDiscardDebug, mRunnerConfig.infologgerDiscardLevel, ilContext); + ILOG_INST.setDetector(AggregatorRunner::getDetectorName()); initDatabase(); initMonitoring(); initServiceDiscovery(); @@ -343,4 +344,19 @@ void AggregatorRunner::reset() } } +std::string AggregatorRunner::getDetectorName(std::vector aggregators) +{ + std::string detectorName; + for (auto& aggregator : aggregators) { + const std::string& thisDetector = aggregator.getDetector(); + if(detectorName.length() == 0) { + detectorName = thisDetector; + } else if (thisDetector != detectorName) { + detectorName = "MANY"; + break; + } + } + return detectorName; +} + } // namespace o2::quality_control::checker diff --git a/Framework/src/CheckRunner.cxx b/Framework/src/CheckRunner.cxx index f6bceccf47..5e163d6a11 100644 --- a/Framework/src/CheckRunner.cxx +++ b/Framework/src/CheckRunner.cxx @@ -457,16 +457,14 @@ void CheckRunner::reset() std::string CheckRunner::getDetectorName(std::vector checks) { - // determine the detector to be used in the infologger. - // if all checks belong to the same detector then we use it otherwise we use MANY std::string detectorName; for (auto& check : checks) { const std::string& thisDetector = check.getDetector(); - if(detectorName != thisDetector && detectorName.length() != 0) { + if(detectorName.length() == 0) { + detectorName = thisDetector; + } else if (thisDetector != detectorName) { detectorName = "MANY"; break; - } else if (detectorName.length() == 0) { - detectorName = thisDetector; } } return detectorName; diff --git a/Framework/test/testAggregatorRunner.cxx b/Framework/test/testAggregatorRunner.cxx index b8c2b5fd5a..aebaf53497 100644 --- a/Framework/test/testAggregatorRunner.cxx +++ b/Framework/test/testAggregatorRunner.cxx @@ -133,4 +133,22 @@ BOOST_AUTO_TEST_CASE(test_aggregator_quality_filter) qoMap["dataSizeCheck2/someNumbersTask/example2"] = make_shared(Quality::Bad, "dataSizeCheck2/someNumbersTask/example2"); result = aggregator->aggregate(qoMap); BOOST_CHECK_EQUAL(getQualityForCheck(result, "MyAggregatorB/newQuality"), Quality::Medium); +} + +BOOST_AUTO_TEST_CASE(test_getDetector) +{ + AggregatorConfig config; + config.detectorName = "TST"; + + vector aggregators; + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), ""); + Aggregator checkTST(config); + aggregators.push_back(checkTST); + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "TST"); + aggregators.push_back(checkTST); + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "TST"); + config.detectorName = "EMC"; + Aggregator checkEMC(config); + aggregators.push_back(checkEMC); + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "MANY"); } \ No newline at end of file From b4617800ca63e51688957148553dc53859952730 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Mon, 11 Oct 2021 16:42:23 +0200 Subject: [PATCH 3/4] format --- Framework/src/AggregatorRunner.cxx | 2 +- Framework/src/CheckRunner.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/src/AggregatorRunner.cxx b/Framework/src/AggregatorRunner.cxx index e6fa470983..6227d23f2c 100644 --- a/Framework/src/AggregatorRunner.cxx +++ b/Framework/src/AggregatorRunner.cxx @@ -349,7 +349,7 @@ std::string AggregatorRunner::getDetectorName(std::vector aggregator std::string detectorName; for (auto& aggregator : aggregators) { const std::string& thisDetector = aggregator.getDetector(); - if(detectorName.length() == 0) { + if (detectorName.length() == 0) { detectorName = thisDetector; } else if (thisDetector != detectorName) { detectorName = "MANY"; diff --git a/Framework/src/CheckRunner.cxx b/Framework/src/CheckRunner.cxx index 5e163d6a11..c9368364e8 100644 --- a/Framework/src/CheckRunner.cxx +++ b/Framework/src/CheckRunner.cxx @@ -460,7 +460,7 @@ std::string CheckRunner::getDetectorName(std::vector checks) std::string detectorName; for (auto& check : checks) { const std::string& thisDetector = check.getDetector(); - if(detectorName.length() == 0) { + if (detectorName.length() == 0) { detectorName = thisDetector; } else if (thisDetector != detectorName) { detectorName = "MANY"; From 70aff7a27ad8d6262d35a47681f38fb505d1ce0c Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Tue, 12 Oct 2021 12:06:21 +0200 Subject: [PATCH 4/4] Fix compilation --- Framework/include/QualityControl/AggregatorRunner.h | 2 +- Framework/src/AggregatorRunner.cxx | 6 +++--- Framework/test/testAggregatorRunner.cxx | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Framework/include/QualityControl/AggregatorRunner.h b/Framework/include/QualityControl/AggregatorRunner.h index a70852d03d..8ace140c90 100644 --- a/Framework/include/QualityControl/AggregatorRunner.h +++ b/Framework/include/QualityControl/AggregatorRunner.h @@ -115,7 +115,7 @@ class AggregatorRunner : public framework::Task /// \brief Compute the detector name to be used in the infologger for this runner. /// Compute the detector name to be used in the infologger for this runner. /// If all checks belong to the same detector we use it, otherwise we use "MANY" - static std::string getDetectorName(std::vector aggregators); + static std::string getDetectorName(std::vector> aggregators); private: /** diff --git a/Framework/src/AggregatorRunner.cxx b/Framework/src/AggregatorRunner.cxx index 6227d23f2c..e9ebde57d9 100644 --- a/Framework/src/AggregatorRunner.cxx +++ b/Framework/src/AggregatorRunner.cxx @@ -96,7 +96,7 @@ void AggregatorRunner::init(framework::InitContext& iCtx) try { ILOG_INST.init("aggregator", mRunnerConfig.infologgerFilterDiscardDebug, mRunnerConfig.infologgerDiscardLevel, ilContext); - ILOG_INST.setDetector(AggregatorRunner::getDetectorName()); + ILOG_INST.setDetector(AggregatorRunner::getDetectorName(mAggregators)); initDatabase(); initMonitoring(); initServiceDiscovery(); @@ -344,11 +344,11 @@ void AggregatorRunner::reset() } } -std::string AggregatorRunner::getDetectorName(std::vector aggregators) +std::string AggregatorRunner::getDetectorName(std::vector> aggregators) { std::string detectorName; for (auto& aggregator : aggregators) { - const std::string& thisDetector = aggregator.getDetector(); + const std::string& thisDetector = aggregator->getDetector(); if (detectorName.length() == 0) { detectorName = thisDetector; } else if (thisDetector != detectorName) { diff --git a/Framework/test/testAggregatorRunner.cxx b/Framework/test/testAggregatorRunner.cxx index aebaf53497..d2a4ede706 100644 --- a/Framework/test/testAggregatorRunner.cxx +++ b/Framework/test/testAggregatorRunner.cxx @@ -140,15 +140,16 @@ BOOST_AUTO_TEST_CASE(test_getDetector) AggregatorConfig config; config.detectorName = "TST"; - vector aggregators; + std::vector> aggregators; BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), ""); - Aggregator checkTST(config); + auto checkTST = std::make_shared(config); aggregators.push_back(checkTST); BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "TST"); - aggregators.push_back(checkTST); + auto checkTST2 = std::make_shared(config); + aggregators.push_back(checkTST2); BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "TST"); config.detectorName = "EMC"; - Aggregator checkEMC(config); + auto checkEMC = std::make_shared(config); aggregators.push_back(checkEMC); BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "MANY"); } \ No newline at end of file