CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AbortOnEventIDAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Modules
4 // Class: AbortOnEventIDAnalyzer
5 //
13 //
14 // Original Author: Chris Jones
15 // Created: Tue Jun 16 15:42:17 CDT 2009
16 //
17 //
18 
19 // user include files
27 
28 // system include files
29 #include <algorithm>
30 #include <memory>
31 #include <vector>
32 #include <stdlib.h>
33 
34 //
35 // class decleration
36 //
37 
39 public:
42  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
43 
44 
45 private:
46  virtual void beginJob() override;
47  virtual void analyze(edm::Event const&, edm::EventSetup const&) override;
48  virtual void endJob() override;
49 
50  // ----------member data ---------------------------
51  std::vector<edm::EventID> ids_;
53 };
54 
55 //
56 // constants, enums and typedefs
57 //
58 
59 //
60 // static data member definitions
61 //
62 
63 //
64 // constructors and destructor
65 //
67  ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventsToAbort")),
68  throwException_(iConfig.getUntrackedParameter<bool>("throwExceptionInsteadOfAbort"))
69 {
70  //now do what ever initialization is needed
71 
72 }
73 
74 
76 
77  // do anything here that needs to be done at desctruction time
78  // (e.g. close files, deallocate resources etc.)
79 
80 }
81 
82 
83 //
84 // member functions
85 //
86 
87 namespace {
88  struct CompareWithoutLumi {
89  CompareWithoutLumi(edm::EventID const& iThis) : m_this(iThis) {
90  }
91  bool operator()(edm::EventID const& iOther) {
92  return m_this.run() == iOther.run() && m_this.event() == iOther.event();
93  }
94  edm::EventID m_this;
95  };
96 }
97 
98 // ------------ method called to for each event ------------
99 void
101  std::vector<edm::EventID>::iterator itFind= std::find_if(ids_.begin(), ids_.end(), CompareWithoutLumi(iEvent.id()));
102  if(itFind != ids_.end()) {
103  if (throwException_) {
104  throw cms::Exception("AbortEvent") << "Found event " << iEvent.id() << "\n";
105  } else {
106  abort();
107  }
108  }
109 }
110 
111 // ------------ method called once each job just before starting event loop ------------
112 void
114 }
115 
116 // ------------ method called once each job just after ending the event loop ------------
117 void
119 }
120 
121 // ------------ method called once each job for validation
122 void
125  desc.addUntracked<std::vector<edm::EventID> >("eventsToAbort");
126  desc.addUntracked<bool>("throwExceptionInsteadOfAbort", false);
127  descriptions.add("abortOnEventID", desc);
128 }
129 
130 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
std::vector< edm::EventID > ids_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void beginJob() override
int iEvent
Definition: GenABIO.cc:243
void add(std::string const &label, ParameterSetDescription const &psetDescription)
AbortOnEventIDAnalyzer(edm::ParameterSet const &)
edm::EventID id() const
Definition: EventBase.h:56
virtual void endJob() override
virtual void analyze(edm::Event const &, edm::EventSetup const &) override