Skip to content

Commit

Permalink
QC-1162 do not use flag types which will be soon deleted (#2268)
Browse files Browse the repository at this point in the history
* QC-1162 do not use flag types which will be soon deleted

* fix test

* more fixes
  • Loading branch information
knopers8 committed Apr 29, 2024
1 parent fb6da46 commit 93e9fb7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Framework/src/QualitiesToFlagCollectionConverter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void QualitiesToFlagCollectionConverter::operator()(const QualityObject& newQO)
if (newQO.getQuality().isWorseThan(Quality::Good)) {
mWorseThanGoodQOs++;
}
// TODO support a scenario when at the beginning of run the data Quality is null, because it could not be judged,
// but then it evolves to bad or good. Null quality should be probably removed.

uint64_t validFrom = strtoull(newQO.getMetadata(metadata_keys::validFrom).c_str(), nullptr, 10);
uint64_t validUntil = strtoull(newQO.getMetadata(metadata_keys::validUntil).c_str(), nullptr, 10);
Expand Down
4 changes: 2 additions & 2 deletions Framework/test/testCcdbDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ BOOST_AUTO_TEST_CASE(ccdb_qcfc)
std::shared_ptr<QualityControlFlagCollection> qcfc1{ new QualityControlFlagCollection{ qcfcName, "TST", { 45, 500000 }, 42, "LHC42x", "spass", "qc" } };
qcfc1->insert({ 50, 77, FlagTypeFactory::Invalid(), "a comment", "a source" });
qcfc1->insert({ 51, 77, FlagTypeFactory::Invalid() });
qcfc1->insert({ 1234, 3434, FlagTypeFactory::LimitedAcceptance() });
qcfc1->insert({ 50, 77, FlagTypeFactory::LimitedAcceptance() });
qcfc1->insert({ 1234, 3434, FlagTypeFactory::BadPID() });
qcfc1->insert({ 50, 77, FlagTypeFactory::BadPID() });
qcfc1->insert({ 43434, 63421, FlagTypeFactory::NotBadFlagExample() });

f.backend->storeQCFC(qcfc1);
Expand Down
6 changes: 3 additions & 3 deletions Framework/test/testQualitiesToFlagCollectionConverter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(test_KnownFlags)
};
qos[1].addFlag(FlagTypeFactory::BadTracking(), "Bug in reco");
qos[2].addFlag(FlagTypeFactory::BadTracking(), "Bug in reco");
qos[2].addFlag(FlagTypeFactory::LimitedAcceptance(), "Sector C was off");
qos[2].addFlag(FlagTypeFactory::BadHadronPID(), "evil CERN scientists changed the proton mass");
qos[3].addFlag(FlagTypeFactory::BadTracking(), "Bug in reco");

std::unique_ptr<QualityControlFlagCollection> qcfc{ new QualityControlFlagCollection("test1", "DET", { 5, 100 }) };
Expand All @@ -267,8 +267,8 @@ BOOST_AUTO_TEST_CASE(test_KnownFlags)
auto& flag2 = *(++qcfc->begin());
BOOST_CHECK_EQUAL(flag2.getStart(), 30);
BOOST_CHECK_EQUAL(flag2.getEnd(), 50);
BOOST_CHECK_EQUAL(flag2.getFlag(), FlagTypeFactory::LimitedAcceptance());
BOOST_CHECK_EQUAL(flag2.getComment(), "Sector C was off");
BOOST_CHECK_EQUAL(flag2.getFlag(), FlagTypeFactory::BadHadronPID());
BOOST_CHECK_EQUAL(flag2.getComment(), "evil CERN scientists changed the proton mass");
BOOST_CHECK_EQUAL(flag2.getSource(), "qc/DET/QO/xyzCheck");
}

Expand Down
10 changes: 5 additions & 5 deletions Framework/test/testQuality.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,24 @@ TEST_CASE("quality_flags")
Quality myQuality = Quality::Bad;
myQuality.addFlag(FlagTypeFactory::BadTracking(), "exception in x");
myQuality.addFlag(FlagTypeFactory::BadTracking(), "exception in y");
myQuality.addFlag(FlagTypeFactory::LimitedAcceptance(), "sector C off");
myQuality.addFlag(FlagTypeFactory::BadPID(), "Bethe and Bloch had a bad day");

auto myFlags = myQuality.getFlags();
CHECK(myFlags[0].first == FlagTypeFactory::BadTracking());
CHECK(myFlags[0].second == "exception in x");
CHECK(myFlags[1].first == FlagTypeFactory::BadTracking());
CHECK(myFlags[1].second == "exception in y");
CHECK(myFlags[2].first == FlagTypeFactory::LimitedAcceptance());
CHECK(myFlags[2].second == "sector C off");
CHECK(myFlags[2].first == FlagTypeFactory::BadPID());
CHECK(myFlags[2].second == "Bethe and Bloch had a bad day");

