All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FilterOpFlash_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: FilterOpFlash
3 // Plugin Type: filter (art v3_06_03)
4 // File: FilterOpFlash_module.cc
5 //
6 // Generated at Wed Mar 24 13:20:35 2021 by Kazuhiro Terao using cetskelgen
7 // from cetlib version v3_11_01.
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/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include <memory>
21 
22 class FilterOpFlash;
23 
24 
25 class FilterOpFlash : public art::EDFilter {
26 public:
27  explicit FilterOpFlash(fhicl::ParameterSet const& p);
28 
29  FilterOpFlash(FilterOpFlash const&) = delete;
30  FilterOpFlash(FilterOpFlash&&) = delete;
31  FilterOpFlash& operator=(FilterOpFlash const&) = delete;
33  bool filter(art::Event& e) override;
34 
35 private:
36  std::vector<std::string> _flash_producer_v;
37  double _time_start;
38  double _time_end;
39  double _pe_threshold;
40 };
41 
42 
43 FilterOpFlash::FilterOpFlash(fhicl::ParameterSet const& p)
44  : EDFilter{p}
45 {
46  _flash_producer_v = p.get<std::vector<std::string> >("OpFlashProducerList");
47  _time_start = p.get<double>("WindowStartTime");
48  _time_end = p.get<double>("WindowEndTime");
49  _pe_threshold = p.get<double>("FlashPEThreshold",-1);
50  assert(_time_end>_time_start);
51 }
52 
53 bool FilterOpFlash::filter(art::Event& e)
54 {
55 
56  bool pass = false;
57  for(auto const& producer : _flash_producer_v) {
58 
59  art::Handle<std::vector<recob::OpFlash> > flash_handle;
60  e.getByLabel(producer, flash_handle);
61  if(!flash_handle.isValid()) {
62  std::cerr << "Invalid producer for truth recob::OpFlash: " << producer<< std::endl;
63  throw std::exception();
64  }
65 
66  for(auto const& flash : *flash_handle) {
67  if(flash.TotalPE() < _pe_threshold) continue;
68  if(flash.Time() < _time_start || flash.Time() > _time_end) continue;
69  pass = true;
70  break;
71  }
72 
73  if(pass) break;
74  }
75  return pass;
76 }
77 
78 DEFINE_ART_MODULE(FilterOpFlash)
std::vector< std::string > _flash_producer_v
BEGIN_PROLOG could also be cerr
pdgs p
Definition: selectors.fcl:22
bool filter(art::Event &e) override
FilterOpFlash(fhicl::ParameterSet const &p)
do i e
FilterOpFlash & operator=(FilterOpFlash const &)=delete