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 
10 #include <fstream>
11 
13 
14  class Event {
15  public:
16  Event(unsigned int r, unsigned int l, unsigned int e) : run(r), lumi(l), event(e) {}
17  unsigned int run;
18  unsigned int lumi;
19  unsigned int event;
20  };
21 
22  public:
23 
24  explicit MultiEventFilter(const edm::ParameterSet & iConfig);
26 
27  private:
28 
29  virtual bool filter(edm::Event & iEvent, const edm::EventSetup & iSetup);
30 
31  std::vector<Event> events_;
32  const std::vector<std::string> eventList_;
33 
34  const bool taggingMode_;
35 
36 };
37 
38 
40  : eventList_ (iConfig.getParameter<std::vector<std::string> >("EventList") )
41  , taggingMode_ (iConfig.getParameter<bool>("taggingMode") )
42 {
43  edm::FileInPath fp = iConfig.getParameter<edm::FileInPath>("file");
44  std::string fFile = fp.fullPath();
45  std::ifstream inStream(fFile.c_str());
46 
47  for (unsigned int i = 0; i < eventList_.size(); ++i) {
48  std::vector<std::string> tokens = edm::tokenize(eventList_[i], ":");
49  if(tokens.size() != 3) {
50  throw edm::Exception(edm::errors::Configuration) << "Incorrect event specification";
51  continue;
52  }
53  events_.push_back(Event(atoi(tokens[0].c_str()), atoi(tokens[1].c_str()), atoi(tokens[2].c_str())));
54  }
55 
56  std::string line;
57  while( getline(inStream, line) ){
58  std::vector<std::string> tokens = edm::tokenize(line, ":");
59  if(tokens.size() != 3) {
60  throw edm::Exception(edm::errors::Configuration) << "Incorrect event specification";
61  continue;
62  }
63  events_.push_back(Event(atoi(tokens[0].c_str()), atoi(tokens[1].c_str()), atoi(tokens[2].c_str())));
64  }
65 
66  produces<bool>();
67 }
68 
69 
71 
72  bool pass = true;
73 
74  for (unsigned int i = 0; i < events_.size(); ++i) {
75  if (events_[i].event == iEvent.id().event() &&
76  events_[i].run == iEvent.id().run() &&
77  events_[i].lumi == iEvent.id().luminosityBlock()) pass = false;
78  }
79 
80  iEvent.put( std::auto_ptr<bool>(new bool(pass)) );
81 
82  return taggingMode_ || pass;
83 
84 }
85 
86 
88 
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:43
virtual bool filter(edm::Event &iEvent, const edm::EventSetup &iSetup)
const bool taggingMode_
std::vector< Event > events_
const std::vector< std::string > eventList_
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
MultiEventFilter(const edm::ParameterSet &iConfig)
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
Event(unsigned int r, unsigned int l, unsigned int e)
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:56
std::string fullPath() const
Definition: FileInPath.cc:171