CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultiEventFilter.cc
Go to the documentation of this file.
1 
7 
9 
11 
12 #include <fstream>
13 
15 
16  class Event {
17  public:
22  };
23 
24  public:
25 
26  explicit MultiEventFilter(const edm::ParameterSet & iConfig);
28 
29  private:
30 
31  virtual bool filter(edm::Event & iEvent, const edm::EventSetup & iSetup) override;
32 
33  std::vector<Event> events_;
34  const std::vector<std::string> eventList_;
35 
36  const bool taggingMode_;
37 
38 };
39 
40 
42  : eventList_ (iConfig.getParameter<std::vector<std::string> >("EventList") )
43  , taggingMode_ (iConfig.getParameter<bool>("taggingMode") )
44 {
46  std::string fFile = fp.fullPath();
47  std::ifstream inStream(fFile.c_str());
48 
49  for (unsigned int i = 0; i < eventList_.size(); ++i) {
50  std::vector<std::string> tokens = edm::tokenize(eventList_[i], ":");
51  if(tokens.size() != 3) {
52  throw edm::Exception(edm::errors::Configuration) << "Incorrect event specification";
53  continue;
54  }
55  events_.push_back(Event(atoi(tokens[0].c_str()), atoi(tokens[1].c_str()), atoi(tokens[2].c_str())));
56  }
57 
59  while( getline(inStream, line) ){
60  std::vector<std::string> tokens = edm::tokenize(line, ":");
61  if(tokens.size() != 3) {
62  throw edm::Exception(edm::errors::Configuration) << "Incorrect event specification";
63  continue;
64  }
65  events_.push_back(Event(atoi(tokens[0].c_str()), atoi(tokens[1].c_str()), atoi(tokens[2].c_str())));
66  }
67 
68  produces<bool>();
69 }
70 
71 
73 
74  bool pass = true;
75 
76  for (unsigned int i = 0; i < events_.size(); ++i) {
77  if (events_[i].event == iEvent.id().event() &&
78  events_[i].run == iEvent.id().run() &&
79  events_[i].lumi == iEvent.id().luminosityBlock()) pass = false;
80  }
81 
82  iEvent.put( std::auto_ptr<bool>(new bool(pass)) );
83 
84  return taggingMode_ || pass;
85 
86 }
87 
88 
90 
RunNumber_t run() const
Definition: EventID.h:39
edm::LuminosityBlockNumber_t lumi
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual bool filter(edm::Event &iEvent, const edm::EventSetup &iSetup) override
unsigned long long EventNumber_t
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
unsigned int LuminosityBlockNumber_t
const bool taggingMode_
std::vector< Event > events_
const std::vector< std::string > eventList_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
MultiEventFilter(const edm::ParameterSet &iConfig)
Event(edm::RunNumber_t r, edm::LuminosityBlockNumber_t l, edm::EventNumber_t e)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
Definition: Parse.cc:57
edm::EventID id() const
Definition: EventBase.h:60
unsigned int RunNumber_t
std::string fullPath() const
Definition: FileInPath.cc:165
edm::EventNumber_t event