Skip to content

Commit

Permalink
Saving filter stats to the metadata (#32)
Browse files Browse the repository at this point in the history
* Saving filter stats to file

* Removing cstdint

* using edm4hep contants header
  • Loading branch information
kjvbrt authored Sep 18, 2024
1 parent 3d7923a commit fe1623d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions k4Gen/src/components/GenEventFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
30 changes: 17 additions & 13 deletions k4Gen/src/components/GenEventFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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<edm4hep::MCParticleCollection> m_inColl{
"particles", Gaudi::DataHandle::Reader, this};
/// Writes out filter statistics.
MetaDataHandle<std::vector<int>> m_evtFilterStats{
edm4hep::EventFilterStats, Gaudi::DataHandle::Writer};

/// Rule to filter the events with
/// Rule to filter the events with.
Gaudi::Property<std::string> 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<std::string> m_filterRulePath{
this, "filterRulePath", "", "Path to the filter rule file"};

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

0 comments on commit fe1623d

Please sign in to comment.