From a6973850ea6cd5656ac291a7df4cafe41ac0f791 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Mon, 20 May 2024 19:35:11 -0400 Subject: [PATCH 1/4] JEventProcessorPODIO: deprecate podio:output_include_collections parameter --- src/services/io/podio/JEventProcessorPODIO.cc | 35 ++++++++++++++++--- src/services/io/podio/JEventProcessorPODIO.h | 3 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 0876fa8857..a852e82587 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -11,7 +11,9 @@ #include #include #include +#include #include +#include #include "services/log/Log_service.h" @@ -43,7 +45,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() { ); // Get the list of output collections to include/exclude - std::vector output_include_collections={ + std::vector output_collections={ // Header and other metadata "EventHeader", @@ -297,9 +299,20 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "DIRCSeededParticleIDs", }; std::vector output_exclude_collections; // need to get as vector, then convert to set + std::string output_include_collections = "DEPRECATED"; japp->SetDefaultParameter( "podio:output_include_collections", output_include_collections, + "DEPRECATED. Use podio:output_collections instead." + ); + if (output_include_collections != "DEPRECATED") { + output_collections.clear(); + JParameterManager::Parse(output_include_collections, output_collections); + m_output_include_collections_set = true; + } + japp->SetDefaultParameter( + "podio:output_collections", + output_collections, "Comma separated list of collection names to write out. If not set, all collections will be written (including ones from input file). Don't set this and use PODIO:OUTPUT_EXCLUDE_COLLECTIONS to write everything except a selection." ); japp->SetDefaultParameter( @@ -313,8 +326,8 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "Comma separated list of collection names to print to screen, e.g. for debugging." ); - m_output_include_collections = std::set(output_include_collections.begin(), - output_include_collections.end()); + m_output_collections = std::set(output_collections.begin(), + output_collections.end()); m_output_exclude_collections = std::set(output_exclude_collections.begin(), output_exclude_collections.end()); @@ -330,6 +343,12 @@ void JEventProcessorPODIO::Init() { // TODO: NWB: Verify that output file is writable NOW, rather than after event processing completes. // I definitely don't trust PODIO to do this for me. + if (m_output_include_collections_set) { + m_log->error("The podio:output_include_collections was provided, but is deprecated. Use podio:output_collections instead."); + using namespace std::chrono_literals; + std::this_thread::sleep_for(10s); + } + } @@ -338,7 +357,7 @@ void JEventProcessorPODIO::FindCollectionsToWrite(const std::shared_ptr all_collections = event->GetAllCollectionNames(); - if (m_output_include_collections.empty()) { + if (m_output_collections.empty()) { // User has not specified an include list, so we include _all_ PODIO collections present in the first event. for (const std::string& col : all_collections) { if (m_output_exclude_collections.find(col) == m_output_exclude_collections.end()) { @@ -354,7 +373,7 @@ void JEventProcessorPODIO::FindCollectionsToWrite(const std::shared_ptr all_collections_set = std::set(all_collections.begin(), all_collections.end()); - for (const auto& col : m_output_include_collections) { + for (const auto& col : m_output_collections) { if (m_output_exclude_collections.find(col) == m_output_exclude_collections.end()) { // Included and not excluded if (all_collections_set.find(col) == all_collections_set.end()) { @@ -488,5 +507,11 @@ void JEventProcessorPODIO::Process(const std::shared_ptr &event) { } void JEventProcessorPODIO::Finish() { + if (m_output_include_collections_set) { + m_log->error("The podio:output_include_collections was provided, but is deprecated. Use podio:output_collections instead."); + using namespace std::chrono_literals; + std::this_thread::sleep_for(10s); + } + m_writer->finish(); } diff --git a/src/services/io/podio/JEventProcessorPODIO.h b/src/services/io/podio/JEventProcessorPODIO.h index 4ab126a140..77d72679de 100644 --- a/src/services/io/podio/JEventProcessorPODIO.h +++ b/src/services/io/podio/JEventProcessorPODIO.h @@ -30,10 +30,11 @@ class JEventProcessorPODIO : public JEventProcessor { bool m_is_first_event = true; bool m_user_included_collections = false; std::shared_ptr m_log; + bool m_output_include_collections_set = false; std::string m_output_file = "podio_output.root"; std::string m_output_file_copy_dir = ""; - std::set m_output_include_collections; // config. parameter + std::set m_output_collections; // config. parameter std::set m_output_exclude_collections; // config. parameter std::vector m_collections_to_write; // derived from above config. parameters std::vector m_collections_to_print; From e6ee28b1d297e51bd81693fefe5e1e02a404d494 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Mon, 20 May 2024 19:52:26 -0400 Subject: [PATCH 2/4] IWYU --- src/services/io/podio/JEventProcessorPODIO.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index a852e82587..e3152ed0e3 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -1,16 +1,16 @@ #include "JEventProcessorPODIO.h" -#include - #include #include #include #include +#include #include #include #include #include +// IWYU pragma: no_include #include #include #include From 9d11a4a974192f59b6fec4eb6494d47e239ffbde Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Mon, 20 May 2024 20:09:57 -0400 Subject: [PATCH 3/4] IWYU --- .github/iwyu.imp | 1 + src/services/io/podio/JEventProcessorPODIO.cc | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/iwyu.imp b/.github/iwyu.imp index e7ef6d254c..e1ea3cd578 100644 --- a/.github/iwyu.imp +++ b/.github/iwyu.imp @@ -30,6 +30,7 @@ { include: ['', private, '', public] }, # the rest + { include: ['', private, '', public] }, { include: ['', private, '', public] }, { include: ['', private, '', public] }, # https://github.com/include-what-you-use/include-what-you-use/issues/166 diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index e3152ed0e3..6ba6e39bdb 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -10,7 +10,6 @@ #include #include #include -// IWYU pragma: no_include #include #include #include From a80b057c2b9de79a05fab8517f7dcc116979a95f Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sat, 25 May 2024 20:15:40 -0400 Subject: [PATCH 4/4] Update JEventProcessorPODIO.cc --- src/services/io/podio/JEventProcessorPODIO.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 6ba6e39bdb..c68561e042 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -344,6 +344,7 @@ void JEventProcessorPODIO::Init() { if (m_output_include_collections_set) { m_log->error("The podio:output_include_collections was provided, but is deprecated. Use podio:output_collections instead."); + // Adding a delay to ensure users notice the deprecation warning. using namespace std::chrono_literals; std::this_thread::sleep_for(10s); } @@ -508,6 +509,7 @@ void JEventProcessorPODIO::Process(const std::shared_ptr &event) { void JEventProcessorPODIO::Finish() { if (m_output_include_collections_set) { m_log->error("The podio:output_include_collections was provided, but is deprecated. Use podio:output_collections instead."); + // Adding a delay to ensure users notice the deprecation warning. using namespace std::chrono_literals; std::this_thread::sleep_for(10s); }