diff --git a/k4FWCore/components/PodioInput.cpp b/k4FWCore/components/PodioInput.cpp index acb4d47c..cbb98921 100644 --- a/k4FWCore/components/PodioInput.cpp +++ b/k4FWCore/components/PodioInput.cpp @@ -186,6 +186,17 @@ PodioInput::PodioInput(const std::string& name, ISvcLocator* svcLoc) : Consumer( fillReaders(); } +StatusCode PodioInput::initialize() { + // If someone uses the collections property from the command line and passes + // an empty string we assume they want all collections (as a simple way to + // override whatever is in the options file) + if (m_collectionNames.size() == 1 && m_collectionNames[0].empty()) { + m_collectionNames.clear(); + } + + return StatusCode::SUCCESS; +} + void PodioInput::operator()() const { if (m_podioDataSvc->getEventFrame().get(edm4hep::EventHeaderName)) { m_readers[edm4hep::EventHeaderCollection::typeName](edm4hep::EventHeaderName); diff --git a/k4FWCore/components/PodioInput.h b/k4FWCore/components/PodioInput.h index 978d821e..a8c4a59f 100644 --- a/k4FWCore/components/PodioInput.h +++ b/k4FWCore/components/PodioInput.h @@ -42,6 +42,8 @@ class PodioInput final : public Gaudi::Functional::Consumer PodioInput(const std::string& name, ISvcLocator* svcLoc); void operator()() const override; + StatusCode initialize() final; + private: template void maybeRead(std::string_view collName) const; void fillReaders(); diff --git a/test/k4FWCoreTest/CMakeLists.txt b/test/k4FWCoreTest/CMakeLists.txt index 19f40204..85e261e5 100644 --- a/test/k4FWCoreTest/CMakeLists.txt +++ b/test/k4FWCoreTest/CMakeLists.txt @@ -60,6 +60,7 @@ endfunction() add_test_with_env(CreateExampleEventData options/createExampleEventData.py) add_test_with_env(CheckExampleEventData options/checkExampleEventData.py PROPERTIES DEPENDS CreateExampleEventData) +add_test_with_env(CheckExampleEventData_noCollections options/checkExampleEventData.py --collections= PROPERTIES DEPENDS CreateExampleEventData) add_test_with_env(CheckExampleEventData_toolong -n 999 options/checkExampleEventData.py PROPERTIES PASS_REGULAR_EXPRESSION "Application Manager Terminated successfully with a user requested ScheduledStop" DEPENDS CreateExampleEventData) add_test_with_env(CheckExampleEventData_unbounded options/checkExampleEventData.py -n 999 PROPERTIES PASS_REGULAR_EXPRESSION diff --git a/test/k4FWCoreTest/options/checkExampleEventData.py b/test/k4FWCoreTest/options/checkExampleEventData.py index 80be3b52..2f635132 100644 --- a/test/k4FWCoreTest/options/checkExampleEventData.py +++ b/test/k4FWCoreTest/options/checkExampleEventData.py @@ -26,14 +26,19 @@ from Configurables import PodioInput +from k4FWCore.parseArgs import parser + +parser.add_argument( + "--collections", + action="extend", + nargs="?", + help="The input collections to read", + default=["VectorFloat", "MCParticles", "SimTrackerHits", "TrackerHits", "Tracks"], +) +my_args = parser.parse_known_args()[0] + inp = PodioInput() -inp.collections = [ - "VectorFloat", - "MCParticles", - "SimTrackerHits", - "TrackerHits", - "Tracks", -] +inp.collections = my_args.collections from Configurables import k4FWCoreTest_CheckExampleEventData