EventFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: EventFilter
3 // Module Type: filter
4 // File: EventFilter_module.cc
5 //
6 // Generated at Wed Jan 28 16:48:29 2015 by Matthew Tamsett using artmod
7 // from cetpkgsupport v1_07_00.
8 ////////////////////////////////////////////////////////////////////////
9 
16 //// this was working at least up to S17-02-21
17 //#include "art/Utilities/InputTag.h"
18 #include "fhiclcpp/ParameterSet.h"
20 
21 #include <memory>
22 #include <iostream>
23 #include <fstream>
24 #include <string>
25 
26 
27 class EventFilter;
28 //----------------------------------------------------------------------
29 class EventFilter : public art::EDFilter {
30 public:
31  explicit EventFilter(fhicl::ParameterSet const & p);
32  // The destructor generated by the compiler is fine for classes
33  // without bare pointers or other resource use.
34 
35  // Plugins should not be copied or assigned.
36  EventFilter(EventFilter const &) = delete;
37  EventFilter(EventFilter &&) = delete;
38  EventFilter & operator = (EventFilter const &) = delete;
39  EventFilter & operator = (EventFilter &&) = delete;
40 
41  // Required functions.
42  bool filter(art::Event & e) override;
43  virtual void beginJob() override;
44 
45 private:
46 
47  // Declare member data here.
48  std::ifstream eventList;
50 
51  std::vector<art::SubRunNumber_t> run;
52  std::vector<art::RunNumber_t> subrun;
53  std::vector<art::EventNumber_t> event;
54 };
55 //----------------------------------------------------------------------
57  : _InputFile (p.get<std::string >("InputFile" ))
58 // :
59 // Initialize member data here.
60 {
61  // Call appropriate produces<>() functions here.
62 }
63 //----------------------------------------------------------------------
65 {
66  run.clear();
67  subrun.clear();
68  event.clear();
69 
70  eventList.open(_InputFile.c_str());
71  int fRun, fSubrun, fEvent, fSlice;
72  double slicetime;
73 
74  while(!eventList.eof())
75  {
76  // Change this once the release is updated
77  eventList >> fRun >> fSubrun >> fEvent >> fSlice >> slicetime;
78  //eventList >> fRun >> fSubrun >> fEvent >> fSlice;
79  run.push_back(fRun);
80  subrun.push_back(fSubrun);
81  event.push_back(fEvent);
82  }
83  eventList.close();
84 }
85 
87 {
88 
89  if(std::find(run.begin(), run.end(), evt.id().run()) != run.end() &&
90  std::find(subrun.begin(), subrun.end(), evt.id().subRun()) != subrun.end() &&
91  std::find(event.begin(), event.end(), evt.id().event()) != event.end())
92  return true;
93 
94  else return false;
95 }
96 //----------------------------------------------------------------------
std::ifstream eventList
std::vector< art::SubRunNumber_t > run
const char * p
Definition: xmltok.h:285
bool filter(art::Event &e) override
DEFINE_ART_MODULE(TestTMapFile)
RunNumber_t run() const
Definition: EventID.h:98
EventFilter & operator=(EventFilter const &)=delete
int evt
virtual void beginJob() override
std::vector< art::EventNumber_t > event
Definition: run.py:1
EventNumber_t event() const
Definition: EventID.h:116
SubRunNumber_t subRun() const
Definition: EventID.h:110
std::vector< art::RunNumber_t > subrun
EventFilter(fhicl::ParameterSet const &p)
std::string _InputFile
Float_t e
Definition: plot.C:35
EventID id() const
Definition: Event.h:56
enum BeamMode string