From 45cfa7ede1afc213b89333f406be5a986ac2eac2 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Mon, 3 Jun 2024 17:58:48 -0400 Subject: [PATCH] JEventProcessorPODIO: deprecate podio:output_include_collections parameter (#1466) This is a follow up on a resolution from #1323 ### What kind of change does this PR introduce? - [ ] Bug fix (issue #__) - [x] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No ### Does this PR change default behavior? No --- .github/iwyu.imp | 1 + src/services/io/podio/JEventProcessorPODIO.cc | 37 ++++++++++++++++--- src/services/io/podio/JEventProcessorPODIO.h | 3 +- 3 files changed, 35 insertions(+), 6 deletions(-) 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 94e9642425..6ebcdd13b0 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", @@ -300,9 +302,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( @@ -316,8 +329,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()); @@ -333,6 +346,13 @@ 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."); + // Adding a delay to ensure users notice the deprecation warning. + using namespace std::chrono_literals; + std::this_thread::sleep_for(10s); + } + } @@ -341,7 +361,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()) { @@ -357,7 +377,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()) { @@ -491,5 +511,12 @@ 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); + } + 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;