All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ToFFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ToFFilter
3 // Plugin Type: filter (art v3_05_01)
4 // File: ToFFilter_module.cc
5 //
6 // Generated at Fri Jan 28 17:07:23 2022 by Varuna Crishan Meddage using cetskelgen
7 // from cetlib version v3_10_00.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDFilter.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/SubRun.h"
14 #include "art/Framework/Principal/Handle.h"
15 #include "art/Framework/Principal/View.h"
16 #include "canvas/Persistency/Common/Ptr.h"
17 #include "canvas/Persistency/Common/PtrVector.h"
18 #include "art/Framework/Services/Registry/ServiceHandle.h"
19 #include "art_root_io/TFileService.h"
20 #include "art_root_io/TFileDirectory.h"
21 #include "canvas/Persistency/Common/FindMany.h"
22 #include "canvas/Persistency/Common/FindManyP.h"
23 #include "canvas/Persistency/Common/FindOneP.h"
24 #include "fhiclcpp/ParameterSet.h"
25 #include "messagefacility/MessageLogger/MessageLogger.h"
29 
31 #include "nusimdata/SimulationBase/GTruth.h"
32 #include "nusimdata/SimulationBase/MCTruth.h"
33 #include "nusimdata/SimulationBase/MCFlux.h"
63 
66 
67 // sbndcode includes
74 
76 
77 #include "sbnobj/SBND/ToF/ToF.hh"
78 
79 #include "TFile.h"
80 #include "TTree.h"
81 #include "TDirectory.h"
82 #include "TH1.h"
83 #include "TH2.h"
84 #include "TF1.h"
85 #include "TProfile.h"
86 #include "TROOT.h"
87 #include "TStyle.h"
88 #include "TMath.h"
89 #include "TGraphErrors.h"
90 #include "TMinuit.h"
91 #include "TString.h"
92 #include "TTimeStamp.h"
93 #include "TVectorD.h"
94 #include "TCanvas.h"
95 #include "TFrame.h"
96 #include "TLine.h"
97 #include "TAxis.h"
98 #include "TTimeStamp.h"
99 
100 #include <vector>
101 #include <fstream>
102 #include "TPaveStats.h"
103 #include <iostream>
104 #include <string>
105 #include "math.h"
106 #include "stdio.h"
107 #include <iterator>
108 #include <map>
109 #include <memory>
110 
111 using namespace std;
112 
113 namespace sbnd{
114 
115 
116 class ToFFilter : public art::EDFilter {
117 public:
118  explicit ToFFilter(fhicl::ParameterSet const& p);
119 
120  ToFFilter(ToFFilter const&) = delete;
121  ToFFilter(ToFFilter&&) = delete;
122  ToFFilter& operator=(ToFFilter const&) = delete;
123  ToFFilter& operator=(ToFFilter&&) = delete;
124 
125  bool filter(art::Event& evt) override;
126 
127 private:
128  art::InputTag ftofLhitLabel;
129  art::InputTag ftofChitLabel;
130  art::InputTag ftofLflashLabel;
131  art::InputTag ftofCflashLabel;
132  art::InputTag ftofLflashhitLabel;
133  art::InputTag ftofCflashhitLabel;
134  bool fuse_Lhit;
135  bool fuse_Chit;
146 };
147 
148 
149 ToFFilter::ToFFilter(fhicl::ParameterSet const& pset):
150 EDFilter{pset},
151 ftofLhitLabel(pset.get<art::InputTag>("tofLhitLabel")),
152 ftofChitLabel(pset.get<art::InputTag>("tofChitLabel")),
153 ftofLflashLabel(pset.get<art::InputTag>("tofLflashLabel")),
154 ftofCflashLabel(pset.get<art::InputTag>("tofCflashLabel")),
155 ftofLflashhitLabel(pset.get<art::InputTag>("tofLflashhitLabel")),
156 ftofCflashhitLabel(pset.get<art::InputTag>("tofCflashhitLabel")),
157 fuse_Lhit(pset.get<bool>("use_Lhit")),
158 fuse_Chit(pset.get<bool>("use_Chit")),
159 fuse_Lflsh(pset.get<bool>("use_Lflsh")),
160 fuse_Cflsh(pset.get<bool>("use_Cflsh")),
161 fuse_Lflsh_hit(pset.get<bool>("use_Lflsh_hit")),
162 fuse_Cflsh_hit(pset.get<bool>("use_Cflsh_hit")),
163 ftof_Lhit_cut(pset.get<float>("tof_Lhit_cut")),
164 ftof_Chit_cut(pset.get<float>("tof_Chit_cut")),
165 ftof_Lflsh_cut(pset.get<float>("tof_Lflsh_cut")),
166 ftof_Cflsh_cut(pset.get<float>("tof_Cflsh_cut")),
167 ftof_Lflshhit_cut(pset.get<float>("tof_Lflshhit_cut")),
168 ftof_Cflshhit_cut(pset.get<float>("tof_Cflshhit_cut"))
169 {
170 }
171 
172 bool ToFFilter::filter(art::Event& evt)
173 {
174  bool keep_event = true;
175 
176  // ================================== Calculatin ToF values using Largest optical hit method =========================
177 
178  if(fuse_Lhit){
179  art::Handle< std::vector<sbnd::ToF::ToF> > tofLhitListHandle;
180  std::vector< art::Ptr<sbnd::ToF::ToF> > tofLhitList;
181  if( evt.getByLabel(ftofLhitLabel,tofLhitListHandle))
182  art::fill_ptr_vector(tofLhitList, tofLhitListHandle);
183 
184  std::vector<bool> is_cos_like;
185 
186  for(auto const& tf_lhit : tofLhitList){
187  if(tf_lhit->tof >= ftof_Lhit_cut) is_cos_like.push_back(false);
188  else is_cos_like.push_back(true);
189  }
190 
191  if(is_cos_like.size()){
192  bool found_nu=false;
193  for(auto itr: is_cos_like){
194  if(!itr){
195  found_nu=true;
196  break;
197  }
198  }
199 
200  if(!found_nu) keep_event=false;
201  }
202  } // Using largest optical hit to calculate tof
203 
204  //======================================================================================================================
205 
206  // ================================== Calculatin ToF values using Closest optical hit method ===========================
207 
208  if(fuse_Chit){
209  art::Handle< std::vector<sbnd::ToF::ToF> > tofChitListHandle;
210  std::vector< art::Ptr<sbnd::ToF::ToF> > tofChitList;
211  if( evt.getByLabel(ftofChitLabel,tofChitListHandle))
212  art::fill_ptr_vector(tofChitList, tofChitListHandle);
213 
214  std::vector<bool> is_cos_like;
215 
216  for(auto const& tf_chit : tofChitList){
217  if(tf_chit->tof >= ftof_Chit_cut) is_cos_like.push_back(false);
218  else is_cos_like.push_back(true);
219  }
220 
221  if(is_cos_like.size()){
222  bool found_nu=false;
223  for(auto itr: is_cos_like){
224  if(!itr){
225  found_nu=true;
226  break;
227  }
228  }
229 
230  if(!found_nu) keep_event=false;
231  }
232  } // Using closest optical hit to calculate tof
233 
234  //======================================================================================================================
235 
236  //==================================== Calculation ToF values using Largest optical flash ==============================
237 
238  if(fuse_Lflsh){
239  art::Handle< std::vector<sbnd::ToF::ToF> > tofLflashListHandle;
240  std::vector< art::Ptr<sbnd::ToF::ToF> > tofLflashList;
241  if( evt.getByLabel(ftofLflashLabel,tofLflashListHandle))
242  art::fill_ptr_vector(tofLflashList, tofLflashListHandle);
243 
244  std::vector<bool> is_cos_like;
245 
246  for(auto const& tf_lflash : tofLflashList){
247  if(tf_lflash->tof >= ftof_Lflsh_cut) is_cos_like.push_back(false);
248  else is_cos_like.push_back(true);
249  }
250 
251  if(is_cos_like.size()){
252  bool found_nu=false;
253  for(auto itr: is_cos_like){
254  if(!itr){
255  found_nu=true;
256  break;
257  }
258  }
259 
260  if(!found_nu) keep_event=false;
261  }
262  } // Using largest optical flash to calculate tof
263 
264  //======================================================================================================================
265 
266  //==================================== Calculation ToF values using Largest optical flash ==============================
267 
268  if(fuse_Cflsh){
269  art::Handle< std::vector<sbnd::ToF::ToF> > tofCflashListHandle;
270  std::vector< art::Ptr<sbnd::ToF::ToF> > tofCflashList;
271  if( evt.getByLabel(ftofCflashLabel,tofCflashListHandle))
272  art::fill_ptr_vector(tofCflashList, tofCflashListHandle);
273 
274  std::vector<bool> is_cos_like;
275 
276  for(auto const& tf_cflash : tofCflashList){
277  if(tf_cflash->tof >= ftof_Cflsh_cut) is_cos_like.push_back(false);
278  else is_cos_like.push_back(true);
279  }
280 
281  if(is_cos_like.size()){
282  bool found_nu=false;
283  for(auto itr: is_cos_like){
284  if(!itr){
285  found_nu=true;
286  break;
287  }
288  }
289 
290  if(!found_nu) keep_event=false;
291  }
292  } // Using closest optical flash to calculate tof
293 
294  //======================================================================================================================
295 
296  //=========================Calculation ToF values using Earliest hit of the Largest flash ==============================
297 
298  if(fuse_Lflsh_hit){
299  art::Handle< std::vector<sbnd::ToF::ToF> > tofLflashhitListHandle;
300  std::vector< art::Ptr<sbnd::ToF::ToF> > tofLflashhitList;
301  if( evt.getByLabel(ftofLflashhitLabel,tofLflashhitListHandle))
302  art::fill_ptr_vector(tofLflashhitList, tofLflashhitListHandle);
303 
304  std::vector<bool> is_cos_like;
305 
306  for(auto const& tf_lflashhit : tofLflashhitList){
307  if(tf_lflashhit->tof >= ftof_Lflshhit_cut) is_cos_like.push_back(false);
308  else is_cos_like.push_back(true);
309  }
310 
311  if(is_cos_like.size()){
312  bool found_nu=false;
313  for(auto itr: is_cos_like){
314  if(!itr){
315  found_nu=true;
316  break;
317  }
318  }
319 
320  if(!found_nu) keep_event=false;
321  }
322  } // Using earliest hit of the largest optical flash to calculate tof
323 
324  //======================================================================================================================
325 
326  //=========================Calculation ToF values using Earliest hit of the Closest flash ==============================
327 
328  if(fuse_Cflsh_hit){
329  art::Handle< std::vector<sbnd::ToF::ToF> > tofCflashhitListHandle;
330  std::vector< art::Ptr<sbnd::ToF::ToF> > tofCflashhitList;
331  if( evt.getByLabel(ftofCflashhitLabel,tofCflashhitListHandle))
332  art::fill_ptr_vector(tofCflashhitList, tofCflashhitListHandle);
333 
334  std::vector<bool> is_cos_like;
335 
336  for(auto const& tf_cflashhit : tofCflashhitList){
337  if(tf_cflashhit->tof >= ftof_Cflshhit_cut) is_cos_like.push_back(false);
338  else is_cos_like.push_back(true);
339  }
340 
341  if(is_cos_like.size()){
342  bool found_nu=false;
343  for(auto itr: is_cos_like){
344  if(!itr){
345  found_nu=true;
346  break;
347  }
348  }
349 
350  if(!found_nu) keep_event=false;
351  }
352  } // Using earliest hit of the closest optical flash to calculate tof
353 
354  //======================================================================================================================
355 
356  return keep_event;
357 }
358 
359 DEFINE_ART_MODULE(ToFFilter)
360 }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
Implementation of the Projection Matching Algorithm.
Declaration of signal hit object.
pdgs p
Definition: selectors.fcl:22
art::InputTag ftofCflashLabel
Definition of basic raw digits.
art::InputTag ftofChitLabel
object containing MC truth information necessary for making RawDigits and doing back tracking ...
art::InputTag ftofCflashhitLabel
Declaration of cluster object.
Definition of data types for geometry description.
art::InputTag ftofLflashhitLabel
Provides recob::Track data product.
bool filter(art::Event &evt) override
physics filters filter
object containing MC truth information necessary for making RawDigits and doing back tracking ...
Class def header for MCShower data container.
stream1 can override from command line with o or output services user sbnd
TCEvent evt
Definition: DataStructs.cxx:8
helper function for LArPandoraInterface producer module
art::InputTag ftofLflashLabel
art framework interface to geometry description
art::InputTag ftofLhitLabel