CMS 3D CMS Logo

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 <cstdlib>
33 
34 //
35 // class decleration
36 //
37 
39 public:
41  ~AbortOnEventIDAnalyzer() override;
42  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
43 
44 private:
45  void beginJob() override;
46  void analyze(edm::Event const&, edm::EventSetup const&) override;
47  void endJob() override;
48 
49  // ----------member data ---------------------------
50  std::vector<edm::EventID> ids_;
52 };
53 
54 //
55 // constants, enums and typedefs
56 //
57 
58 //
59 // static data member definitions
60 //
61 
62 //
63 // constructors and destructor
64 //
66  : ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventsToAbort")),
67  throwException_(iConfig.getUntrackedParameter<bool>("throwExceptionInsteadOfAbort")) {
68  //now do what ever initialization is needed
69 }
70 
72  // do anything here that needs to be done at desctruction time
73  // (e.g. close files, deallocate resources etc.)
74 }
75 
76 //
77 // member functions
78 //
79 
80 namespace {
81  struct CompareWithoutLumi {
82  CompareWithoutLumi(edm::EventID const& iThis) : m_this(iThis) {}
83  bool operator()(edm::EventID const& iOther) {
84  return m_this.run() == iOther.run() && m_this.event() == iOther.event();
85  }
86  edm::EventID m_this;
87  };
88 } // namespace
89 
90 // ------------ method called to for each event ------------
92  std::vector<edm::EventID>::iterator itFind = std::find_if(ids_.begin(), ids_.end(), CompareWithoutLumi(iEvent.id()));
93  if (itFind != ids_.end()) {
94  if (throwException_) {
95  throw cms::Exception("AbortEvent") << "Found event " << iEvent.id() << "\n";
96  } else {
97  abort();
98  }
99  }
100 }
101 
102 // ------------ method called once each job just before starting event loop ------------
104 
105 // ------------ method called once each job just after ending the event loop ------------
107 
108 // ------------ method called once each job for validation
111  desc.addUntracked<std::vector<edm::EventID> >("eventsToAbort");
112  desc.addUntracked<bool>("throwExceptionInsteadOfAbort", false);
113  descriptions.add("abortOnEventID", desc);
114 }
115 
116 //define this as a plug-in
ConfigurationDescriptions.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
AbortOnEventIDAnalyzer::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: AbortOnEventIDAnalyzer.cc:91
AbortOnEventIDAnalyzer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: AbortOnEventIDAnalyzer.cc:109
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDAnalyzer.h
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
AbortOnEventIDAnalyzer
Definition: AbortOnEventIDAnalyzer.cc:38
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
AbortOnEventIDAnalyzer::beginJob
void beginJob() override
Definition: AbortOnEventIDAnalyzer.cc:103
EventID.h
ParameterSetDescription.h
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AbortOnEventIDAnalyzer::throwException_
bool throwException_
Definition: AbortOnEventIDAnalyzer.cc:51
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
iEvent
int iEvent
Definition: GenABIO.cc:224
AbortOnEventIDAnalyzer::AbortOnEventIDAnalyzer
AbortOnEventIDAnalyzer(edm::ParameterSet const &)
Definition: AbortOnEventIDAnalyzer.cc:65
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:57
AbortOnEventIDAnalyzer::ids_
std::vector< edm::EventID > ids_
Definition: AbortOnEventIDAnalyzer.cc:50
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
AbortOnEventIDAnalyzer::~AbortOnEventIDAnalyzer
~AbortOnEventIDAnalyzer() override
Definition: AbortOnEventIDAnalyzer.cc:71
Exception
Definition: hltDiff.cc:246
AbortOnEventIDAnalyzer::endJob
void endJob() override
Definition: AbortOnEventIDAnalyzer.cc:106
ParameterSet.h
edm::EventID
Definition: EventID.h:31
edm::Event
Definition: Event.h:73