ToFFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ToFFilter
3 // Plugin Type: filter (art v2_12_01)
4 // File: ToFFilter_module.cc
5 //
6 // John Rabaey::jrabaey@udallas.edu
7 //
8 // Description: ToF filter module
9 ////////////////////////////////////////////////////////////////////////
10 
18 #include "fhiclcpp/ParameterSet.h"
26 
28 #include "BeamlineRecoBase/ToF.h"
29 #include "RawData/RawBeamline.h"
30 #include "Utilities/AssociationUtil.h"
31 
32 #include <iostream>
33 #include <map>
34 
35 namespace beamlinereco {
36  class ToFFilter : public art::EDFilter {
37  public:
38  explicit ToFFilter(fhicl::ParameterSet const &p);
39 
40  bool filter(art::Event &e);
41  void reconfigure(const fhicl::ParameterSet &p);
42 
43  private:
48  unsigned int fMinToFHitsUS;
49  unsigned int fMaxToFHitsUS;
50  unsigned int fMinToFHitsDS;
51  unsigned int fMaxToFHitsDS;
52  unsigned int fMinToFCount;
53  unsigned int fMaxToFCount;
54  double fMinToF;
55  double fMaxToF;
56 
57  };
58 }
59 
61 {
62  this->reconfigure(p);
63 }
64 
66  fToFDataLabel = pset.get<art::InputTag>("ToFDataLabel");
67  fBeamlineToFDataLabel = pset.get<art::InputTag>("BeamlineToFDataLabel");
68  fFilterOnBeamlineDigits = pset.get<bool>("FilterOnBeamlineDigits");
69  fFilterOnRecoToFs = pset.get<bool>("FilterOnRecoToFs");
70  fMinToFHitsUS = pset.get<unsigned int>("MinToFHitsUS");
71  fMaxToFHitsUS = pset.get<unsigned int>("MaxToFHitsUS");
72  fMinToFHitsDS = pset.get<unsigned int>("MinToFHitsDS");
73  fMaxToFHitsDS = pset.get<unsigned int>("MaxToFHitsDS");
74  fMinToFCount = pset.get<unsigned int>("MinToFCount");
75  fMaxToFCount = pset.get<unsigned int>("MaxToFCount");
76  fMinToF = pset.get<double>("MinToF");
77  fMaxToF = pset.get<double>("MaxToF");
78 }
79 
81 {
82  // Get tof digits
84  std::vector<art::Ptr<brb::BeamlineDigit>> digits;
85  if (e.getByLabel(fBeamlineToFDataLabel, digitHandle)) art::fill_ptr_vector(digits, digitHandle);
86 
87  // Get ToF objects
89  std::vector<art::Ptr<brb::ToF>> tofs;
90  if (e.getByLabel(fToFDataLabel, tofHandle)) art::fill_ptr_vector(tofs, tofHandle);
91 
92  // tof digit filtering
94  // Separate by counter
95  std::vector<art::Ptr<brb::BeamlineDigit>> usDigits;
96  std::vector<art::Ptr<brb::BeamlineDigit>> dsDigits;
97  for (auto d : digits) {
98  if (d->ChannelID().Detector == beamlinegeo::ToFCounter::US) {
99  usDigits.push_back(d);
100  } else if (d->ChannelID().Detector == beamlinegeo::ToFCounter::DS) {
101  dsDigits.push_back(d);
102  }
103  }
104  if (usDigits.size() < fMinToFHitsUS) return false;
105  if (usDigits.size() > fMaxToFHitsUS) return false;
106  if (dsDigits.size() < fMinToFHitsDS) return false;
107  if (dsDigits.size() > fMaxToFHitsDS) return false;
108  }
109 
110  // tof filtering
111  if (fFilterOnRecoToFs) {
112  if(tofs.size() < fMinToFCount) return false;
113  if(tofs.size() > fMaxToFCount) return false;
114 
115  //std::cout << e.id() << ": \n";
116 
117  // Retrieve BeamlineDigits for tof reco
119 
120  //filter out events with bad behavior
121  for (auto tof : tofs) {
122  if (tof->Time() < fMinToF) return false;
123  if (tof->Time() > fMaxToF) return false;
124 
125  // Get associated reco digits
126  //const std::vector<art::Ptr<brb::BeamlineDigit>> tofDigits = fmbd.at(tof.key());
127  }
128  }
129 
130  return true;
131 }
132 
133 
void reconfigure(const fhicl::ParameterSet &p)
const char * p
Definition: xmltok.h:285
ToFFilter(fhicl::ParameterSet const &p)
DEFINE_ART_MODULE(TestTMapFile)
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
T get(std::string const &key) const
Definition: ParameterSet.h:231
Encapsulation of reconstructed Time-of-Flight (ToF) information. Part of beamline reconstruction for ...
Float_t d
Definition: plot.C:236
art::InputTag fBeamlineToFDataLabel
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Raw data definitions for beamline data used in NOvA test beam experiment.
bool filter(art::Event &e)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Float_t e
Definition: plot.C:35