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..8ace140c90 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/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/AggregatorRunner.cxx b/Framework/src/AggregatorRunner.cxx index d77dd956ad..e9ebde57d9 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(mAggregators)); 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 cbf2ad96db..c9368364e8 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,19 @@ void CheckRunner::reset() mTotalQOSent = 0; } +std::string CheckRunner::getDetectorName(std::vector checks) +{ + std::string detectorName; + for (auto& check : checks) { + const std::string& thisDetector = check.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/test/testAggregatorRunner.cxx b/Framework/test/testAggregatorRunner.cxx index b8c2b5fd5a..d2a4ede706 100644 --- a/Framework/test/testAggregatorRunner.cxx +++ b/Framework/test/testAggregatorRunner.cxx @@ -133,4 +133,23 @@ 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"; + + std::vector> aggregators; + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), ""); + auto checkTST = std::make_shared(config); + aggregators.push_back(checkTST); + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "TST"); + auto checkTST2 = std::make_shared(config); + aggregators.push_back(checkTST2); + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "TST"); + config.detectorName = "EMC"; + auto checkEMC = std::make_shared(config); + aggregators.push_back(checkEMC); + BOOST_CHECK_EQUAL(AggregatorRunner::getDetectorName(aggregators), "MANY"); } \ No newline at end of file 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