From f11621920e91beeb4d68f8b4fe6f7e1aefe93120 Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com> Date: Fri, 27 Sep 2024 17:58:16 +0200 Subject: [PATCH] Fix imports in python files and other minor changes (#25) --- .../options/createExampleEventData.py | 9 +++--- k4ProjectTemplate/options/createHelloWorld.py | 17 ++++++----- .../options/readExampleEventData.py | 28 ++++++++----------- .../src/components/ExampleConsumer.cpp | 6 ++-- .../src/components/ExampleTransformer.cpp | 11 +++----- 5 files changed, 29 insertions(+), 42 deletions(-) diff --git a/k4ProjectTemplate/options/createExampleEventData.py b/k4ProjectTemplate/options/createExampleEventData.py index 1f5175b..4a10cdc 100644 --- a/k4ProjectTemplate/options/createExampleEventData.py +++ b/k4ProjectTemplate/options/createExampleEventData.py @@ -18,14 +18,13 @@ # from Gaudi.Configuration import INFO from Configurables import CreateExampleEventData -from k4FWCore import ApplicationMgr -from k4FWCore import IOSvc +from k4FWCore import ApplicationMgr, IOSvc -iosvc = IOSvc("IOSvc") -iosvc.output = "output_k4test_exampledata.root" +iosvc = IOSvc() +iosvc.Output = "output_k4test_exampledata.root" iosvc.outputCommands = ["keep *"] -producer = CreateExampleEventData() +producer = CreateExampleEventData("CreateExampleEventData") ApplicationMgr(TopAlg=[producer], EvtSel="NONE", diff --git a/k4ProjectTemplate/options/createHelloWorld.py b/k4ProjectTemplate/options/createHelloWorld.py index cbfa3b0..2ae8d29 100644 --- a/k4ProjectTemplate/options/createHelloWorld.py +++ b/k4ProjectTemplate/options/createHelloWorld.py @@ -16,16 +16,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from Gaudi.Configuration import * - +from Gaudi.Configuration import INFO from Configurables import HelloWorldAlg +from k4FWCore import ApplicationMgr + producer = HelloWorldAlg() producer.PerEventPrintMessage = "Hello World !" -from Configurables import ApplicationMgr -ApplicationMgr( TopAlg=[producer], - EvtSel="NONE", - EvtMax=1, - OutputLevel=INFO, - ) - +ApplicationMgr(TopAlg=[producer], + EvtSel="NONE", + EvtMax=1, + OutputLevel=INFO, + ) diff --git a/k4ProjectTemplate/options/readExampleEventData.py b/k4ProjectTemplate/options/readExampleEventData.py index 4974482..ec09a6d 100644 --- a/k4ProjectTemplate/options/readExampleEventData.py +++ b/k4ProjectTemplate/options/readExampleEventData.py @@ -17,23 +17,17 @@ # limitations under the License. # from Gaudi.Configuration import DEBUG -from Configurables import k4DataSvc -from Configurables import CreateExampleEventData -from Configurables import PodioInput -from Configurables import ApplicationMgr +from k4FWCore import ApplicationMgr +from k4FWCore import IOSvc -podioevent = k4DataSvc("EventDataSvc") -podioevent.input = "output_k4test_exampledata.root" -producer = CreateExampleEventData() - -inp = PodioInput("InputReader") -inp.collections = ["ExampleParticles"] - -ApplicationMgr( TopAlg=[inp], - EvtSel="NONE", - EvtMax=100, - ExtSvc=[podioevent], - OutputLevel=DEBUG, - ) +iosvc = IOSvc("IOSvc") +iosvc.input = "output_k4test_exampledata.root" +iosvc.CollectionNames = ["ExampleParticles"] +ApplicationMgr(TopAlg=[], + EvtSel="NONE", + EvtMax=100, + ExtSvc=[iosvc], + OutputLevel=DEBUG, + ) diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp index bfe3f55..cd2c444 100644 --- a/k4ProjectTemplate/src/components/ExampleConsumer.cpp +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -24,11 +24,9 @@ struct ExampleConsumer final : k4FWCore::Consumer { ExampleConsumer(const std::string& name, ISvcLocator* svcLoc) - : Consumer(name, svcLoc, {KeyValues("ExampleConsumerInputLocation", {"/ExampleInt"})}) {} + : Consumer(name, svcLoc, KeyValues("ExampleConsumerInputLocation", {"/ExampleInt"})) {} - void operator()(const edm4hep::MCParticleCollection& input) const override { - info() << "ExampleInt = " << input << endmsg; - } + void operator()(const edm4hep::MCParticleCollection& input) const override { info() << input << endmsg; } }; DECLARE_COMPONENT(ExampleConsumer) diff --git a/k4ProjectTemplate/src/components/ExampleTransformer.cpp b/k4ProjectTemplate/src/components/ExampleTransformer.cpp index 3d659a5..6b9d547 100644 --- a/k4ProjectTemplate/src/components/ExampleTransformer.cpp +++ b/k4ProjectTemplate/src/components/ExampleTransformer.cpp @@ -17,9 +17,10 @@ * limitations under the License. */ -#include "edm4hep/MCParticleCollection.h" #include "k4FWCore/Transformer.h" +#include "edm4hep/MCParticleCollection.h" + #include struct ExampleTransformer final @@ -29,12 +30,8 @@ struct ExampleTransformer final {KeyValues("ExampleTransformerOutputLocation", {"/OutputExampleInt"})}) {} edm4hep::MCParticleCollection operator()(const edm4hep::MCParticleCollection& input) const override { - info() << "ExampleInt = " << input << endmsg; - auto out = edm4hep::MCParticleCollection(); - for (const auto& mc : input) { - out.push_back(mc); - } - return out; + info() << input << endmsg; + return edm4hep::MCParticleCollection(); } };