FWCore
Modules
src
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
20
#include "
DataFormats/Provenance/interface/EventID.h
"
21
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
22
#include "
FWCore/Framework/interface/Event.h
"
23
#include "
FWCore/Framework/interface/MakerMacros.h
"
24
#include "
FWCore/ParameterSet/interface/ConfigurationDescriptions.h
"
25
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
26
#include "
FWCore/ParameterSet/interface/ParameterSetDescription.h
"
27
28
// system include files
29
#include <algorithm>
30
#include <memory>
31
#include <vector>
32
#include <cstdlib>
33
34
//
35
// class decleration
36
//
37
38
class
AbortOnEventIDAnalyzer
:
public
edm::EDAnalyzer
{
39
public
:
40
explicit
AbortOnEventIDAnalyzer
(
edm::ParameterSet
const
&);
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_
;
51
bool
throwException_
;
52
};
53
54
//
55
// constants, enums and typedefs
56
//
57
58
//
59
// static data member definitions
60
//
61
62
//
63
// constructors and destructor
64
//
65
AbortOnEventIDAnalyzer::AbortOnEventIDAnalyzer
(
edm::ParameterSet
const
& iConfig)
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
71
AbortOnEventIDAnalyzer::~AbortOnEventIDAnalyzer
() {
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 ------------
91
void
AbortOnEventIDAnalyzer::analyze
(
edm::Event
const
&
iEvent
,
edm::EventSetup
const
&) {
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 ------------
103
void
AbortOnEventIDAnalyzer::beginJob
() {}
104
105
// ------------ method called once each job just after ending the event loop ------------
106
void
AbortOnEventIDAnalyzer::endJob
() {}
107
108
// ------------ method called once each job for validation
109
void
AbortOnEventIDAnalyzer::fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions) {
110
edm::ParameterSetDescription
desc
;
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
117
DEFINE_FWK_MODULE
(
AbortOnEventIDAnalyzer
);
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
Generated for CMSSW Reference Manual by
1.8.16