All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FilterNumberTPCHits_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // FilterNumberTPCHits class
4 //
5 ////////////////////////////////////////////////////////////////////////
6 #include <fstream>
7 
8 /// Framework includes
9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Core/EDFilter.h"
11 #include "art/Framework/Principal/Event.h"
12 #include "canvas/Utilities/InputTag.h"
13 #include "fhiclcpp/ParameterSet.h"
14 #include "messagefacility/MessageLogger/MessageLogger.h"
16 
17 ///filters for events, etc
18 namespace filter
19 {
20 
21  class FilterNumberTPCHits : public art::EDFilter
22  {
23 
24  public:
25  explicit FilterNumberTPCHits(fhicl::ParameterSet const &);
26 
27  bool filter(art::Event &evt) override;
28 
29  private:
30  std::vector<art::InputTag> fHitDataLabelVec;
31  unsigned int fMaximumHits;
32 
33  }; //class FilterNumberTPCHits
34 }
35 
36 ///////////////////////////////////////////////////////
37 
38 filter::FilterNumberTPCHits::FilterNumberTPCHits(fhicl::ParameterSet const &pset)
39  : EDFilter{pset}
40 {
41  fHitDataLabelVec = pset.get<std::vector<art::InputTag>>("HitDataLabelVec", {""});
42  fMaximumHits = pset.get<unsigned int >("MaximumHits", 800000u);
43 
44  return;
45 }
46 
47 bool filter::FilterNumberTPCHits::filter(art::Event &event)
48 {
49  bool filterPass = true;
50 
51  for(auto const& hitDataLabel : fHitDataLabelVec)
52  {
53  auto const& hitData = event.getProduct<std::vector<recob::Hit>>(hitDataLabel);
54 
55 // std::cout << "FilterNumberTPCHits: label: " << hitDataLabel << " has " << hitData.size() << " hits (rejection is " << fMaximumHits << ")" << std::endl;
56 
57  if (hitData.size() > fMaximumHits)
58  {
59  mf::LogInfo log("FilterNumberTPCHits");
60  log << "******************************************************\n" << "Rejecting event for "
61  << "***** " << hitDataLabel << " with " << hitData.size() << " hits ******\n"
62  << "******************************************************";
63 
64  filterPass = false;
65  break;
66  }
67  }
68 
69  return filterPass;
70 }
71 
72 namespace filter
73 {
74 
75  DEFINE_ART_MODULE(FilterNumberTPCHits)
76 
77 } //namespace filt
Declaration of signal hit object.
FilterNumberTPCHits(fhicl::ParameterSet const &)
bool filter(art::Event &evt) override
std::vector< art::InputTag > fHitDataLabelVec
physics filters filter
TCEvent evt
Definition: DataStructs.cxx:8