Skip to content

Commit

Permalink
Adress comments from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Sep 30, 2023
1 parent 050cff3 commit d01f32f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,27 @@ make install
```

## Implementing algorithms
k4FWCore uses (or will use) `Gaudi::Functional` for executing algorithms. In
`Gaudi::Functional` we have three different base classes that we will use
depending on how may input and output types they take:
k4FWCore uses `Gaudi::Functional` for executing algorithms. There are several
types of algorithms, depending on your use case:
- The `Consumer` takes inputs but no outputs; can be used for reading
- The `Producer` takes outputs but no inputs; can be used for generating
collections or events
- The `Transformer` is the more general one (both the `Consumer` and the
`Producer` are a particular case of this one) and takes both inputs and
outputs

In all cases the implementation process is the same, we'll create a new class
that will implement `operator()`, that is where our algorithm will be. Simple
examples can be found in the test folder for each one of these three. In
addition, there are tests that have either multiple inputs and / or multiple
outputs (like `ExampleFunctionalProducerMultiple`) that can be used as a
template for the more typical case when working with multiple inputs or outputs.
A more complete list of algorithms can be found in
https://lhcb.github.io/DevelopKit/03a-gaudi/, in the `Gaudi::Functional`
section.

In all cases the implementation process is the same: we'll create a new class
that will inherit from one of the previous algorithms. Then, we implement
`operator()`, where our algorithm will be. This `operator()` will return either
a single type (including `void`) or a tuple with multiple types. It will take
one parameter per input. Simple examples can be found in the test folder for
each one of the above-mentioned algorithms. In addition, there are tests that
have either multiple inputs and / or multiple outputs (like
`ExampleFunctionalProducerMultiple`) that can be used as a template for the more
typical case when working with multiple inputs or outputs.

`GaudiAlg` is deprecated and will be removed in future versions of Gaudi.
2 changes: 1 addition & 1 deletion k4FWCore/src/PodioDataSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ PodioDataSvc::PodioDataSvc(const std::string& name, ISvcLocator* svc) : DataSvc(
PodioDataSvc::~PodioDataSvc() {}

const std::string_view PodioDataSvc::getCollectionType(const std::string& collName) {
auto coll = m_eventframe.get(collName);
const auto coll = m_eventframe.get(collName);
if (coll == nullptr) {
error() << "Collection " << collName << " does not exist." << endmsg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ struct ExampleFunctionalConsumerMultiple final
const FloatColl& floatVector,
const ParticleColl& particles, const SimTrackerHitColl& simTrackerHits,
const TrackerHitColl& trackerHits, const TrackColl& tracks) const override {
// if ((floatVector[0] != 125) || (floatVector[1] != 25) || (floatVector[2] != m_event)) {
// fatal() << "Wrong data in floatVector collection";
// }
if ((floatVector[0] != 125) || (floatVector[1] != 25) || (floatVector[2] != m_event)) {
fatal() << "Wrong data in floatVector collection";
}

auto p4 = particles.momentum()[0];
if ((p4.x != m_magicNumberOffset + m_event + 5) || (p4.y != m_magicNumberOffset + 6) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ struct ExampleFunctionalTransformer final
new_particle.setCharge(particle.getCharge() + 10);
new_particle.setTime(particle.getTime() + 10);
new_particle.setMass(particle.getMass() + 10);
// new_particle.
coll_out->push_back(new_particle);
}
return coll_out;
Expand Down

0 comments on commit d01f32f

Please sign in to comment.