Skip to content

Commit

Permalink
Converting to Gaudi::Algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Feb 22, 2024
1 parent 0854134 commit f7b7a0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions k4Gen/src/components/GenEventFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
#include "TInterpreter.h"
#include "TGlobal.h"

DECLARE_COMPONENT(GenEventFilter)

GenEventFilter::GenEventFilter(
const std::string& name,
ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
ISvcLocator* svcLoc) : Gaudi::Algorithm(name, svcLoc) {
declareProperty("particles", m_inColl,
"Generated particles to decide on (input)");
}

StatusCode GenEventFilter::initialize() {
{
StatusCode sc = GaudiAlgorithm::initialize();
StatusCode sc = Gaudi::Algorithm::initialize();
if (sc.isFailure()) {
return sc;
}
Expand Down Expand Up @@ -141,7 +140,7 @@ StatusCode GenEventFilter::initialize() {
return StatusCode::SUCCESS;
}

StatusCode GenEventFilter::execute() {
StatusCode GenEventFilter::execute(const EventContext& evtCtx) const {
const edm4hep::MCParticleCollection* inParticles = m_inColl.get();
m_nEventsSeen++;

Expand Down Expand Up @@ -180,5 +179,7 @@ StatusCode GenEventFilter::execute() {
StatusCode GenEventFilter::finalize() {
debug() << "Number of events seen: " << m_nEventsSeen << endmsg;

return GaudiAlgorithm::finalize();
return Gaudi::Algorithm::finalize();
}

DECLARE_COMPONENT(GenEventFilter)
14 changes: 7 additions & 7 deletions k4Gen/src/components/GenEventFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define GENERATION_GENEVENTFILTER_H

// Gaudi
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/Algorithm.h"
class IProperty;
class IIncidentSvc;
class IEventProcessor;
Expand All @@ -23,21 +23,21 @@ namespace edm4hep {
* @author J. Smiesko
*/

class GenEventFilter : public GaudiAlgorithm {
class GenEventFilter : public Gaudi::Algorithm {

public:
/// Constructor
GenEventFilter(const std::string& name, ISvcLocator* svcLoc);
/// Initialize
virtual StatusCode initialize();
/// Execute: Applies the filter
virtual StatusCode execute();
virtual StatusCode execute(const EventContext& evtCtx) const;
/// Finalize
virtual StatusCode finalize();

private:
/// Handle for the MCParticle collection to be read
DataHandle<edm4hep::MCParticleCollection> m_inColl{
mutable DataHandle<edm4hep::MCParticleCollection> m_inColl{
"particles", Gaudi::DataHandle::Reader, this};

/// Rule to filter the events with
Expand All @@ -49,11 +49,11 @@ class GenEventFilter : public GaudiAlgorithm {
this, "filterRulePath", "", "Path to the filter rule file"};

/// Targeted number of events.
size_t m_nEventsTarget;
mutable std::atomic<unsigned int> m_nEventsTarget;
/// Keep track of how many events were already accepted.
size_t m_nEventsAccepted;
mutable std::atomic<unsigned int> m_nEventsAccepted;
/// Keep track of how many events we went through.
size_t m_nEventsSeen;
mutable std::atomic<unsigned int> m_nEventsSeen;
/// Pointer to the property.
SmartIF<IProperty> m_property;
/// Pointer to the incident service.
Expand Down

0 comments on commit f7b7a0e

Please sign in to comment.