diff --git a/Framework/test/testTrendingTask.cxx b/Framework/test/testTrendingTask.cxx index 0c3872483..ba34951e2 100644 --- a/Framework/test/testTrendingTask.cxx +++ b/Framework/test/testTrendingTask.cxx @@ -245,60 +245,60 @@ TEST_CASE("test_trending_task") } }); - // // Running the task - // ServiceRegistry services; - // services.registerService(repository.get()); - // auto objectManager = std::make_shared(taskName, "o2::quality_control::postprocessing::TrendingTask", "TST"); - // - // TrendingTask task; - // task.setName(trendingTaskName); - // task.setID(trendingTaskID); - // task.setObjectsManager(objectManager); - // REQUIRE_NOTHROW(task.configure(config)); - // - // // test initialize() - // REQUIRE_NOTHROW(task.initialize({ TriggerType::UserOrControl, true, { 0, "NONE", "", "", "qc" }, 1 }, services)); - // REQUIRE(objectManager->getNumberPublishedObjects() == 1); - // auto treeMO = objectManager->getMonitorObject(trendingTaskName); - // REQUIRE(treeMO != nullptr); - // TTree* tree = dynamic_cast(treeMO->getObject()); - // REQUIRE(tree != nullptr); - // REQUIRE(tree->GetEntries() == 0); - // - // // test update() - // task.update({ TriggerType::NewObject, false, { 0, "NONE", "", "", "qc", { 2, 100000 } }, 100000 - 1 }, services); - // objectManager->stopPublishing(PublicationPolicy::Once); - // task.update({ TriggerType::NewObject, false, { 0, "NONE", "", "", "qc", { 100000, 200000 } }, 200000 - 1 }, services); - // REQUIRE(objectManager->getNumberPublishedObjects() == 3); - // REQUIRE(tree->GetEntries() == 2); - // auto varexp = "testHistoTrending.mean:testHistoTrending.entries:" + checkName + ".level"; - // tree->Draw(varexp.c_str(), "", "goff"); - // Double_t* means = tree->GetVal(0); - // Double_t* entries = tree->GetVal(1); - // Double_t* qualityLevels = tree->GetVal(2); - // CHECK_THAT(means[0], Catch::Matchers::WithinAbs(5, 0.01)); - // CHECK_THAT(entries[0], Catch::Matchers::WithinAbs(3, 0.01)); - // CHECK_THAT(qualityLevels[0], Catch::Matchers::WithinAbs(3, 0.01)); - // CHECK_THAT(means[1], Catch::Matchers::WithinAbs(5, 0.01)); - // CHECK_THAT(entries[1], Catch::Matchers::WithinAbs(4, 0.01)); - // CHECK_THAT(qualityLevels[1], Catch::Matchers::WithinAbs(1, 0.01)); - // - // auto histo1MO = objectManager->getMonitorObject("mean_of_histogram"); - // REQUIRE(histo1MO != nullptr); - // auto histo1 = dynamic_cast(histo1MO->getObject()); - // REQUIRE(histo1 != nullptr); - // CHECK(std::strcmp(histo1->GetName(), "mean_of_histogram") == 0); - // auto histo2MO = objectManager->getMonitorObject("quality_histogram"); - // REQUIRE(histo2MO != nullptr); - // auto histo2 = dynamic_cast(histo2MO->getObject()); - // REQUIRE(histo2 != nullptr); - // CHECK(std::strcmp(histo2->GetName(), "quality_histogram") == 0); - // objectManager->stopPublishing(PublicationPolicy::Once); - // - // // test finalize() - // REQUIRE_NOTHROW(task.finalize({ TriggerType::UserOrControl, true }, services)); - // REQUIRE(objectManager->getNumberPublishedObjects() == 3); - // REQUIRE(tree->GetEntries() == 2); - // objectManager->stopPublishing(PublicationPolicy::Once); - // objectManager->stopPublishing(PublicationPolicy::ThroughStop); + // Running the task + ServiceRegistry services; + services.registerService(repository.get()); + auto objectManager = std::make_shared(taskName, "o2::quality_control::postprocessing::TrendingTask", "TST"); + + TrendingTask task; + task.setName(trendingTaskName); + task.setID(trendingTaskID); + task.setObjectsManager(objectManager); + REQUIRE_NOTHROW(task.configure(config)); + + // test initialize() + REQUIRE_NOTHROW(task.initialize({ TriggerType::UserOrControl, true, { 0, "NONE", "", "", "qc" }, 1 }, services)); + REQUIRE(objectManager->getNumberPublishedObjects() == 1); + auto treeMO = objectManager->getMonitorObject(trendingTaskName); + REQUIRE(treeMO != nullptr); + TTree* tree = dynamic_cast(treeMO->getObject()); + REQUIRE(tree != nullptr); + REQUIRE(tree->GetEntries() == 0); + + // test update() + task.update({ TriggerType::NewObject, false, { 0, "NONE", "", "", "qc", { 2, 100000 } }, 100000 - 1 }, services); + objectManager->stopPublishing(PublicationPolicy::Once); + task.update({ TriggerType::NewObject, false, { 0, "NONE", "", "", "qc", { 100000, 200000 } }, 200000 - 1 }, services); + REQUIRE(objectManager->getNumberPublishedObjects() == 3); + REQUIRE(tree->GetEntries() == 2); + auto varexp = "testHistoTrending.mean:testHistoTrending.entries:" + checkName + ".level"; + tree->Draw(varexp.c_str(), "", "goff"); + Double_t* means = tree->GetVal(0); + Double_t* entries = tree->GetVal(1); + Double_t* qualityLevels = tree->GetVal(2); + CHECK_THAT(means[0], Catch::Matchers::WithinAbs(5, 0.01)); + CHECK_THAT(entries[0], Catch::Matchers::WithinAbs(3, 0.01)); + CHECK_THAT(qualityLevels[0], Catch::Matchers::WithinAbs(3, 0.01)); + CHECK_THAT(means[1], Catch::Matchers::WithinAbs(5, 0.01)); + CHECK_THAT(entries[1], Catch::Matchers::WithinAbs(4, 0.01)); + CHECK_THAT(qualityLevels[1], Catch::Matchers::WithinAbs(1, 0.01)); + + auto histo1MO = objectManager->getMonitorObject("mean_of_histogram"); + REQUIRE(histo1MO != nullptr); + auto histo1 = dynamic_cast(histo1MO->getObject()); + REQUIRE(histo1 != nullptr); + CHECK(std::strcmp(histo1->GetName(), "mean_of_histogram") == 0); + auto histo2MO = objectManager->getMonitorObject("quality_histogram"); + REQUIRE(histo2MO != nullptr); + auto histo2 = dynamic_cast(histo2MO->getObject()); + REQUIRE(histo2 != nullptr); + CHECK(std::strcmp(histo2->GetName(), "quality_histogram") == 0); + objectManager->stopPublishing(PublicationPolicy::Once); + + // test finalize() + REQUIRE_NOTHROW(task.finalize({ TriggerType::UserOrControl, true }, services)); + REQUIRE(objectManager->getNumberPublishedObjects() == 3); + REQUIRE(tree->GetEntries() == 2); + objectManager->stopPublishing(PublicationPolicy::Once); + objectManager->stopPublishing(PublicationPolicy::ThroughStop); }