FilterNoMCParticles_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file FilterNoMCParticles_module.cc
3 /// \brief Simple EDFilter filter events with no MCParticles
4 ///
5 /// \author echurch@fnal.gov
6 ////////////////////////////////////////////////////////////////////////
7 
8 /// Framework includes
13 #include "fhiclcpp/ParameterSet.h"
14 
15 // LArSoft Includes
17 
18 #include <vector>
19 
20 /// Geant4 interface
21 namespace simfilter {
22 
24  public:
25  explicit FilterNoMCParticles(fhicl::ParameterSet const& pset,
26  art::ProcessingFrame const&);
27 
28  private:
29  bool filter(art::Event&, art::ProcessingFrame const&) override;
31  };
32 
33 } // namespace simfilter
34 
35 namespace simfilter {
36 
37  //-----------------------------------------------------------------------
38  // Constructor
40  art::ProcessingFrame const&)
41  : SharedFilter{pset}
42  , fLArG4ModuleLabel{pset.get<std::string>("LArG4ModuleLabel", "NoLabel")}
43  {
44  async<art::InEvent>();
45  }
46 
47  //-----------------------------------------------------------------------
48  bool
50  {
51  auto const& mcps =
52  *evt.getValidHandle<std::vector<simb::MCParticle>>(fLArG4ModuleLabel);
53  return not mcps.empty();
54  }
55 
56 } // namespace simfilter
57 
std::string string
Definition: nybbler.cc:12
SharedFilter(fhicl::ParameterSet const &pset)
Definition: SharedFilter.h:22
Particle class.
bool filter(art::Event &, art::ProcessingFrame const &) override
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
FilterNoMCParticles(fhicl::ParameterSet const &pset, art::ProcessingFrame const &)
TCEvent evt
Definition: DataStructs.cxx:7
Framework includes.