diff --git a/Framework/include/QualityControl/QualitiesToFlagCollectionConverter.h b/Framework/include/QualityControl/QualitiesToFlagCollectionConverter.h index c39fe79f90..f50571cfcc 100644 --- a/Framework/include/QualityControl/QualitiesToFlagCollectionConverter.h +++ b/Framework/include/QualityControl/QualitiesToFlagCollectionConverter.h @@ -46,6 +46,7 @@ class QualitiesToFlagCollectionConverter size_t getQOsIncluded() const; size_t getWorseThanGoodQOs() const; + int getRunNumber() const; /// Sets the provided validity interval, trims affected flags and fills extensions with UnknownQuality void updateValidityInterval(const ValidityInterval validityInterval); diff --git a/Framework/src/BookkeepingQualitySink.cxx b/Framework/src/BookkeepingQualitySink.cxx index 003ca9e35c..4900cd0b94 100644 --- a/Framework/src/BookkeepingQualitySink.cxx +++ b/Framework/src/BookkeepingQualitySink.cxx @@ -26,6 +26,7 @@ #include "QualityControl/QcInfoLogger.h" #include #include +#include #include #include @@ -51,13 +52,18 @@ void BookkeepingQualitySink::send(const std::string& grpcUri, const BookkeepingQ std::optional periodName; for (auto& [detector, qoMap] : flags) { - ILOG(Info, Support) << "Sending " << flags.size() << " flags for detector: " << detector << ENDM; + ILOG(Info, Support) << "Processing flags for detector: " << detector << ENDM; std::vector bkpQcFlags{}; for (auto& [qoName, converter] : qoMap) { if (converter == nullptr) { continue; } + if (provenance == Provenance::AsyncQC || provenance == Provenance::MCQC) { + auto runDuration = ccdb::BasicCCDBManager::instance().getRunDuration(converter->getRunNumber(), false); + converter->updateValidityInterval({ static_cast(runDuration.first), static_cast(runDuration.second) }); + } + auto flagCollection = converter->getResult(); if (flagCollection == nullptr) { continue; @@ -86,9 +92,9 @@ void BookkeepingQualitySink::send(const std::string& grpcUri, const BookkeepingQ } if (bkpQcFlags.empty()) { + ILOG(Info, Support) << "No flags for detector '" << detector << "', skipping" << ENDM; continue; } - try { switch (provenance) { case Provenance::SyncQC: @@ -105,6 +111,7 @@ void BookkeepingQualitySink::send(const std::string& grpcUri, const BookkeepingQ ILOG(Error, Support) << "Failed to send flags for detector: " << detector << " with error: " << err.what() << ENDM; } + ILOG(Info, Support) << "Sent " << bkpQcFlags.size() << " flags for detector: " << detector << ENDM; } } diff --git a/Framework/src/FlagHelpers.cxx b/Framework/src/FlagHelpers.cxx index 4168a15096..e5d40844f9 100644 --- a/Framework/src/FlagHelpers.cxx +++ b/Framework/src/FlagHelpers.cxx @@ -64,7 +64,7 @@ std::optional intersection(const QualityControlFlag& flag, V return flag; } auto intersection = flag.getInterval().getOverlap(interval); - if (intersection.isInvalid()) { + if (intersection.isInvalid() || intersection.isZeroLength()) { return std::nullopt; } return QualityControlFlag{ intersection.getMin(), intersection.getMax(), flag.getFlag(), flag.getComment(), flag.getSource() }; diff --git a/Framework/src/QualitiesToFlagCollectionConverter.cxx b/Framework/src/QualitiesToFlagCollectionConverter.cxx index ed3d4ed9f8..bfabc2862e 100644 --- a/Framework/src/QualitiesToFlagCollectionConverter.cxx +++ b/Framework/src/QualitiesToFlagCollectionConverter.cxx @@ -289,4 +289,9 @@ void QualitiesToFlagCollectionConverter::updateValidityInterval(const ValidityIn mConverted->setInterval(interval); } +int QualitiesToFlagCollectionConverter::getRunNumber() const +{ + return mConverted ? mConverted->getRunNumber() : -1; +} + } // namespace o2::quality_control::core diff --git a/Framework/test/testFlagHelpers.cxx b/Framework/test/testFlagHelpers.cxx index 3bb5b4cbff..4c5991d3b7 100644 --- a/Framework/test/testFlagHelpers.cxx +++ b/Framework/test/testFlagHelpers.cxx @@ -295,4 +295,10 @@ TEST_CASE("intersection") REQUIRE(result->getComment() == qcFlag.getComment()); REQUIRE(result->getSource() == qcFlag.getSource()); } + SECTION("Returns nullopt if the flag and the interval are adjacent") + { + QualityControlFlag qcFlag{ 15, 25, FlagTypeFactory::BadTracking(), "comment", "source" }; + REQUIRE_FALSE(intersection(qcFlag, { 10, 15 }).has_value()); + REQUIRE_FALSE(intersection(qcFlag, { 25, 30 }).has_value()); + } }