Skip to content

Commit

Permalink
Don't link to GaudiAlg, update to the functional algorithms and IOSvc
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Aug 2, 2024
1 parent b6568a2 commit 121e7df
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 60 deletions.
1 change: 0 additions & 1 deletion k4ProjectTemplate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ file(GLOB _plugin_sources src/components/*.cpp)
gaudi_add_module(k4ProjectTemplatePlugins
SOURCES ${_plugin_sources}
LINK Gaudi::GaudiKernel
Gaudi::GaudiAlgLib
k4FWCore::k4FWCore
EDM4HEP::edm4hep
)
Expand Down
16 changes: 6 additions & 10 deletions k4ProjectTemplate/options/createExampleEventData.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@
#
from Gaudi.Configuration import INFO
from Configurables import CreateExampleEventData
from Configurables import PodioOutput
from Configurables import ApplicationMgr
from Configurables import k4DataSvc
from k4FWCore import ApplicationMgr, IOSvc

podioevent = k4DataSvc("EventDataSvc")
iosvc = IOSvc()
iosvc.Output = "output_k4test_exampledata.root"
iosvc.outputCommands = ["keep *"]

producer = CreateExampleEventData()

out = PodioOutput("out")
out.filename = "output_k4test_exampledata.root"
out.outputCommands = ["keep *"]

ApplicationMgr(TopAlg=[producer, out],
ApplicationMgr(TopAlg=[producer],
EvtSel="NONE",
EvtMax=100,
ExtSvc=[podioevent],
ExtSvc=[iosvc],
OutputLevel=INFO,
)
17 changes: 8 additions & 9 deletions k4ProjectTemplate/options/createHelloWorld.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
28 changes: 11 additions & 17 deletions k4ProjectTemplate/options/readExampleEventData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
9 changes: 3 additions & 6 deletions k4ProjectTemplate/src/components/CreateExampleEventData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@
*/

#include "Gaudi/Property.h"
#include "GaudiAlg/Producer.h"

// Define BaseClass_t
#include "k4FWCore/BaseClass.h"
#include "k4FWCore/Producer.h"

#include "edm4hep/MCParticleCollection.h"

#include <string>

struct CreateExampleEventData final : Gaudi::Functional::Producer<edm4hep::MCParticleCollection(), BaseClass_t> {
struct CreateExampleEventData final : k4FWCore::Producer<edm4hep::MCParticleCollection()> {
CreateExampleEventData(const std::string& name, ISvcLocator* svcLoc)
: Producer(name, svcLoc, KeyValue("OutputLocation", "ExampleParticles")) {}
: Producer(name, svcLoc, {}, KeyValues("OutputLocation", {"ExampleParticles"})) {}

edm4hep::MCParticleCollection operator()() const override {
auto coll = edm4hep::MCParticleCollection();
Expand Down
12 changes: 5 additions & 7 deletions k4ProjectTemplate/src/components/ExampleConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@
* limitations under the License.
*/

#include "Gaudi/Property.h"
#include "GaudiAlg/Consumer.h"
#include "k4FWCore/Consumer.h"

// Define BaseClass_t
#include "k4FWCore/BaseClass.h"
#include "edm4hep/MCParticleCollection.h"

#include <string>

struct ExampleConsumer final : Gaudi::Functional::Consumer<void(const int&), BaseClass_t> {
struct ExampleConsumer final : k4FWCore::Consumer<void(const edm4hep::MCParticleCollection&)> {
ExampleConsumer(const std::string& name, ISvcLocator* svcLoc)
: Consumer(name, svcLoc, KeyValue("ExampleConsumerInputLocation", "/ExampleInt")) {}
: Consumer(name, svcLoc, KeyValues("ExampleConsumerInputLocation", {"/ExampleInt"})) {}

void operator()(const int& input) const override { info() << "ExampleInt = " << input << endmsg; }
void operator()(const edm4hep::MCParticleCollection& input) const override { info() << input << endmsg; }
};

DECLARE_COMPONENT(ExampleConsumer)
18 changes: 8 additions & 10 deletions k4ProjectTemplate/src/components/ExampleTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@
* limitations under the License.
*/

#include "Gaudi/Property.h"
#include "GaudiAlg/Transformer.h"
#include "k4FWCore/Transformer.h"

// Define BaseClass_t
#include "k4FWCore/BaseClass.h"
#include "edm4hep/MCParticleCollection.h"

#include <string>

struct ExampleTransformer final : Gaudi::Functional::Transformer<int(const int&), BaseClass_t> {
struct ExampleTransformer final : k4FWCore::Transformer<edm4hep::MCParticleCollection(const edm4hep::MCParticleCollection&)> {
ExampleTransformer(const std::string& name, ISvcLocator* svcLoc)
: Transformer(name, svcLoc, KeyValue("ExampleTransformerInputLocation", "/InputExampleInt"),
{KeyValue("ExampleTransformerOutputLocation", "/OutputExampleInt")}) {}
: Transformer(name, svcLoc, {KeyValues("ExampleTransformerInputLocation", {"/InputExampleInt"})},
{KeyValues("ExampleTransformerOutputLocation", {"/OutputExampleInt"})}) {}

int operator()(const int& input) const override {
info() << "ExampleInt = " << input << endmsg;
return input + 1;
edm4hep::MCParticleCollection operator()(const edm4hep::MCParticleCollection& input) const override {
info() << input << endmsg;
return edm4hep::MCParticleCollection();
}
};

Expand Down

0 comments on commit 121e7df

Please sign in to comment.