auto copyQuality = myQuality;
auto copyFlags = copyQuality.getFlags();
CHECK(copyFlags[0].first == FlagTypeFactory::BadTracking());
CHECK(copyFlags[0].second == "exception in x");
CHECK(copyFlags[1].first == FlagTypeFactory::BadTracking());
CHECK(copyFlags[1].second == "exception in y");
CHECK(copyFlags[2].first == FlagTypeFactory::LimitedAcceptance());
CHECK(copyFlags[2].second == "sector C off");
CHECK(copyFlags[2].first == FlagTypeFactory::BadPID());
CHECK(copyFlags[2].second == "Bethe and Bloch had a bad day");
}

} // namespace o2::quality_control::core
14 changes: 7 additions & 7 deletions Framework/test/testQualityObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,31 @@ TEST_CASE("qo_flags")
QualityObject qo1(Quality::Bad, "xyzCheck", "DET");
qo1.addFlag(FlagTypeFactory::BadTracking(), "exception in x");
qo1.addFlag(FlagTypeFactory::BadTracking(), "exception in y");
qo1.addFlag(FlagTypeFactory::LimitedAcceptance(), "sector C off");
qo1.addFlag(FlagTypeFactory::BadPID(), "wrong time of flight due to the summer time change");

auto flags1 = qo1.getFlags();
CHECK(flags1[0].first == FlagTypeFactory::BadTracking());
CHECK(flags1[0].second == "exception in x");
CHECK(flags1[1].first == FlagTypeFactory::BadTracking());
CHECK(flags1[1].second == "exception in y");
CHECK(flags1[2].first == FlagTypeFactory::LimitedAcceptance());
CHECK(flags1[2].second == "sector C off");
CHECK(flags1[2].first == FlagTypeFactory::BadPID());
CHECK(flags1[2].second == "wrong time of flight due to the summer time change");

auto qo2 = qo1;
auto flags2 = qo2.getFlags();
CHECK(flags2[0].first == FlagTypeFactory::BadTracking());
CHECK(flags2[0].second == "exception in x");
CHECK(flags2[1].first == FlagTypeFactory::BadTracking());
CHECK(flags2[1].second == "exception in y");
CHECK(flags2[2].first == FlagTypeFactory::LimitedAcceptance());
CHECK(flags2[2].second == "sector C off");
CHECK(flags2[2].first == FlagTypeFactory::BadPID());
CHECK(flags2[2].second == "wrong time of flight due to the summer time change");

auto quality = qo1.getQuality();
auto flags3 = quality.getFlags();
CHECK(flags3[0].first == FlagTypeFactory::BadTracking());
CHECK(flags3[0].second == "exception in x");
CHECK(flags3[1].first == FlagTypeFactory::BadTracking());
CHECK(flags3[1].second == "exception in y");
CHECK(flags3[2].first == FlagTypeFactory::LimitedAcceptance());
CHECK(flags3[2].second == "sector C off");
CHECK(flags3[2].first == FlagTypeFactory::BadPID());
CHECK(flags3[2].second == "wrong time of flight due to the summer time change");
}
8 changes: 4 additions & 4 deletions Modules/Common/test/testWorstOfAllAggregator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(test_WorstOfAllAggregator)
qoNull->addFlag(FlagTypeFactory::BadTracking(), "oh no");
std::shared_ptr<QualityObject> qoGood = std::make_shared<QualityObject>(Quality::Good, "testCheckGood", "TST");
std::shared_ptr<QualityObject> qoMedium = std::make_shared<QualityObject>(Quality::Medium, "testCheckMedium", "TST");
qoMedium->addFlag(FlagTypeFactory::LimitedAcceptance(), "booo");
qoMedium->addFlag(FlagTypeFactory::BadPID(), "booo");
std::shared_ptr<QualityObject> qoBad = std::make_shared<QualityObject>(Quality::Bad, "testCheckBad", "TST");
QualityObjectsMapType input;

Expand All @@ -64,21 +64,21 @@ BOOST_AUTO_TEST_CASE(test_WorstOfAllAggregator)
BOOST_REQUIRE_EQUAL(result3.size(), 1);
BOOST_CHECK_EQUAL(result3["agg1"], Quality::Medium);
BOOST_REQUIRE_EQUAL(result3["agg1"].getFlags().size(), 1);
BOOST_CHECK_EQUAL(result3["agg1"].getFlags().at(0).first, FlagTypeFactory::LimitedAcceptance());
BOOST_CHECK_EQUAL(result3["agg1"].getFlags().at(0).first, FlagTypeFactory::BadPID());

input[qoBad->getName()] = qoBad;
std::map<std::string, Quality> result4 = agg1.aggregate(input);
BOOST_REQUIRE_EQUAL(result4.size(), 1);
BOOST_CHECK_EQUAL(result4["agg1"], Quality::Bad);
BOOST_REQUIRE_EQUAL(result4["agg1"].getFlags().size(), 1);
BOOST_CHECK_EQUAL(result4["agg1"].getFlags().at(0).first, FlagTypeFactory::LimitedAcceptance());
BOOST_CHECK_EQUAL(result4["agg1"].getFlags().at(0).first, FlagTypeFactory::BadPID());

input[qoNull->getName()] = qoNull;
std::map<std::string, Quality> result5 = agg1.aggregate(input);
BOOST_REQUIRE_EQUAL(result5.size(), 1);
BOOST_CHECK_EQUAL(result5["agg1"], Quality::Null);
BOOST_REQUIRE_EQUAL(result5["agg1"].getFlags().size(), 2);
BOOST_CHECK_EQUAL(result5["agg1"].getFlags().at(0).first, FlagTypeFactory::LimitedAcceptance());
BOOST_CHECK_EQUAL(result5["agg1"].getFlags().at(0).first, FlagTypeFactory::BadPID());
BOOST_CHECK_EQUAL(result5["agg1"].getFlags().at(1).first, FlagTypeFactory::BadTracking());
}

Expand Down

0 comments on commit 93e9fb7

Please sign in to comment.