Skip to content

Commit e7612eb

Browse files
authored
Update algorithms and README, don't link to GaudiAlgLib, update tests (#22)
1 parent d57e90a commit e7612eb

File tree

6 files changed

+38
-41
lines changed

6 files changed

+38
-41
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# k4-project-template
22

33

4-
This repository can be a starting point and template for projects using the Key4HEP software stack.
4+
This repository can be a starting point and template for projects using the Key4hep software stack, in particular those writing Gaudi algorithms.
55

66

77
## Dependencies
@@ -16,13 +16,15 @@ This repository can be a starting point and template for projects using the Key4
1616

1717
## Installation
1818

19+
Run, from the `k4-project-template` directory:
1920

2021
``` bash
2122
source /cvmfs/sw.hsf.org/key4hep/setup.sh
22-
mkdir build install
23-
cd build;
24-
cmake .. -DCMAKE_INSTALL_PREFIX=../install
25-
make install
23+
k4_local_repo
24+
mkdir build
25+
cd build
26+
cmake .. -DCMAKE_INSTALL_PREFIX=../install -G Ninja
27+
ninja install
2628
```
2729

2830
Alternatively you can source the nightlies instead of the releases:
@@ -48,7 +50,8 @@ issue](https://github.com/key4hep/k4-project-template/issues/new/choose).
4850
## Execute Examples
4951

5052
Make sure that `../install/lib` and `../install/python` are in `LD_LIBRARY_PATH`
51-
and `PYTHONPATH` respectively, by doing:
53+
and `PYTHONPATH` respectively (`k4_local_repo` should take care of this).
54+
If they are not, they can be added by running:
5255
``` bash
5356
export LD_LIBRARY_PATH=$PWD/../install/lib:$LD_LIBRARY_PATH
5457
export PYTHONPATH=$PWD/../install/python:$PYTHONPATH

k4ProjectTemplate/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ file(GLOB _plugin_sources src/components/*.cpp)
2121
gaudi_add_module(k4ProjectTemplatePlugins
2222
SOURCES ${_plugin_sources}
2323
LINK Gaudi::GaudiKernel
24-
Gaudi::GaudiAlgLib
2524
k4FWCore::k4FWCore
2625
EDM4HEP::edm4hep
2726
)

k4ProjectTemplate/options/createExampleEventData.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,18 @@
1818
#
1919
from Gaudi.Configuration import INFO
2020
from Configurables import CreateExampleEventData
21-
from Configurables import PodioOutput
22-
from Configurables import ApplicationMgr
23-
from Configurables import k4DataSvc
21+
from k4FWCore import ApplicationMgr
22+
from k4FWCore import IOSvc
2423

25-
podioevent = k4DataSvc("EventDataSvc")
24+
iosvc = IOSvc("IOSvc")
25+
iosvc.output = "output_k4test_exampledata.root"
26+
iosvc.outputCommands = ["keep *"]
2627

2728
producer = CreateExampleEventData()
2829

29-
out = PodioOutput("out")
30-
out.filename = "output_k4test_exampledata.root"
31-
out.outputCommands = ["keep *"]
32-
33-
ApplicationMgr(TopAlg=[producer, out],
30+
ApplicationMgr(TopAlg=[producer],
3431
EvtSel="NONE",
3532
EvtMax=100,
36-
ExtSvc=[podioevent],
33+
ExtSvc=[iosvc],
3734
OutputLevel=INFO,
3835
)

k4ProjectTemplate/src/components/CreateExampleEventData.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@
1818
*/
1919

2020
#include "Gaudi/Property.h"
21-
#include "GaudiAlg/Producer.h"
22-
23-
// Define BaseClass_t
24-
#include "k4FWCore/BaseClass.h"
21+
#include "k4FWCore/Producer.h"
2522

2623
#include "edm4hep/MCParticleCollection.h"
2724

2825
#include <string>
2926

30-
struct CreateExampleEventData final : Gaudi::Functional::Producer<edm4hep::MCParticleCollection(), BaseClass_t> {
27+
struct CreateExampleEventData final : k4FWCore::Producer<edm4hep::MCParticleCollection()> {
3128
CreateExampleEventData(const std::string& name, ISvcLocator* svcLoc)
32-
: Producer(name, svcLoc, KeyValue("OutputLocation", "ExampleParticles")) {}
29+
: Producer(name, svcLoc, {}, KeyValues("OutputLocation", {"ExampleParticles"})) {}
3330

3431
edm4hep::MCParticleCollection operator()() const override {
3532
auto coll = edm4hep::MCParticleCollection();

k4ProjectTemplate/src/components/ExampleConsumer.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@
1717
* limitations under the License.
1818
*/
1919

20-
#include "Gaudi/Property.h"
21-
#include "GaudiAlg/Consumer.h"
22-
23-
// Define BaseClass_t
24-
#include "k4FWCore/BaseClass.h"
20+
#include "edm4hep/MCParticleCollection.h"
21+
#include "k4FWCore/Consumer.h"
2522

2623
#include <string>
2724

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

32-
void operator()(const int& input) const override { info() << "ExampleInt = " << input << endmsg; }
29+
void operator()(const edm4hep::MCParticleCollection& input) const override {
30+
info() << "ExampleInt = " << input << endmsg;
31+
}
3332
};
3433

3534
DECLARE_COMPONENT(ExampleConsumer)

k4ProjectTemplate/src/components/ExampleTransformer.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@
1717
* limitations under the License.
1818
*/
1919

20-
#include "Gaudi/Property.h"
21-
#include "GaudiAlg/Transformer.h"
22-
23-
// Define BaseClass_t
24-
#include "k4FWCore/BaseClass.h"
20+
#include "edm4hep/MCParticleCollection.h"
21+
#include "k4FWCore/Transformer.h"
2522

2623
#include <string>
2724

28-
struct ExampleTransformer final : Gaudi::Functional::Transformer<int(const int&), BaseClass_t> {
25+
struct ExampleTransformer final
26+
: k4FWCore::Transformer<edm4hep::MCParticleCollection(const edm4hep::MCParticleCollection&)> {
2927
ExampleTransformer(const std::string& name, ISvcLocator* svcLoc)
30-
: Transformer(name, svcLoc, KeyValue("ExampleTransformerInputLocation", "/InputExampleInt"),
31-
{KeyValue("ExampleTransformerOutputLocation", "/OutputExampleInt")}) {}
28+
: Transformer(name, svcLoc, {KeyValues("ExampleTransformerInputLocation", {"/InputExampleInt"})},
29+
{KeyValues("ExampleTransformerOutputLocation", {"/OutputExampleInt"})}) {}
3230

33-
int operator()(const int& input) const override {
31+
edm4hep::MCParticleCollection operator()(const edm4hep::MCParticleCollection& input) const override {
3432
info() << "ExampleInt = " << input << endmsg;
35-
return input + 1;
33+
auto out = edm4hep::MCParticleCollection();
34+
for (const auto& mc : input) {
35+
out.push_back(mc);
36+
}
37+
return out;
3638
}
3739
};
3840

0 commit comments

Comments
 (0)