diff --git a/k4Gen/src/components/GenEventFilter.cpp b/k4Gen/src/components/GenEventFilter.cpp index c0ddc70..ff306ab 100644 --- a/k4Gen/src/components/GenEventFilter.cpp +++ b/k4Gen/src/components/GenEventFilter.cpp @@ -179,6 +179,8 @@ StatusCode GenEventFilter::execute(const EventContext& evtCtx) const { StatusCode GenEventFilter::finalize() { debug() << "Number of events seen: " << m_nEventsSeen << endmsg; + m_evtFilterStats.put({m_nEventsSeen, m_nEventsAccepted, m_nEventsTarget}); + return Gaudi::Algorithm::finalize(); } diff --git a/k4Gen/src/components/GenEventFilter.h b/k4Gen/src/components/GenEventFilter.h index 7db6e34..dbf9401 100644 --- a/k4Gen/src/components/GenEventFilter.h +++ b/k4Gen/src/components/GenEventFilter.h @@ -9,11 +9,12 @@ class IEventProcessor; // k4FWCore #include "k4FWCore/DataHandle.h" +#include "k4FWCore/MetaDataHandle.h" // Datamodel -namespace edm4hep { - class MCParticleCollection; -} +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/Constants.h" + /** @class GenEventFilter Generation/src/components/GenEventFilter.h GenEventFilter.h * @@ -26,34 +27,37 @@ namespace edm4hep { class GenEventFilter : public Gaudi::Algorithm { public: - /// Constructor + /// Constructor. GenEventFilter(const std::string& name, ISvcLocator* svcLoc); - /// Initialize + /// Initialize. virtual StatusCode initialize(); - /// Execute: Applies the filter + /// Execute: Applies the filter. virtual StatusCode execute(const EventContext& evtCtx) const; - /// Finalize + /// Finalize. virtual StatusCode finalize(); private: - /// Handle for the MCParticle collection to be read + /// Handle for the MCParticle collection to be read. mutable DataHandle m_inColl{ "particles", Gaudi::DataHandle::Reader, this}; + /// Writes out filter statistics. + MetaDataHandle> m_evtFilterStats{ + edm4hep::EventFilterStats, Gaudi::DataHandle::Writer}; - /// Rule to filter the events with + /// Rule to filter the events with. Gaudi::Property m_filterRuleStr{ this, "filterRule", "", "Filter rule to apply on the events"}; - /// Path of the filter rule file + /// Path of the filter rule file. Gaudi::Property m_filterRulePath{ this, "filterRulePath", "", "Path to the filter rule file"}; /// Targeted number of events. - mutable std::atomic m_nEventsTarget; + mutable std::atomic m_nEventsTarget; /// Keep track of how many events were already accepted. - mutable std::atomic m_nEventsAccepted; + mutable std::atomic m_nEventsAccepted; /// Keep track of how many events we went through. - mutable std::atomic m_nEventsSeen; + mutable std::atomic m_nEventsSeen; /// Pointer to the property. SmartIF m_property; /// Pointer to the incident service.