Skip to content

Commit

Permalink
Do not allow to put parameters during the event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Jul 26, 2024
1 parent 8537364 commit b7641c8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion k4FWCore/include/k4FWCore/IMetadataSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

class IMetadataSvc : virtual public IInterface {
public:
/// InterfaceID
DeclareInterfaceID(IMetadataSvc, 1, 0);

std::unique_ptr<podio::Frame> m_frame;
Expand Down
2 changes: 2 additions & 0 deletions test/k4FWCoreTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ add_test_with_env(FunctionalTransformerHist options/ExampleFunctionalTransformer
add_test_with_env(FunctionalCollectionMerger options/ExampleFunctionalCollectionMerger.py)
add_test_with_env(FunctionalFilterFile options/ExampleFunctionalFilterFile.py)
add_test_with_env(FunctionalMetadata options/ExampleFunctionalMetadata.py)

add_test(NAME FunctionalCheckFiles COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/options/CheckOutputFiles.py)
set_tests_properties(FunctionalCheckFiles PROPERTIES DEPENDS "FunctionalFile;FunctionalMTFile;FunctionalMultipleFile;FunctionalOutputCommands;FunctionalProducerAbsolutePath;FunctionalTransformerRuntimeEmpty;FunctionalMix;FunctionalMixIOSvc;FunctionalTransformerHist;FunctionalCollectionMerger;FunctionalFilterFile;FunctionalMetadata")

# Do this after checking the files not to overwrite them
Expand Down
3 changes: 1 addition & 2 deletions test/k4FWCoreTest/options/CheckOutputFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ def check_events(filename, number):
"ParticleTime",
"PDGValues",
"MetadataString",
"EventMetadataInt",
"FinalizeMetadataInt",
],
[3, 1.5, [1, 2, 3, 4], "hello", 5, 10],
[3, 1.5, [1, 2, 3, 4], "hello", 10],
):
if metadata.get_parameter(key) != value:
raise RuntimeError(f"Metadata parameter {key} does not match expected value")
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ struct ExampleFunctionalMetadataConsumer final : k4FWCore::Consumer<void(const e
return StatusCode::FAILURE;
}

auto eventMetadataInt = k4FWCore::getParameter<int>("EventMetadataInt", this).value_or(-1);
if (eventMetadataInt != 5) {
error() << "EventMetadataInt is not 5" << endmsg;
return StatusCode::FAILURE;
}
// Putting parameters in the main loop fails
// auto eventMetadataInt = k4FWCore::getParameter<int>("EventMetadataInt", this).value_or(-1);
// if (eventMetadataInt != 5) {
// error() << "EventMetadataInt is not 5" << endmsg;
// return StatusCode::FAILURE;
// }

auto finalizeMetadataInt = k4FWCore::getParameter<int>("FinalizeMetadataInt", this).value_or(-1);
if (finalizeMetadataInt != 10) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ struct ExampleFunctionalMetadataProducer final : k4FWCore::Producer<edm4hep::MCP
}

edm4hep::MCParticleCollection operator()() const override {
k4FWCore::putParameter("EventMetadataInt", 5, this);
// Putting metadata in the main loop doesn't work
// k4FWCore::putParameter("EventMetadataInt", 5, this);
auto coll = edm4hep::MCParticleCollection();
for (int i = 0; i < m_particleNum.value(); ++i) {
auto particle = coll.create();
Expand Down

0 comments on commit b7641c8

Please sign in to comment.