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 0876fa8857..c68561e042 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -1,17 +1,18 @@ #include "JEventProcessorPODIO.h" -#include - #include #include #include #include +#include #include #include #include #include +#include #include +#include #include "services/log/Log_service.h" @@ -43,7 +44,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 +298,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 +325,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 +342,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); + } + } @@ -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,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;