From d994b12a3b9b0d736bf0117fe2078128a19b8b0f Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Thu, 15 Aug 2024 17:19:01 +0200 Subject: [PATCH 1/8] add tests for reading metadata from file --- test/k4FWCoreTest/CMakeLists.txt | 5 +- test/k4FWCoreTest/options/CheckOutputFiles.py | 51 +++++++++++++------ .../options/ExampleFunctionalMetadataRead.py | 39 ++++++++++++++ ...ampleFunctionalMetadataReadOldAlgorithm.py | 39 ++++++++++++++ 4 files changed, 117 insertions(+), 17 deletions(-) create mode 100644 test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py create mode 100644 test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py diff --git a/test/k4FWCoreTest/CMakeLists.txt b/test/k4FWCoreTest/CMakeLists.txt index e65fc048..524303e8 100644 --- a/test/k4FWCoreTest/CMakeLists.txt +++ b/test/k4FWCoreTest/CMakeLists.txt @@ -136,14 +136,17 @@ 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_with_env(FunctionalMetadataRead options/ExampleFunctionalMetadataRead.py PROPERTIES DEPENDS FunctionalMetadata) add_test_with_env(FunctionalMetadataOldAlgorithm options/ExampleFunctionalMetadataOldAlgorithm.py) add_test_with_env(createEventHeaderConcurrent options/createEventHeaderConcurrent.py) +add_test_with_env(FunctionalMetadataReadOldAlgorithm options/ExampleFunctionalMetadataReadOldAlgorithm.py PROPERTIES DEPENDS ExampleFunctionalMetadataOldAlgorithm) add_test_with_env(FunctionalWrongImport options/ExampleFunctionalWrongImport.py) set_tests_properties(FunctionalWrongImport PROPERTIES PASS_REGULAR_EXPRESSION "ImportError: Importing ApplicationMgr or IOSvc from Configurables is not allowed.") 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;FunctionalMetadataOldAlgorithm;createEventHeaderConcurrent") + +set_tests_properties(FunctionalCheckFiles PROPERTIES DEPENDS "FunctionalFile;FunctionalMTFile;FunctionalMultipleFile;FunctionalOutputCommands;FunctionalProducerAbsolutePath;FunctionalTransformerRuntimeEmpty;FunctionalMix;FunctionalMixIOSvc;FunctionalTransformerHist;FunctionalCollectionMerger;FunctionalFilterFile;FunctionalMetadata;FunctionalMetadataRead;FunctionalMetadataOldAlgorithm;FunctionalMetadataReadOldAlgorithm;createEventHeaderConcurrent") # Do this after checking the files not to overwrite them add_test_with_env(FunctionalFile_toolong options/ExampleFunctionalFile.py -n 999 PROPERTIES DEPENDS FunctionalCheckFiles PASS_REGULAR_EXPRESSION diff --git a/test/k4FWCoreTest/options/CheckOutputFiles.py b/test/k4FWCoreTest/options/CheckOutputFiles.py index 90c8971d..a7ad127a 100644 --- a/test/k4FWCoreTest/options/CheckOutputFiles.py +++ b/test/k4FWCoreTest/options/CheckOutputFiles.py @@ -58,6 +58,17 @@ def check_events(filename, number): raise RuntimeError("Number of events does not match expected number") +def check_metadata(filename, keys, values): + print(f'Checking file "{filename}" for metadata') + podio_reader = podio.root_io.Reader(filename) + metadata = podio_reader.get("metadata")[0] + for key, value in zip(keys, values): + if metadata.get_parameter(key) != value: + raise RuntimeError( + f"Metadata parameter {key} does not match the expected value, got {metadata.get_parameter(key)} but expected {value}" + ) + + check_collections("functional_transformer.root", ["MCParticles", "NewMCParticles"]) check_collections( "functional_transformer_multiple.root", @@ -161,9 +172,8 @@ def check_events(filename, number): check_collections("functional_metadata.root", ["MCParticles"]) -reader = podio.root_io.Reader("functional_metadata.root") -metadata = reader.get("metadata")[0] -for key, value in zip( +check_metadata( + "functional_metadata.root", [ "NumberOfParticles", "ParticleTime", @@ -172,22 +182,31 @@ def check_events(filename, number): "FinalizeMetadataInt", ], [3, 1.5, [1, 2, 3, 4], "hello", 10], -): - if metadata.get_parameter(key) != value: - raise RuntimeError( - f"Metadata parameter {key} does not match the expected value, got {metadata.get_parameter(key)} but expected {value}" - ) +) + +check_metadata( + "functional_metadata_propagate.root", + [ + "NumberOfParticles", + "ParticleTime", + "PDGValues", + "MetadataString", + "FinalizeMetadataInt", + ], + [3, 1.5, [1, 2, 3, 4], "hello", 10], +) -reader = podio.root_io.Reader("functional_metadata_old_algorithm.root") -metadata = reader.get("metadata")[0] -for key, value in zip( +check_metadata( + "functional_metadata_old_algorithm.root", ["SimTrackerHits__CellIDEncoding"], ["M:3,S-1:3,I:9,J:9,K-1:6"], -): - if metadata.get_parameter(key) != value: - raise RuntimeError( - f"Metadata parameter {key} does not match the expected value, got {metadata.get_parameter(key)} but expected {value}" - ) +) + +check_metadata( + "functional_metadata_old_algorithm_propagate.root", + ["SimTrackerHits__CellIDEncoding"], + ["M:3,S-1:3,I:9,J:9,K-1:6"], +) reader = podio.root_io.Reader("eventHeaderConcurrent.root") events = reader.get("events") diff --git a/test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py b/test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py new file mode 100644 index 00000000..19d46668 --- /dev/null +++ b/test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py @@ -0,0 +1,39 @@ +# +# Copyright (c) 2014-2024 Key4hep-Project. +# +# This file is part of Key4hep. +# See https://key4hep.github.io/key4hep-doc/ for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This is an example accessing matadata read from input file using MetadataSvc + +from Gaudi.Configuration import INFO +from Configurables import ExampleFunctionalMetadataConsumer +from k4FWCore import ApplicationMgr, IOSvc +from Configurables import EventDataSvc + +iosvc = IOSvc() +iosvc.input = "functional_metadata.root" +iosvc.output = "functional_metadata_propagate.root" + +consumer = ExampleFunctionalMetadataConsumer("Consumer", InputCollection=["MCParticles"]) + +ApplicationMgr( + TopAlg=[consumer], + EvtSel="NONE", + EvtMax=10, + ExtSvc=[EventDataSvc("EventDataSvc")], + OutputLevel=INFO, +) diff --git a/test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py b/test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py new file mode 100644 index 00000000..69e6bb74 --- /dev/null +++ b/test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py @@ -0,0 +1,39 @@ +# +# Copyright (c) 2014-2024 Key4hep-Project. +# +# This file is part of Key4hep. +# See https://key4hep.github.io/key4hep-doc/ for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This is an example accessing matadata read from input file using MetaDataHandle + +from Gaudi.Configuration import INFO +from Configurables import k4FWCoreTest_cellID_reader +from k4FWCore import ApplicationMgr, IOSvc + +iosvc = IOSvc() +iosvc.input = "functional_metadata_old_algorithm.root" +iosvc.output = "functional_metadata_old_algorithm_propagate.root" + +consumer = k4FWCoreTest_cellID_reader() + +ApplicationMgr( + TopAlg=[consumer], + EvtSel="NONE", + EvtMax=10, + ExtSvc=[], + OutputLevel=INFO, + StopOnSignal=True, +) From e7788c2df3f70d6629dcb5ee5e2990804c4be9b2 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Thu, 15 Aug 2024 17:28:23 +0200 Subject: [PATCH 2/8] fix frame variable shadowing in metadata service interface --- k4FWCore/components/MetadataSvc.cpp | 6 ++---- k4FWCore/components/MetadataSvc.h | 5 ++++- k4FWCore/components/Writer.cpp | 4 ++-- k4FWCore/include/k4FWCore/IMetadataSvc.h | 15 +++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/k4FWCore/components/MetadataSvc.cpp b/k4FWCore/components/MetadataSvc.cpp index a0da7928..25adeaf8 100644 --- a/k4FWCore/components/MetadataSvc.cpp +++ b/k4FWCore/components/MetadataSvc.cpp @@ -38,14 +38,12 @@ StatusCode MetadataSvc::initialize() { error() << "Unable to locate the EventDataSvc" << endmsg; return StatusCode::FAILURE; } - - m_frame = std::make_unique(); - return StatusCode::SUCCESS; } StatusCode MetadataSvc::finalize() { return Service::finalize(); } -void MetadataSvc::setFrame(podio::Frame&& fr) { m_frame = std::make_unique(std::move(fr)); } +podio::Frame* MetadataSvc::getFrame() { return m_frame.get(); } +void MetadataSvc::setFrame(podio::Frame&& frame) { m_frame = std::make_unique(std::move(frame)); } DECLARE_COMPONENT(MetadataSvc) diff --git a/k4FWCore/components/MetadataSvc.h b/k4FWCore/components/MetadataSvc.h index 42cc281b..857aec8b 100644 --- a/k4FWCore/components/MetadataSvc.h +++ b/k4FWCore/components/MetadataSvc.h @@ -26,6 +26,8 @@ #include "k4FWCore/IMetadataSvc.h" +#include + class MetadataSvc : public extends { using extends::extends; @@ -38,7 +40,8 @@ class MetadataSvc : public extends { std::unique_ptr m_frame; - void setFrame(podio::Frame&& frame) override; + podio::Frame* getFrame() override; + void setFrame(podio::Frame&& frame) override; }; #endif diff --git a/k4FWCore/components/Writer.cpp b/k4FWCore/components/Writer.cpp index f4c9fb29..94952bcf 100644 --- a/k4FWCore/components/Writer.cpp +++ b/k4FWCore/components/Writer.cpp @@ -121,8 +121,8 @@ class Writer final : public Gaudi::Functional::ConsumergetWriter()->writeFrame(config_metadata_frame, "configuration_metadata"); - if (m_metadataSvc->m_frame) { - iosvc->getWriter()->writeFrame(*std::move(m_metadataSvc->m_frame), podio::Category::Metadata); + if (auto* metadata_frame = m_metadataSvc->getFrame(); metadata_frame) { + iosvc->getWriter()->writeFrame(*metadata_frame, podio::Category::Metadata); } iosvc->deleteWriter(); diff --git a/k4FWCore/include/k4FWCore/IMetadataSvc.h b/k4FWCore/include/k4FWCore/IMetadataSvc.h index 0144608e..019af862 100644 --- a/k4FWCore/include/k4FWCore/IMetadataSvc.h +++ b/k4FWCore/include/k4FWCore/IMetadataSvc.h @@ -19,8 +19,6 @@ #ifndef FWCORE_IMETADATASERVICE_H #define FWCORE_IMETADATASERVICE_H -#include - #include "GaudiKernel/IInterface.h" #include "podio/Frame.h" @@ -29,16 +27,17 @@ class IMetadataSvc : virtual public IInterface { public: DeclareInterfaceID(IMetadataSvc, 1, 0); - std::unique_ptr m_frame; + virtual podio::Frame* getFrame() = 0; + virtual void setFrame(podio::Frame&& frame) = 0; - virtual void setFrame(podio::Frame&& fr) = 0; template void put(const std::string& name, const T& obj) { - if (!m_frame) { - m_frame = std::make_unique(); + if (!getFrame()) { + setFrame(podio::Frame{}); } - m_frame->putParameter(name, obj); + getFrame()->putParameter(name, obj); } - template std::optional get(const std::string& name) { return m_frame->getParameter(name); } + + template std::optional get(const std::string& name) { return getFrame()->getParameter(name); } }; #endif From e0dd7d049ed361982fdadfc9fdb9067046641bd6 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Thu, 15 Aug 2024 17:32:11 +0200 Subject: [PATCH 3/8] fix get metadata not checking if frame exists --- k4FWCore/include/k4FWCore/IMetadataSvc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/k4FWCore/include/k4FWCore/IMetadataSvc.h b/k4FWCore/include/k4FWCore/IMetadataSvc.h index 019af862..8ad64727 100644 --- a/k4FWCore/include/k4FWCore/IMetadataSvc.h +++ b/k4FWCore/include/k4FWCore/IMetadataSvc.h @@ -37,7 +37,13 @@ class IMetadataSvc : virtual public IInterface { getFrame()->putParameter(name, obj); } - template std::optional get(const std::string& name) { return getFrame()->getParameter(name); } + template std::optional get(const std::string& name) { + auto* frame = getFrame(); + if (!frame) { + return std::nullopt; + } + return frame->getParameter(name); + } }; #endif From 9d2015188bc1752dba08e9a0134e84c9bf26aa15 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Fri, 16 Aug 2024 09:24:50 +0200 Subject: [PATCH 4/8] make methods const when appropriate --- k4FWCore/components/MetadataSvc.cpp | 3 ++- k4FWCore/components/MetadataSvc.h | 5 +++-- k4FWCore/components/Writer.cpp | 3 ++- k4FWCore/include/k4FWCore/IMetadataSvc.h | 11 +++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/k4FWCore/components/MetadataSvc.cpp b/k4FWCore/components/MetadataSvc.cpp index 25adeaf8..d87f0845 100644 --- a/k4FWCore/components/MetadataSvc.cpp +++ b/k4FWCore/components/MetadataSvc.cpp @@ -43,7 +43,8 @@ StatusCode MetadataSvc::initialize() { StatusCode MetadataSvc::finalize() { return Service::finalize(); } -podio::Frame* MetadataSvc::getFrame() { return m_frame.get(); } +const podio::Frame* MetadataSvc::getFrame() const { return m_frame.get(); } +podio::Frame* MetadataSvc::getFrame() { return m_frame.get(); } void MetadataSvc::setFrame(podio::Frame&& frame) { m_frame = std::make_unique(std::move(frame)); } DECLARE_COMPONENT(MetadataSvc) diff --git a/k4FWCore/components/MetadataSvc.h b/k4FWCore/components/MetadataSvc.h index 857aec8b..13a8703f 100644 --- a/k4FWCore/components/MetadataSvc.h +++ b/k4FWCore/components/MetadataSvc.h @@ -40,8 +40,9 @@ class MetadataSvc : public extends { std::unique_ptr m_frame; - podio::Frame* getFrame() override; - void setFrame(podio::Frame&& frame) override; + const podio::Frame* getFrame() const override; + podio::Frame* getFrame() override; + void setFrame(podio::Frame&& frame) override; }; #endif diff --git a/k4FWCore/components/Writer.cpp b/k4FWCore/components/Writer.cpp index 94952bcf..f44dce11 100644 --- a/k4FWCore/components/Writer.cpp +++ b/k4FWCore/components/Writer.cpp @@ -34,6 +34,7 @@ #include #include +#include class Writer final : public Gaudi::Functional::Consumer { public: @@ -121,7 +122,7 @@ class Writer final : public Gaudi::Functional::ConsumergetWriter()->writeFrame(config_metadata_frame, "configuration_metadata"); - if (auto* metadata_frame = m_metadataSvc->getFrame(); metadata_frame) { + if (const auto* metadata_frame = std::as_const(*m_metadataSvc).getFrame(); metadata_frame) { iosvc->getWriter()->writeFrame(*metadata_frame, podio::Category::Metadata); } diff --git a/k4FWCore/include/k4FWCore/IMetadataSvc.h b/k4FWCore/include/k4FWCore/IMetadataSvc.h index 8ad64727..c88df593 100644 --- a/k4FWCore/include/k4FWCore/IMetadataSvc.h +++ b/k4FWCore/include/k4FWCore/IMetadataSvc.h @@ -27,8 +27,8 @@ class IMetadataSvc : virtual public IInterface { public: DeclareInterfaceID(IMetadataSvc, 1, 0); - virtual podio::Frame* getFrame() = 0; - virtual void setFrame(podio::Frame&& frame) = 0; + virtual const podio::Frame* getFrame() const = 0; + virtual void setFrame(podio::Frame&& frame) = 0; template void put(const std::string& name, const T& obj) { if (!getFrame()) { @@ -37,13 +37,16 @@ class IMetadataSvc : virtual public IInterface { getFrame()->putParameter(name, obj); } - template std::optional get(const std::string& name) { - auto* frame = getFrame(); + template std::optional get(const std::string& name) const { + const auto* frame = getFrame(); if (!frame) { return std::nullopt; } return frame->getParameter(name); } + +protected: + virtual podio::Frame* getFrame() = 0; }; #endif From cd3ce7b6814fc0568ad2512a5c301d93976f8729 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila <37295697+m-fila@users.noreply.github.com> Date: Fri, 30 Aug 2024 08:40:13 +0200 Subject: [PATCH 5/8] Update test/k4FWCoreTest/options/CheckOutputFiles.py Co-authored-by: Andre Sailer --- test/k4FWCoreTest/options/CheckOutputFiles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/k4FWCoreTest/options/CheckOutputFiles.py b/test/k4FWCoreTest/options/CheckOutputFiles.py index a7ad127a..0bb86c21 100644 --- a/test/k4FWCoreTest/options/CheckOutputFiles.py +++ b/test/k4FWCoreTest/options/CheckOutputFiles.py @@ -63,9 +63,9 @@ def check_metadata(filename, keys, values): podio_reader = podio.root_io.Reader(filename) metadata = podio_reader.get("metadata")[0] for key, value in zip(keys, values): - if metadata.get_parameter(key) != value: + if (metaval := metadata.get_parameter(key)) != value: raise RuntimeError( - f"Metadata parameter {key} does not match the expected value, got {metadata.get_parameter(key)} but expected {value}" + f"Metadata parameter {key} does not match the expected value, got {metaval} but expected {value}" ) From 9c5264f14b75db401455418bd39a880ef3d2d093 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Tue, 3 Sep 2024 10:27:25 +0200 Subject: [PATCH 6/8] use dict for expected metadata in check_metadata --- test/k4FWCoreTest/options/CheckOutputFiles.py | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/k4FWCoreTest/options/CheckOutputFiles.py b/test/k4FWCoreTest/options/CheckOutputFiles.py index 0bb86c21..5bbeaf13 100644 --- a/test/k4FWCoreTest/options/CheckOutputFiles.py +++ b/test/k4FWCoreTest/options/CheckOutputFiles.py @@ -58,11 +58,11 @@ def check_events(filename, number): raise RuntimeError("Number of events does not match expected number") -def check_metadata(filename, keys, values): +def check_metadata(filename, expected_metadata): print(f'Checking file "{filename}" for metadata') podio_reader = podio.root_io.Reader(filename) metadata = podio_reader.get("metadata")[0] - for key, value in zip(keys, values): + for key, value in expected_metadata.items(): if (metaval := metadata.get_parameter(key)) != value: raise RuntimeError( f"Metadata parameter {key} does not match the expected value, got {metaval} but expected {value}" @@ -174,38 +174,38 @@ def check_metadata(filename, keys, values): check_metadata( "functional_metadata.root", - [ - "NumberOfParticles", - "ParticleTime", - "PDGValues", - "MetadataString", - "FinalizeMetadataInt", - ], - [3, 1.5, [1, 2, 3, 4], "hello", 10], + { + "NumberOfParticles": 3, + "ParticleTime": 1.5, + "PDGValues": [1, 2, 3, 4], + "MetadataString": "hello", + "FinalizeMetadataInt": 10, + }, ) check_metadata( "functional_metadata_propagate.root", - [ - "NumberOfParticles", - "ParticleTime", - "PDGValues", - "MetadataString", - "FinalizeMetadataInt", - ], - [3, 1.5, [1, 2, 3, 4], "hello", 10], + { + "NumberOfParticles": 3, + "ParticleTime": 1.5, + "PDGValues": [1, 2, 3, 4], + "MetadataString": "hello", + "FinalizeMetadataInt": 10, + }, ) check_metadata( "functional_metadata_old_algorithm.root", - ["SimTrackerHits__CellIDEncoding"], - ["M:3,S-1:3,I:9,J:9,K-1:6"], + { + "SimTrackerHits__CellIDEncoding": "M:3,S-1:3,I:9,J:9,K-1:6", + }, ) check_metadata( "functional_metadata_old_algorithm_propagate.root", - ["SimTrackerHits__CellIDEncoding"], - ["M:3,S-1:3,I:9,J:9,K-1:6"], + { + "SimTrackerHits__CellIDEncoding": "M:3,S-1:3,I:9,J:9,K-1:6", + }, ) reader = podio.root_io.Reader("eventHeaderConcurrent.root") From e53afba5eaecfce3b6bd5d4c401df8da64d0efd2 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Fri, 6 Sep 2024 12:43:55 +0200 Subject: [PATCH 7/8] fix input/output property name Co-authored-by: jmcarcell --- test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py | 4 ++-- .../options/ExampleFunctionalMetadataReadOldAlgorithm.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py b/test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py index 19d46668..a5c34f93 100644 --- a/test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py +++ b/test/k4FWCoreTest/options/ExampleFunctionalMetadataRead.py @@ -25,8 +25,8 @@ from Configurables import EventDataSvc iosvc = IOSvc() -iosvc.input = "functional_metadata.root" -iosvc.output = "functional_metadata_propagate.root" +iosvc.Input = "functional_metadata.root" +iosvc.Output = "functional_metadata_propagate.root" consumer = ExampleFunctionalMetadataConsumer("Consumer", InputCollection=["MCParticles"]) diff --git a/test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py b/test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py index 69e6bb74..5bbcc418 100644 --- a/test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py +++ b/test/k4FWCoreTest/options/ExampleFunctionalMetadataReadOldAlgorithm.py @@ -24,8 +24,8 @@ from k4FWCore import ApplicationMgr, IOSvc iosvc = IOSvc() -iosvc.input = "functional_metadata_old_algorithm.root" -iosvc.output = "functional_metadata_old_algorithm_propagate.root" +iosvc.Input = "functional_metadata_old_algorithm.root" +iosvc.Output = "functional_metadata_old_algorithm_propagate.root" consumer = k4FWCoreTest_cellID_reader() From 38f8bd280ad722a8b8187e91f87ea199d357e988 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Tue, 17 Sep 2024 10:04:41 +0200 Subject: [PATCH 8/8] don't make getFrame public --- k4FWCore/components/Writer.cpp | 2 +- k4FWCore/include/k4FWCore/IMetadataSvc.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/k4FWCore/components/Writer.cpp b/k4FWCore/components/Writer.cpp index f44dce11..a613be8e 100644 --- a/k4FWCore/components/Writer.cpp +++ b/k4FWCore/components/Writer.cpp @@ -122,7 +122,7 @@ class Writer final : public Gaudi::Functional::ConsumergetWriter()->writeFrame(config_metadata_frame, "configuration_metadata"); - if (const auto* metadata_frame = std::as_const(*m_metadataSvc).getFrame(); metadata_frame) { + if (const auto* metadata_frame = m_metadataSvc->getFrame(); metadata_frame) { iosvc->getWriter()->writeFrame(*metadata_frame, podio::Category::Metadata); } diff --git a/k4FWCore/include/k4FWCore/IMetadataSvc.h b/k4FWCore/include/k4FWCore/IMetadataSvc.h index c88df593..6066a301 100644 --- a/k4FWCore/include/k4FWCore/IMetadataSvc.h +++ b/k4FWCore/include/k4FWCore/IMetadataSvc.h @@ -24,11 +24,12 @@ #include "podio/Frame.h" class IMetadataSvc : virtual public IInterface { + friend class Writer; + public: DeclareInterfaceID(IMetadataSvc, 1, 0); - virtual const podio::Frame* getFrame() const = 0; - virtual void setFrame(podio::Frame&& frame) = 0; + virtual void setFrame(podio::Frame&& frame) = 0; template void put(const std::string& name, const T& obj) { if (!getFrame()) { @@ -46,7 +47,8 @@ class IMetadataSvc : virtual public IInterface { } protected: - virtual podio::Frame* getFrame() = 0; + virtual podio::Frame* getFrame() = 0; + virtual const podio::Frame* getFrame() const = 0; }; #endif