Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions Framework/src/BookkeepingQualitySink.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "QualityControl/QcInfoLogger.h"
#include <BookkeepingApi/QcFlagServiceClient.h>
#include <BookkeepingApi/BkpClientFactory.h>
#include <CCDB/BasicCCDBManager.h>
#include <stdexcept>
#include <utility>

Expand All @@ -51,13 +52,18 @@ void BookkeepingQualitySink::send(const std::string& grpcUri, const BookkeepingQ
std::optional<std::string> 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<QcFlag> 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<uint64_t>(runDuration.first), static_cast<uint64_t>(runDuration.second) });
}

auto flagCollection = converter->getResult();
if (flagCollection == nullptr) {
continue;
Expand Down Expand Up @@ -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:
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Framework/src/FlagHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ std::optional<QualityControlFlag> 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() };
Expand Down
5 changes: 5 additions & 0 deletions Framework/src/QualitiesToFlagCollectionConverter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions Framework/test/testFlagHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Loading