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"
23 #include "art_root_io/TFileService.h"
24 #include "art_root_io/TFileDirectory.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 : EDFilter(p)
62 {
63  this->reconfigure(p);
64 }
65 
67  fToFDataLabel = pset.get<art::InputTag>("ToFDataLabel");
68  fBeamlineToFDataLabel = pset.get<art::InputTag>("BeamlineToFDataLabel");
69  fFilterOnBeamlineDigits = pset.get<bool>("FilterOnBeamlineDigits");
70  fFilterOnRecoToFs = pset.get<bool>("FilterOnRecoToFs");
71  fMinToFHitsUS = pset.get<unsigned int>("MinToFHitsUS");
72  fMaxToFHitsUS = pset.get<unsigned int>("MaxToFHitsUS");
73  fMinToFHitsDS = pset.get<unsigned int>("MinToFHitsDS");
74  fMaxToFHitsDS = pset.get<unsigned int>("MaxToFHitsDS");
75  fMinToFCount = pset.get<unsigned int>("MinToFCount");
76  fMaxToFCount = pset.get<unsigned int>("MaxToFCount");
77  fMinToF = pset.get<double>("MinToF");
78  fMaxToF = pset.get<double>("MaxToF");
79 }
80 
82 {
83  // Get tof digits
85  std::vector<art::Ptr<brb::BeamlineDigit>> digits;
86  if (e.getByLabel(fBeamlineToFDataLabel, digitHandle)) art::fill_ptr_vector(digits, digitHandle);
87 
88  // Get ToF objects
90  std::vector<art::Ptr<brb::ToF>> tofs;
91  if (e.getByLabel(fToFDataLabel, tofHandle)) art::fill_ptr_vector(tofs, tofHandle);
92 
93  // tof digit filtering
95  // Separate by counter
96  std::vector<art::Ptr<brb::BeamlineDigit>> usDigits;
97  std::vector<art::Ptr<brb::BeamlineDigit>> dsDigits;
98  for (auto d : digits) {
99  if (d->ChannelID().Detector == beamlinegeo::ToFCounter::US) {
100  usDigits.push_back(d);
101  } else if (d->ChannelID().Detector == beamlinegeo::ToFCounter::DS) {
102  dsDigits.push_back(d);
103  }
104  }
105  if (usDigits.size() < fMinToFHitsUS) return false;
106  if (usDigits.size() > fMaxToFHitsUS) return false;
107  if (dsDigits.size() < fMinToFHitsDS) return false;
108  if (dsDigits.size() > fMaxToFHitsDS) return false;
109  }
110 
111  // tof filtering
112  if (fFilterOnRecoToFs) {
113  if(tofs.size() < fMinToFCount) return false;
114  if(tofs.size() > fMaxToFCount) return false;
115 
116  //std::cout << e.id() << ": \n";
117 
118  // Retrieve BeamlineDigits for tof reco
120 
121  //filter out events with bad behavior
122  for (auto tof : tofs) {
123  if (tof->Time() < fMinToF) return false;
124  if (tof->Time() > fMaxToF) return false;
125 
126  // Get associated reco digits
127  //const std::vector<art::Ptr<brb::BeamlineDigit>> tofDigits = fmbd.at(tof.key());
128  }
129  }
130 
131  return true;
132 }
133 
134 
void reconfigure(const fhicl::ParameterSet &p)
const char * p
Definition: xmltok.h:285
ToFFilter(fhicl::ParameterSet const &p)
DEFINE_ART_MODULE(TestTMapFile)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
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
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:22
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:291
Float_t e
Definition: plot.C:35