From 38743f664652d5b902158acd023019be5fc43e82 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 15:28:10 +0200 Subject: [PATCH 01/22] Add an example producer --- .../src/components/ExampleProducer.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 k4ProjectTemplate/src/components/ExampleProducer.cpp diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp new file mode 100644 index 0000000..d2cf5b1 --- /dev/null +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -0,0 +1,23 @@ +#include "Gaudi/Property.h" +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiAlg/Producer.h" + +#include + +using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; + +struct ExampleProducer final : Gaudi::Functional::Producer { + + ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) + : Producer( name, svcLoc, KeyValue( "OutputLocation", m_outputLocation ) ) {} + + int operator()() const override { + return m_exampleInt; + } + + Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt"}; + Gaudi::Property m_exampleInt{this, "ExampleInt", 3}; + +}; + +DECLARE_COMPONENT(ExampleProducer) From 69180b7bc1f92fd9c7815b732ab15e15b4628563 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 15:34:38 +0200 Subject: [PATCH 02/22] Add comments --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index d2cf5b1..d8ba96b 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -15,8 +15,10 @@ struct ExampleProducer final : Gaudi::Functional::Producer { return m_exampleInt; } - Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt"}; - Gaudi::Property m_exampleInt{this, "ExampleInt", 3}; + Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", + "Location of the ExampleInt"}; + Gaudi::Property m_exampleInt{this, "ExampleInt", 3, + "Example int to be produced"}; }; From 1af625e7d999320aaa181848db83c5486f103fa8 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 15:35:15 +0200 Subject: [PATCH 03/22] Change to c_str --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index d8ba96b..2a72a89 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -9,7 +9,7 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; struct ExampleProducer final : Gaudi::Functional::Producer { ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) - : Producer( name, svcLoc, KeyValue( "OutputLocation", m_outputLocation ) ) {} + : Producer( name, svcLoc, KeyValue( "OutputLocation", m_outputLocation.c_str() ) ) {} int operator()() const override { return m_exampleInt; From a4a5ed9310afb5dee47516d63a74e46501e59bec Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 15:35:57 +0200 Subject: [PATCH 04/22] Try --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 2a72a89..2599c1c 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -9,7 +9,7 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; struct ExampleProducer final : Gaudi::Functional::Producer { ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) - : Producer( name, svcLoc, KeyValue( "OutputLocation", m_outputLocation.c_str() ) ) {} + : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} int operator()() const override { return m_exampleInt; From 67d05a10fa09ac5f9737feb75b1f7ad6446964c1 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 15:39:10 +0200 Subject: [PATCH 05/22] up --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 2599c1c..0ed94eb 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -6,7 +6,7 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; -struct ExampleProducer final : Gaudi::Functional::Producer { +class ExampleProducer final : Gaudi::Functional::Producer { ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} @@ -15,6 +15,7 @@ struct ExampleProducer final : Gaudi::Functional::Producer { return m_exampleInt; } +private: Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", "Location of the ExampleInt"}; Gaudi::Property m_exampleInt{this, "ExampleInt", 3, From 18d164853e6769fe908d5c7812f101d39e984734 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 15:49:15 +0200 Subject: [PATCH 06/22] Up --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 0ed94eb..6f134f5 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -6,7 +6,8 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; -class ExampleProducer final : Gaudi::Functional::Producer { +class ExampleProducer final : public Gaudi::Functional::Producer { +public: ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} @@ -15,7 +16,6 @@ class ExampleProducer final : Gaudi::Functional::Producer { return m_exampleInt; } -private: Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", "Location of the ExampleInt"}; Gaudi::Property m_exampleInt{this, "ExampleInt", 3, From 974491f2f5e4bfe5b918e6f83aa09679c4fece0c Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 15:57:49 +0200 Subject: [PATCH 07/22] Add an example consumer --- .../src/components/ExampleConsumer.cpp | 23 +++++++++++++++++++ .../src/components/ExampleProducer.cpp | 3 +-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 k4ProjectTemplate/src/components/ExampleConsumer.cpp diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp new file mode 100644 index 0000000..4187d9e --- /dev/null +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -0,0 +1,23 @@ +#include "Gaudi/Property.h" +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiAlg/Consumer.h" + +#include + +using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; + +struct ExampleConsumer final : Gaudi::Functional::Consumer { + + ExampleConsumer( const std::string& name, ISvcLocator* svcLoc ) + : Consumer( name, svcLoc, KeyValue( "InputLocation", "/ExampleInt" ) ) {} + + void operator()() const override { + info() << "ExampleInt = " << m_exampleInt << endmsg; + } + + Gaudi::Property m_outputLocation{this, "InputLocation", "/ExampleInt", + "Location of the ExampleInt"}; + +}; + +DECLARE_COMPONENT(ExampleConsumer) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 6f134f5..2599c1c 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -6,8 +6,7 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; -class ExampleProducer final : public Gaudi::Functional::Producer { -public: +struct ExampleProducer final : Gaudi::Functional::Producer { ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} From 2452042254ca4b11c33a62b7ecd3511b256a3096 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 16:00:37 +0200 Subject: [PATCH 08/22] Update --- k4ProjectTemplate/src/components/ExampleConsumer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp index 4187d9e..ceb7e3b 100644 --- a/k4ProjectTemplate/src/components/ExampleConsumer.cpp +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -6,13 +6,13 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; -struct ExampleConsumer final : Gaudi::Functional::Consumer { +struct ExampleConsumer final : Gaudi::Functional::Consumer { ExampleConsumer( const std::string& name, ISvcLocator* svcLoc ) : Consumer( name, svcLoc, KeyValue( "InputLocation", "/ExampleInt" ) ) {} - void operator()() const override { - info() << "ExampleInt = " << m_exampleInt << endmsg; + void operator()(const int& input) const override { + info() << "ExampleInt = " << input << endmsg; } Gaudi::Property m_outputLocation{this, "InputLocation", "/ExampleInt", From eb6d0ab045140acb2f9b99cb05c5bbdcb08d6f77 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 16:02:00 +0200 Subject: [PATCH 09/22] Fix names --- k4ProjectTemplate/src/components/ExampleConsumer.cpp | 4 ++-- k4ProjectTemplate/src/components/ExampleProducer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp index ceb7e3b..88a36bf 100644 --- a/k4ProjectTemplate/src/components/ExampleConsumer.cpp +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -9,13 +9,13 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; struct ExampleConsumer final : Gaudi::Functional::Consumer { ExampleConsumer( const std::string& name, ISvcLocator* svcLoc ) - : Consumer( name, svcLoc, KeyValue( "InputLocation", "/ExampleInt" ) ) {} + : Consumer( name, svcLoc, KeyValue( "ExampleConsumerInputLocation", "/ExampleInt" ) ) {} void operator()(const int& input) const override { info() << "ExampleInt = " << input << endmsg; } - Gaudi::Property m_outputLocation{this, "InputLocation", "/ExampleInt", + Gaudi::Property m_inputLocation{this, "ExampleConsumerInputLocation", "/ExampleInt", "Location of the ExampleInt"}; }; diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 2599c1c..da04f71 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -9,13 +9,13 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; struct ExampleProducer final : Gaudi::Functional::Producer { ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) - : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} + : Producer( name, svcLoc, KeyValue( "ExampleProducerOutputLocation", "/ExampleInt" ) ) {} int operator()() const override { return m_exampleInt; } - Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", + Gaudi::Property m_outputLocation{this, "ExampleProducerOutputLocation", "/ExampleInt", "Location of the ExampleInt"}; Gaudi::Property m_exampleInt{this, "ExampleInt", 3, "Example int to be produced"}; From 53e9ebd65b9993f9f998778aaed75addd898281b Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 16:43:42 +0200 Subject: [PATCH 10/22] Up --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index da04f71..2599c1c 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -9,13 +9,13 @@ using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; struct ExampleProducer final : Gaudi::Functional::Producer { ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) - : Producer( name, svcLoc, KeyValue( "ExampleProducerOutputLocation", "/ExampleInt" ) ) {} + : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} int operator()() const override { return m_exampleInt; } - Gaudi::Property m_outputLocation{this, "ExampleProducerOutputLocation", "/ExampleInt", + Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", "Location of the ExampleInt"}; Gaudi::Property m_exampleInt{this, "ExampleInt", 3, "Example int to be produced"}; From 535e81107ece1b879b5a8974f3aebe9a9351521c Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 16:49:23 +0200 Subject: [PATCH 11/22] Comment --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 2599c1c..9aeff2a 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -15,10 +15,10 @@ struct ExampleProducer final : Gaudi::Functional::Producer { return m_exampleInt; } - Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", - "Location of the ExampleInt"}; - Gaudi::Property m_exampleInt{this, "ExampleInt", 3, - "Example int to be produced"}; + // Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", + // "Location of the ExampleInt"}; + // Gaudi::Property m_exampleInt{this, "ExampleInt", 3, + // "Example int to be produced"}; }; From 94ad6e9039a0cde37bbf97af2c6491ab1e81b3ec Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 16:50:46 +0200 Subject: [PATCH 12/22] Up --- k4ProjectTemplate/src/components/ExampleProducer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 9aeff2a..7076808 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -12,13 +12,12 @@ struct ExampleProducer final : Gaudi::Functional::Producer { : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} int operator()() const override { + info() << "Producing ExampleInt = " << m_exampleInt << endmsg; return m_exampleInt; } - // Gaudi::Property m_outputLocation{this, "OutputLocation", "/ExampleInt", - // "Location of the ExampleInt"}; - // Gaudi::Property m_exampleInt{this, "ExampleInt", 3, - // "Example int to be produced"}; + Gaudi::Property m_exampleInt{this, "ExampleInt", 3, + "Example int to be produced"}; }; From 65034b68ddabec88b6d2ee201afa2b589c1b6212 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 9 Jul 2023 16:56:52 +0200 Subject: [PATCH 13/22] Add script to run the producer --- k4ProjectTemplate/options/runExampleProducer.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 k4ProjectTemplate/options/runExampleProducer.py diff --git a/k4ProjectTemplate/options/runExampleProducer.py b/k4ProjectTemplate/options/runExampleProducer.py new file mode 100644 index 0000000..d86e106 --- /dev/null +++ b/k4ProjectTemplate/options/runExampleProducer.py @@ -0,0 +1,13 @@ +from Gaudi.Configuration import * +from Configurables import ExampleProducer +from Configurables import EvtStoreSvc +from Configurables import ApplicationMgr + +producer = ExampleProducer("ExampleProducer", OutputLocation="/ExampleInt", ExampleInt=5) + +ApplicationMgr( TopAlg=[producer], + EvtSel="NONE", + EvtMax=10, + ExtSvc=[EvtStoreSvc("EventDataSvc")], + OutputLevel=INFO, + ) From 0681ed0a7766431268615928182bca33f04a4189 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 15:23:07 +0200 Subject: [PATCH 14/22] Add an example producer and consumer --- .../src/components/ExampleConsumer.cpp | 25 ++++++++++++++++--- .../src/components/ExampleProducer.cpp | 25 ++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp index 88a36bf..1ae8183 100644 --- a/k4ProjectTemplate/src/components/ExampleConsumer.cpp +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -1,10 +1,29 @@ +/* + * Copyright (c) 2014-2023 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. + */ + #include "Gaudi/Property.h" -#include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiAlg/Consumer.h" -#include +// Define BaseClass_t +#include "k4FWCore/BaseClass.h" -using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; +#include struct ExampleConsumer final : Gaudi::Functional::Consumer { diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 7076808..4ee17f4 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -1,10 +1,29 @@ +/* + * Copyright (c) 2014-2023 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. + */ + #include "Gaudi/Property.h" -#include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiAlg/Producer.h" -#include +// Define BaseClass_t +#include "k4FWCore/BaseClass.h" -using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t; +#include struct ExampleProducer final : Gaudi::Functional::Producer { From caee68c59e77fce9d83b8330e1a8fdc75ce8c782 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 15:26:24 +0200 Subject: [PATCH 15/22] Add an example transformer --- .../src/components/ExampleTransformer.cpp | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 k4ProjectTemplate/src/components/ExampleTransformer.cpp diff --git a/k4ProjectTemplate/src/components/ExampleTransformer.cpp b/k4ProjectTemplate/src/components/ExampleTransformer.cpp new file mode 100644 index 0000000..749d6c8 --- /dev/null +++ b/k4ProjectTemplate/src/components/ExampleTransformer.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014-2023 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. + */ + +#include "Gaudi/Property.h" +#include "GaudiAlg/Transformer.h" + +// Define BaseClass_t +#include "k4FWCore/BaseClass.h" + +#include + +struct ExampleTransformer final : Gaudi::Functional::Transformer { + + ExampleTransformer( const std::string& name, ISvcLocator* svcLoc ) + : Transformer( name, svcLoc, + KeyValue( "ExampleTransformerInputLocation", "/InputExampleInt" ), + {KeyValue( "ExampleTransformerOutputLocation", "/OutputExampleInt")} {} + + int operator()(const int& input) const override { + info() << "ExampleInt = " << input << endmsg; + return input + 1; + } + + Gaudi::Property m_inputLocation{this, "ExampleConsumerInputLocation", "/ExampleInt", + "Location of the ExampleInt"}; + +}; + +DECLARE_COMPONENT(ExampleTransformer) From edc39c7d527039b18375ad8107cf81b139b43eab Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 15:28:21 +0200 Subject: [PATCH 16/22] Remove unused properties --- k4ProjectTemplate/src/components/ExampleConsumer.cpp | 3 --- k4ProjectTemplate/src/components/ExampleTransformer.cpp | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp index 1ae8183..f3f9161 100644 --- a/k4ProjectTemplate/src/components/ExampleConsumer.cpp +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -34,9 +34,6 @@ struct ExampleConsumer final : Gaudi::Functional::Consumer Date: Sun, 8 Oct 2023 15:32:22 +0200 Subject: [PATCH 17/22] Run clang-format --- .../src/components/ExampleConsumer.cpp | 14 +++++--------- .../src/components/ExampleProducer.cpp | 11 ++++------- .../src/components/ExampleTransformer.cpp | 13 +++++-------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp index f3f9161..f922519 100644 --- a/k4ProjectTemplate/src/components/ExampleConsumer.cpp +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -25,15 +25,11 @@ #include -struct ExampleConsumer final : Gaudi::Functional::Consumer { - - ExampleConsumer( const std::string& name, ISvcLocator* svcLoc ) - : Consumer( name, svcLoc, KeyValue( "ExampleConsumerInputLocation", "/ExampleInt" ) ) {} - - void operator()(const int& input) const override { - info() << "ExampleInt = " << input << endmsg; - } +struct ExampleConsumer final : Gaudi::Functional::Consumer { + ExampleConsumer(const std::string& name, ISvcLocator* svcLoc) + : Consumer(name, svcLoc, KeyValue("ExampleConsumerInputLocation", "/ExampleInt")) {} + void operator()(const int& input) const override { info() << "ExampleInt = " << input << endmsg; } }; - + DECLARE_COMPONENT(ExampleConsumer) diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 4ee17f4..7ac9414 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -26,18 +26,15 @@ #include struct ExampleProducer final : Gaudi::Functional::Producer { - - ExampleProducer( const std::string& name, ISvcLocator* svcLoc ) - : Producer( name, svcLoc, KeyValue( "OutputLocation", "/ExampleInt" ) ) {} + ExampleProducer(const std::string& name, ISvcLocator* svcLoc) + : Producer(name, svcLoc, KeyValue("OutputLocation", "/ExampleInt")) {} int operator()() const override { info() << "Producing ExampleInt = " << m_exampleInt << endmsg; return m_exampleInt; } - Gaudi::Property m_exampleInt{this, "ExampleInt", 3, - "Example int to be produced"}; - + Gaudi::Property m_exampleInt{this, "ExampleInt", 3, "Example int to be produced"}; }; - + DECLARE_COMPONENT(ExampleProducer) diff --git a/k4ProjectTemplate/src/components/ExampleTransformer.cpp b/k4ProjectTemplate/src/components/ExampleTransformer.cpp index 649294c..0a7760d 100644 --- a/k4ProjectTemplate/src/components/ExampleTransformer.cpp +++ b/k4ProjectTemplate/src/components/ExampleTransformer.cpp @@ -25,18 +25,15 @@ #include -struct ExampleTransformer final : Gaudi::Functional::Transformer { - - ExampleTransformer( const std::string& name, ISvcLocator* svcLoc ) - : Transformer( name, svcLoc, - KeyValue( "ExampleTransformerInputLocation", "/InputExampleInt" ), - {KeyValue( "ExampleTransformerOutputLocation", "/OutputExampleInt")}) {} +struct ExampleTransformer final : Gaudi::Functional::Transformer { + ExampleTransformer(const std::string& name, ISvcLocator* svcLoc) + : Transformer(name, svcLoc, KeyValue("ExampleTransformerInputLocation", "/InputExampleInt"), + {KeyValue("ExampleTransformerOutputLocation", "/OutputExampleInt")}) {} int operator()(const int& input) const override { info() << "ExampleInt = " << input << endmsg; return input + 1; } - }; - + DECLARE_COMPONENT(ExampleTransformer) From 44c91ed33bfbfd3832aec425d31a15498c658b23 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 15:34:47 +0200 Subject: [PATCH 18/22] Add license to the runExampleProducer.py --- .../options/runExampleProducer.py | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/k4ProjectTemplate/options/runExampleProducer.py b/k4ProjectTemplate/options/runExampleProducer.py index d86e106..0d84fa5 100644 --- a/k4ProjectTemplate/options/runExampleProducer.py +++ b/k4ProjectTemplate/options/runExampleProducer.py @@ -1,13 +1,32 @@ -from Gaudi.Configuration import * +# +# Copyright (c) 2014-2023 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. +# + +from Gaudi.Configuration import INFO from Configurables import ExampleProducer from Configurables import EvtStoreSvc from Configurables import ApplicationMgr producer = ExampleProducer("ExampleProducer", OutputLocation="/ExampleInt", ExampleInt=5) -ApplicationMgr( TopAlg=[producer], - EvtSel="NONE", - EvtMax=10, - ExtSvc=[EvtStoreSvc("EventDataSvc")], - OutputLevel=INFO, - ) +ApplicationMgr(TopAlg=[producer], + EvtSel="NONE", + EvtMax=10, + ExtSvc=[EvtStoreSvc("EventDataSvc")], + OutputLevel=INFO, + ) From a4f504a928d442f91e1990597222b820a39a25c5 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 16:01:11 +0200 Subject: [PATCH 19/22] Fix license headers, move HelloWorldAlg to Gaudi::Algorithm --- .../options/runExampleProducer.py | 2 +- .../src/components/ExampleConsumer.cpp | 2 +- .../src/components/ExampleProducer.cpp | 2 +- .../src/components/ExampleTransformer.cpp | 2 +- .../src/components/HelloWorldAlg.cpp | 8 ++++---- .../src/components/HelloWorldAlg.h | 19 ++++++++----------- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/k4ProjectTemplate/options/runExampleProducer.py b/k4ProjectTemplate/options/runExampleProducer.py index 0d84fa5..02096ad 100644 --- a/k4ProjectTemplate/options/runExampleProducer.py +++ b/k4ProjectTemplate/options/runExampleProducer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2014-2023 Key4hep-Project. +# Copyright (c) 2020-2023 Key4hep-Project. # # This file is part of Key4hep. # See https://key4hep.github.io/key4hep-doc/ for further info. diff --git a/k4ProjectTemplate/src/components/ExampleConsumer.cpp b/k4ProjectTemplate/src/components/ExampleConsumer.cpp index f922519..b3367bb 100644 --- a/k4ProjectTemplate/src/components/ExampleConsumer.cpp +++ b/k4ProjectTemplate/src/components/ExampleConsumer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2023 Key4hep-Project. + * Copyright (c) 2020-2023 Key4hep-Project. * * This file is part of Key4hep. * See https://key4hep.github.io/key4hep-doc/ for further info. diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp index 7ac9414..4b1a439 100644 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ b/k4ProjectTemplate/src/components/ExampleProducer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2023 Key4hep-Project. + * Copyright (c) 2020-2023 Key4hep-Project. * * This file is part of Key4hep. * See https://key4hep.github.io/key4hep-doc/ for further info. diff --git a/k4ProjectTemplate/src/components/ExampleTransformer.cpp b/k4ProjectTemplate/src/components/ExampleTransformer.cpp index 0a7760d..5654b43 100644 --- a/k4ProjectTemplate/src/components/ExampleTransformer.cpp +++ b/k4ProjectTemplate/src/components/ExampleTransformer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2023 Key4hep-Project. + * Copyright (c) 2020-2023 Key4hep-Project. * * This file is part of Key4hep. * See https://key4hep.github.io/key4hep-doc/ for further info. diff --git a/k4ProjectTemplate/src/components/HelloWorldAlg.cpp b/k4ProjectTemplate/src/components/HelloWorldAlg.cpp index d4948df..dbefa66 100644 --- a/k4ProjectTemplate/src/components/HelloWorldAlg.cpp +++ b/k4ProjectTemplate/src/components/HelloWorldAlg.cpp @@ -21,18 +21,18 @@ DECLARE_COMPONENT(HelloWorldAlg) -HelloWorldAlg::HelloWorldAlg(const std::string& aName, ISvcLocator* aSvcLoc) : GaudiAlgorithm(aName, aSvcLoc) {} +HelloWorldAlg::HelloWorldAlg(const std::string& aName, ISvcLocator* aSvcLoc) : Gaudi::Algorithm(aName, aSvcLoc) {} HelloWorldAlg::~HelloWorldAlg() {} StatusCode HelloWorldAlg::initialize() { - if (GaudiAlgorithm::initialize().isFailure()) { + if (Gaudi::Algorithm::initialize().isFailure()) { return StatusCode::FAILURE; } return StatusCode::SUCCESS; } -StatusCode HelloWorldAlg::execute() { +StatusCode HelloWorldAlg::execute(const EventContext& ctx) const { info() << endmsg; info() << endmsg; info() << theMessage << endmsg; @@ -41,4 +41,4 @@ StatusCode HelloWorldAlg::execute() { return StatusCode::SUCCESS; } -StatusCode HelloWorldAlg::finalize() { return GaudiAlgorithm::finalize(); } +StatusCode HelloWorldAlg::finalize() { return Gaudi::Algorithm::finalize(); } diff --git a/k4ProjectTemplate/src/components/HelloWorldAlg.h b/k4ProjectTemplate/src/components/HelloWorldAlg.h index c18a51b..d19d316 100644 --- a/k4ProjectTemplate/src/components/HelloWorldAlg.h +++ b/k4ProjectTemplate/src/components/HelloWorldAlg.h @@ -16,36 +16,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef TESTFWCORE_HELLOWORLDALG -#define TESTFWCORE_HELLOWORLDALG -#pragma once +// Note that in most cases it's better to use the functional +// approach than Gaudi::Algorithm // GAUDI #include "Gaudi/Property.h" -#include "GaudiAlg/GaudiAlgorithm.h" +#include "Gaudi/Algorithm.h" -class HelloWorldAlg : public GaudiAlgorithm { +class HelloWorldAlg : public Gaudi::Algorithm { public: - explicit HelloWorldAlg(const std::string&, ISvcLocator*); + HelloWorldAlg(const std::string&, ISvcLocator*); virtual ~HelloWorldAlg(); /** Initialize. * @return status code */ - virtual StatusCode initialize() final; + StatusCode initialize() override; /** Execute. * @return status code */ - virtual StatusCode execute() final; + StatusCode execute(const EventContext&) const override; /** Finalize. * @return status code */ - virtual StatusCode finalize() final; + StatusCode finalize() override; private: // member variable Gaudi::Property theMessage{this, "PerEventPrintMessage", "Hello ", "The message to printed for each Event"}; }; - -#endif /* TESTFWCORE_HELLOWORLDALG */ From cb6c82e526f0bbdb14946cea5dd7e1efefb22afb Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 16:01:42 +0200 Subject: [PATCH 20/22] Run clang-format --- k4ProjectTemplate/src/components/HelloWorldAlg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k4ProjectTemplate/src/components/HelloWorldAlg.h b/k4ProjectTemplate/src/components/HelloWorldAlg.h index d19d316..e9ffe82 100644 --- a/k4ProjectTemplate/src/components/HelloWorldAlg.h +++ b/k4ProjectTemplate/src/components/HelloWorldAlg.h @@ -21,8 +21,8 @@ // approach than Gaudi::Algorithm // GAUDI -#include "Gaudi/Property.h" #include "Gaudi/Algorithm.h" +#include "Gaudi/Property.h" class HelloWorldAlg : public Gaudi::Algorithm { public: From f82f0cd0f80e6c6c5ee79a8fd88992e1a59e8ef3 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 20:44:39 +0200 Subject: [PATCH 21/22] Improve tests and remove the ones that use the old GaudiAlg --- .../options/createExampleEventData.py | 24 +++--- k4ProjectTemplate/options/eventcounter.py | 36 --------- .../options/readExampleEventData.py | 12 +-- .../options/runExampleProducer.py | 32 -------- .../src/components/CreateExampleEventData.cpp | 57 +++++---------- .../src/components/CreateExampleEventData.h | 73 ------------------- k4ProjectTemplate/src/components/EmptyAlg.cpp | 31 -------- k4ProjectTemplate/src/components/EmptyAlg.h | 45 ------------ .../src/components/ExampleProducer.cpp | 40 ---------- 9 files changed, 36 insertions(+), 314 deletions(-) delete mode 100644 k4ProjectTemplate/options/eventcounter.py delete mode 100644 k4ProjectTemplate/options/runExampleProducer.py delete mode 100644 k4ProjectTemplate/src/components/CreateExampleEventData.h delete mode 100644 k4ProjectTemplate/src/components/EmptyAlg.cpp delete mode 100644 k4ProjectTemplate/src/components/EmptyAlg.h delete mode 100644 k4ProjectTemplate/src/components/ExampleProducer.cpp diff --git a/k4ProjectTemplate/options/createExampleEventData.py b/k4ProjectTemplate/options/createExampleEventData.py index e742d07..ced4f05 100644 --- a/k4ProjectTemplate/options/createExampleEventData.py +++ b/k4ProjectTemplate/options/createExampleEventData.py @@ -16,25 +16,23 @@ # 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 CreateExampleEventData +from Configurables import PodioOutput +from Configurables import ApplicationMgr from Configurables import k4DataSvc + podioevent = k4DataSvc("EventDataSvc") -from Configurables import CreateExampleEventData producer = CreateExampleEventData() -from Configurables import PodioOutput out = PodioOutput("out") out.filename = "output_k4test_exampledata.root" out.outputCommands = ["keep *"] -from Configurables import ApplicationMgr -ApplicationMgr( TopAlg=[producer, out], - EvtSel="NONE", - EvtMax=100, - ExtSvc=[podioevent], - OutputLevel=INFO, - ) - - +ApplicationMgr(TopAlg=[producer, out], + EvtSel="NONE", + EvtMax=100, + ExtSvc=[podioevent], + OutputLevel=INFO, + ) diff --git a/k4ProjectTemplate/options/eventcounter.py b/k4ProjectTemplate/options/eventcounter.py deleted file mode 100644 index cbc7ec3..0000000 --- a/k4ProjectTemplate/options/eventcounter.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (c) 2020-2023 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. -# -from Gaudi.Configuration import * - -from Configurables import k4DataSvc -podioevent = k4DataSvc("EventDataSvc") - -from Configurables import EventCounterExample -eventcounter = EventCounterExample() - - -from Configurables import ApplicationMgr -ApplicationMgr( TopAlg=[eventcounter], - EvtSel="NONE", - EvtMax=100, - ExtSvc=[podioevent], - OutputLevel=DEBUG, - ) - - diff --git a/k4ProjectTemplate/options/readExampleEventData.py b/k4ProjectTemplate/options/readExampleEventData.py index 9875758..4296e26 100644 --- a/k4ProjectTemplate/options/readExampleEventData.py +++ b/k4ProjectTemplate/options/readExampleEventData.py @@ -16,19 +16,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from Gaudi.Configuration import * - +from Gaudi.Configuration import DEBUG from Configurables import k4DataSvc +from Configurables import CreateExampleEventData +from Configurables import PodioInput +from Configurables import ApplicationMgr + podioevent = k4DataSvc("EventDataSvc") podioevent.input = "output_k4test_exampledata.root" -from Configurables import CreateExampleEventData producer = CreateExampleEventData() -from Configurables import PodioInput inp = PodioInput("InputReader") -inp.collections = ["MCParticles", "SimTrackerHit"] +inp.collections = ["ExampleParticles"] -from Configurables import ApplicationMgr ApplicationMgr( TopAlg=[inp], EvtSel="NONE", EvtMax=100, diff --git a/k4ProjectTemplate/options/runExampleProducer.py b/k4ProjectTemplate/options/runExampleProducer.py deleted file mode 100644 index 02096ad..0000000 --- a/k4ProjectTemplate/options/runExampleProducer.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 2020-2023 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. -# - -from Gaudi.Configuration import INFO -from Configurables import ExampleProducer -from Configurables import EvtStoreSvc -from Configurables import ApplicationMgr - -producer = ExampleProducer("ExampleProducer", OutputLocation="/ExampleInt", ExampleInt=5) - -ApplicationMgr(TopAlg=[producer], - EvtSel="NONE", - EvtMax=10, - ExtSvc=[EvtStoreSvc("EventDataSvc")], - OutputLevel=INFO, - ) diff --git a/k4ProjectTemplate/src/components/CreateExampleEventData.cpp b/k4ProjectTemplate/src/components/CreateExampleEventData.cpp index 4b5a402..6ff6bc4 100644 --- a/k4ProjectTemplate/src/components/CreateExampleEventData.cpp +++ b/k4ProjectTemplate/src/components/CreateExampleEventData.cpp @@ -16,49 +16,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "CreateExampleEventData.h" -// datamodel -#include "edm4hep/MCParticleCollection.h" -#include "edm4hep/SimTrackerHitCollection.h" - -DECLARE_COMPONENT(CreateExampleEventData) - -CreateExampleEventData::CreateExampleEventData(const std::string& aName, ISvcLocator* aSvcLoc) - : GaudiAlgorithm(aName, aSvcLoc) { - declareProperty("mcparticles", m_mcParticleHandle, "Dummy Particle collection (output)"); - declareProperty("trackhits", m_simTrackerHitHandle, "Dummy Hit collection (output)"); -} - -CreateExampleEventData::~CreateExampleEventData() {} +#include "Gaudi/Property.h" +#include "GaudiAlg/Producer.h" -StatusCode CreateExampleEventData::initialize() { - if (GaudiAlgorithm::initialize().isFailure()) { - return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; -} - -StatusCode CreateExampleEventData::execute() { - auto* floatVector = m_vectorFloatHandle.createAndPut(); - floatVector->push_back(125.); - floatVector->push_back(25.); +// Define BaseClass_t +#include "k4FWCore/BaseClass.h" - edm4hep::MCParticleCollection* particles = m_mcParticleHandle.createAndPut(); +#include "edm4hep/MCParticleCollection.h" - auto particle = particles->create(); +#include - auto& p4 = particle.momentum(); - p4.x = m_magicNumberOffset + 5; - p4.y = m_magicNumberOffset + 6; - p4.z = m_magicNumberOffset + 7; - particle.setMass(m_magicNumberOffset + 8); +struct CreateExampleEventData final : Gaudi::Functional::Producer { + CreateExampleEventData(const std::string& name, ISvcLocator* svcLoc) + : Producer(name, svcLoc, KeyValue("OutputLocation", "ExampleParticles")) {} - auto* hits = m_simTrackerHitHandle.createAndPut(); - auto hit = hits->create(); - hit.setPosition({3, 4, 5}); + edm4hep::MCParticleCollection operator()() const override { + auto coll = edm4hep::MCParticleCollection(); + auto particle = coll.create(); + particle.setMass(m_exampleEnergy); + info() << "Producing a particle with mass = " << m_exampleEnergy << " GeV" << endmsg; + return coll; + } - return StatusCode::SUCCESS; -} + Gaudi::Property m_exampleEnergy{this, "ExampleEnergy", 3, "Example int to be produced"}; +}; -StatusCode CreateExampleEventData::finalize() { return GaudiAlgorithm::finalize(); } +DECLARE_COMPONENT(CreateExampleEventData) diff --git a/k4ProjectTemplate/src/components/CreateExampleEventData.h b/k4ProjectTemplate/src/components/CreateExampleEventData.h deleted file mode 100644 index cd46c84..0000000 --- a/k4ProjectTemplate/src/components/CreateExampleEventData.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2020-2023 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. - */ -#ifndef TESTFWCORE_CREATEEXAMPLEEVENTDATA -#define TESTFWCORE_CREATEEXAMPLEEVENTDATA - -// GAUDI -#include "GaudiAlg/GaudiAlgorithm.h" - -#include "podio/UserDataCollection.h" - -// edm4hep -#include "TTree.h" -#include "k4FWCore/DataHandle.h" - -// datamodel -namespace edm4hep { - class MCParticleCollection; - class SimTrackerHitCollection; - class SimCaloHit; -} // namespace edm4hep - -/** @class CreateExampleEventData - * Lightweight producer for edm data for tests that do not depend on the actual - * data content and therefore do not need the simulation machinery. - * Fills data members with increasing integers, together with some offset so that different - * events can be easily distinguished. - * - */ -class CreateExampleEventData : public GaudiAlgorithm { -public: - explicit CreateExampleEventData(const std::string&, ISvcLocator*); - virtual ~CreateExampleEventData(); - /** Initialize. - * @return status code - */ - virtual StatusCode initialize() final; - /** Execute. - * @return status code - */ - virtual StatusCode execute() final; - /** Finalize. - * @return status code - */ - virtual StatusCode finalize() final; - -private: - /// integer to add to the dummy values written to the edm - Gaudi::Property m_magicNumberOffset{this, "magicNumberOffset", 0, - "Integer to add to the dummy values written to the edm"}; - /// Handle for the genparticles to be written - DataHandle m_mcParticleHandle{"MCParticles", Gaudi::DataHandle::Writer, this}; - /// Handle for the genvertices to be written - DataHandle m_simTrackerHitHandle{"SimTrackerHit", Gaudi::DataHandle::Writer, this}; - - DataHandle> m_vectorFloatHandle{"VectorFloat", Gaudi::DataHandle::Writer, this}; -}; -#endif /* TESTFWCORE_CREATEEXAMPLEEVENTDATA */ diff --git a/k4ProjectTemplate/src/components/EmptyAlg.cpp b/k4ProjectTemplate/src/components/EmptyAlg.cpp deleted file mode 100644 index 9527a68..0000000 --- a/k4ProjectTemplate/src/components/EmptyAlg.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020-2023 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. - */ -#include "EmptyAlg.h" - -DECLARE_COMPONENT(EmptyAlg) - -EmptyAlg::EmptyAlg(const std::string& aName, ISvcLocator* aSvcLoc) : GaudiAlgorithm(aName, aSvcLoc) {} - -EmptyAlg::~EmptyAlg() {} - -StatusCode EmptyAlg::initialize() { return StatusCode::SUCCESS; } - -StatusCode EmptyAlg::execute() { return StatusCode::SUCCESS; } - -StatusCode EmptyAlg::finalize() { return StatusCode::SUCCESS; } diff --git a/k4ProjectTemplate/src/components/EmptyAlg.h b/k4ProjectTemplate/src/components/EmptyAlg.h deleted file mode 100644 index 61b3bd0..0000000 --- a/k4ProjectTemplate/src/components/EmptyAlg.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020-2023 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. - */ -#pragma once - -// GAUDI -#include "Gaudi/Property.h" -#include "GaudiAlg/GaudiAlgorithm.h" - -class EmptyAlg : public GaudiAlgorithm { -public: - explicit EmptyAlg(const std::string&, ISvcLocator*); - virtual ~EmptyAlg(); - /** Initialize. - * @return status code - */ - virtual StatusCode initialize() final; - /** Execute. - * @return status code - */ - virtual StatusCode execute() final; - /** Finalize. - * @return status code - */ - virtual StatusCode finalize() final; - -private: - // member variable - int m_member = 0; -}; diff --git a/k4ProjectTemplate/src/components/ExampleProducer.cpp b/k4ProjectTemplate/src/components/ExampleProducer.cpp deleted file mode 100644 index 4b1a439..0000000 --- a/k4ProjectTemplate/src/components/ExampleProducer.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020-2023 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. - */ - -#include "Gaudi/Property.h" -#include "GaudiAlg/Producer.h" - -// Define BaseClass_t -#include "k4FWCore/BaseClass.h" - -#include - -struct ExampleProducer final : Gaudi::Functional::Producer { - ExampleProducer(const std::string& name, ISvcLocator* svcLoc) - : Producer(name, svcLoc, KeyValue("OutputLocation", "/ExampleInt")) {} - - int operator()() const override { - info() << "Producing ExampleInt = " << m_exampleInt << endmsg; - return m_exampleInt; - } - - Gaudi::Property m_exampleInt{this, "ExampleInt", 3, "Example int to be produced"}; -}; - -DECLARE_COMPONENT(ExampleProducer) From 42609f8267df8f3a29e74b83d1b12b77f47eb114 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Sun, 8 Oct 2023 20:46:46 +0200 Subject: [PATCH 22/22] Run clang-format --- k4ProjectTemplate/src/components/CreateExampleEventData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k4ProjectTemplate/src/components/CreateExampleEventData.cpp b/k4ProjectTemplate/src/components/CreateExampleEventData.cpp index 6ff6bc4..7052739 100644 --- a/k4ProjectTemplate/src/components/CreateExampleEventData.cpp +++ b/k4ProjectTemplate/src/components/CreateExampleEventData.cpp @@ -32,7 +32,7 @@ struct CreateExampleEventData final : Gaudi::Functional::Producer