All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventSelect_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: EventSelect
3 // Plugin Type: filter (art v3_05_01)
4 // File: EventSelect_module.cc
5 //
6 // Generated at Mon Oct 5 13:03:33 2020 by Gray Putnam 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/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"
19 
20 #include <memory>
21 
22 namespace sbn {
23  namespace util {
24  class EventSelect;
25  }
26 }
27 
28 
29 class sbn::util::EventSelect : public art::EDFilter {
30 public:
31  explicit EventSelect(fhicl::ParameterSet const& p);
32  // The compiler-generated destructor is fine for non-base
33  // classes without bare pointers or other resource use.
34 
35  // Plugins should not be copied or assigned.
36  EventSelect(EventSelect const&) = delete;
37  EventSelect(EventSelect&&) = delete;
38  EventSelect& operator=(EventSelect const&) = delete;
39  EventSelect& operator=(EventSelect&&) = delete;
40 
41  // Required functions.
42  bool filter(art::Event& e) override;
43 
44  void respondToOpenInputFile(const art::FileBlock& fb) override { fFileNo ++; }
45 
46 private:
47 
48  // Declare member data here.
49  std::vector<std::string> fConfig;
50  std::vector<int> fFileNoSelect;
51  std::vector<int> fEvtSelect;
52  int fFileNo;
53  unsigned fNAccept;
54 };
55 
56 
57 sbn::util::EventSelect::EventSelect(fhicl::ParameterSet const& p)
58  : EDFilter{p},
59  fConfig(p.get<std::vector<std::string>>("Select"))
60 {
61  for (const std::string &s: fConfig) {
62  fFileNoSelect.push_back(-1);
63  fEvtSelect.push_back(-1);
64  sscanf(s.c_str(), "%d:%d", &fFileNoSelect.back(), &fEvtSelect.back());
65  }
66  fFileNo = -1;
67  fNAccept = 0;
68 }
69 
71 {
72  //if (fNAccept == fFileNoSelect.size()) {
73  // throw cet::exception("EventSelect Filter") << "Finished selecting events from list. ";
74  //}
75 
76  for (unsigned i = 0; i < fFileNoSelect.size(); i++) {
77  if (fFileNoSelect[i] == fFileNo && fEvtSelect[i] == (int)e.event()) {
78  fNAccept ++;
79  return true;
80  }
81  }
82  return false;
83 }
84 
85 DEFINE_ART_MODULE(sbn::util::EventSelect)
pdgs p
Definition: selectors.fcl:22
EventSelect & operator=(EventSelect const &)=delete
std::vector< std::string > fConfig
EventSelect(fhicl::ParameterSet const &p)
std::vector< int > fEvtSelect
void respondToOpenInputFile(const art::FileBlock &fb) override
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
bool filter(art::Event &e) override
do i e
std::vector< int > fFileNoSelect