LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SmallClusterFilter_module.cc
Go to the documentation of this file.
1 //
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 //
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;
44  std::vector<std::size_t> fMaxHitsByPlane;
45  std::size_t fMaxTotalHits;
46  std::size_t fNPlanes;
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 
66 {
67  auto const& hits = *evt.getValidHandle<std::vector<recob::Hit>>(fHitFinderModuleLabel);
68 
69  mf::LogVerbatim("SmallClusterFilter")
70  << " ++++ Hitsreceived received " << size(hits) << " +++++ ";
71 
72  if (empty(hits)) {
73  mf::LogWarning("SmallClusterFilter") << " no hits received! exiting ";
74  return false;
75  }
76 
77  if (size(hits) > fMaxTotalHits) {
78  mf::LogWarning("SmallClusterFinder") << "Not an empty event, exiting.";
79  return false;
80  }
81 
82  bool collFound = false;
83 
84  std::map<unsigned int, std::size_t> hitsPerPlane;
85 
86  for (auto const& hit : hits) {
87 
88  // Skip crazy hits:
89  if (hit.Integral() > 500) continue;
90 
91  ++hitsPerPlane[hit.WireID().Plane];
92 
93  if (hit.SignalType() == geo::kCollection) collFound = true;
94  }
95 
96  for (unsigned int i = 0; i < fNPlanes; i++) {
97  if (hitsPerPlane[i] > fMaxHitsByPlane[i]) return false;
98  }
99 
100  //check that there is at least 1 hit on collection:
101  return collFound;
102 }
103 
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Declaration of signal hit object.
std::vector< std::size_t > fMaxHitsByPlane
maximum hits on each plane
std::string fHitFinderModuleLabel
label of module making hits
Cluster finding and building.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void hits()
Definition: readHits.C:15
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
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
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.cc:6
TCEvent evt
Definition: DataStructs.cxx:8
art framework interface to geometry description
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
SmallClusterFilter(fhicl::ParameterSet const &pset)
Signal from collection planes.
Definition: geo_types.h:152