SmallClusterFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \file SmallClusterFilter_module.cc
4 //
5 // \author corey.adams@yale.edu
6 //
7 // \brief Filter out events and only keep those with a few hits.
8 /*
9  This filter is meant to search for radioactive decay products in "empty" frames.
10 
11  It will run on microboone, I claim, though it's really meant for argoneut.
12 
13  The algorithm is quite simple, it just makes a cut on the total number of hits (all
14  planes combined) and also a hit on the number of hits in each individual plane. Both
15  of those numbers are parameters from the .fcl file filters.fcl.
16  -Corey
17 */
18 //
19 //
20 ///////////////////////////////////////////////////////////////////////
21 
22 // include the proper bit of the framework
29 
33 
34 namespace cluster {
35 
37  public:
38  explicit SmallClusterFilter(fhicl::ParameterSet const& pset);
39 
40  private:
41  bool filter(art::Event& evt) override;
42 
43  std::string fHitFinderModuleLabel; ///< label of module making hits
44  std::vector<std::size_t> fMaxHitsByPlane; ///< maximum hits on each plane
45  std::size_t fMaxTotalHits; ///< maximum number of hits allowed
46  std::size_t fNPlanes; ///< number of planes
47  };
48 
49 }
50 
52  : EDFilter{pset}
53  , fHitFinderModuleLabel{pset.get<std::string>("HitFinderModuleLabel")}
54  , fMaxHitsByPlane{pset.get<std::vector<std::size_t>>("MaxHitsByPlane")}
55  , fMaxTotalHits{pset.get<std::size_t>("MaxTotalHits")}
57 {
58  if (size(fMaxHitsByPlane) != fNPlanes) {
60  << "Mismatch in number of planes specified in 'MaxHitsByPlane' (" << size(fMaxHitsByPlane)
61  << ") and the number of planes (" << fNPlanes << ")\n";
62  }
63 }
64 
65 bool
67 {
68  auto const& hits = *evt.getValidHandle<std::vector<recob::Hit>>(fHitFinderModuleLabel);
69 
70  mf::LogVerbatim("SmallClusterFilter")
71  << " ++++ Hitsreceived received " << size(hits) << " +++++ ";
72 
73  if (empty(hits)) {
74  mf::LogWarning("SmallClusterFilter") << " no hits received! exiting ";
75  return false;
76  }
77 
78  if (size(hits) > fMaxTotalHits) {
79  mf::LogWarning("SmallClusterFinder") << "Not an empty event, exiting.";
80  return false;
81  }
82 
83  bool collFound = false;
84 
85  std::map<unsigned int, std::size_t> hitsPerPlane;
86 
87  for (auto const& hit : hits) {
88 
89  // Skip crazy hits:
90  if (hit.Integral() > 500) continue;
91 
92  ++hitsPerPlane[hit.WireID().Plane];
93 
94  if (hit.SignalType() == geo::kCollection) collFound = true;
95 
96  }
97 
98  for (unsigned int i = 0; i < fNPlanes; i++) {
99  if (hitsPerPlane[i] > fMaxHitsByPlane[i]) return false;
100  }
101 
102  //check that there is at least 1 hit on collection:
103  return collFound;
104 }
105 
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::string string
Definition: nybbler.cc:12
std::vector< std::size_t > fMaxHitsByPlane
maximum hits on each plane
std::string fHitFinderModuleLabel
label of module making hits
Cluster finding and building.
art framework interface to geometry description
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
std::size_t fMaxTotalHits
maximum number of hits allowed
bool filter(art::Event &evt) override
std::size_t fNPlanes
number of planes
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Declaration of signal hit object.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:21
TCEvent evt
Definition: DataStructs.cxx:7
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
SmallClusterFilter(fhicl::ParameterSet const &pset)
Signal from collection planes.
Definition: geo_types.h:146