CMS 3D CMS Logo

EventIDChecker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Modules
4 // Class: EventIDChecker
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 
33 //
34 // class decleration
35 //
36 
37 class EventIDChecker : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
38 public:
39  explicit EventIDChecker(edm::ParameterSet const&);
40  ~EventIDChecker() override;
41  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
42 
43 private:
44  void beginJob() override;
45  void beginRun(edm::Run const&, edm::EventSetup const&) override;
46  void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
47  void analyze(edm::Event const&, edm::EventSetup const&) override;
48  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
49  void endRun(edm::Run const&, edm::EventSetup const&) override;
50  void endJob() override;
51 
52  // ----------member data ---------------------------
53  std::vector<edm::EventID> ids_;
54  unsigned int index_;
57 
61 };
62 
63 //
64 // constants, enums and typedefs
65 //
66 
67 //
68 // static data member definitions
69 //
70 
71 //
72 // constructors and destructor
73 //
75  : ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventSequence")),
76  index_(0),
77  multiProcessSequentialEvents_(iConfig.getUntrackedParameter<unsigned int>("multiProcessSequentialEvents")),
78  numberOfEventsLeftBeforeSearch_(0),
79  mustSearch_(false) {
80  //now do what ever initialization is needed
81 }
82 
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86 }
87 
88 //
89 // member functions
90 //
91 
92 namespace {
93  struct CompareWithoutLumi {
94  CompareWithoutLumi(edm::EventID const& iThis) : m_this(iThis) {}
95  bool operator()(edm::EventID const& iOther) {
96  return m_this.run() == iOther.run() && m_this.event() == iOther.event();
97  }
98  edm::EventID m_this;
99  };
100 } // namespace
101 
102 // ------------ method called to for each event ------------
104  if (mustSearch_) {
107  //the event must be after the last event in our list since multicore doesn't go backwards
108  std::vector<edm::EventID>::iterator itFind =
109  std::find_if(ids_.begin() + index_, ids_.end(), CompareWithoutLumi(iEvent.id()));
110  if (itFind == ids_.end()) {
111  throw cms::Exception("MissedEvent") << "The event " << iEvent.id() << "is not in the list.\n";
112  }
113  index_ = itFind - ids_.begin();
114  }
116  }
117 
118  if (index_ >= ids_.size()) {
119  throw cms::Exception("TooManyEvents")
120  << "Was passes " << ids_.size() << " EventIDs but have processed more events than that\n";
121  }
122  if (iEvent.id().run() != ids_[index_].run() || iEvent.id().event() != ids_[index_].event()) {
123  throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEvent.id()
124  << "\n";
125  }
126 
127  if (presentRun_ != iEvent.run()) {
128  throw cms::Exception("MissingRunTransitionForEvent")
129  << "at event expected Run " << presentRun_ << " but got " << iEvent.run();
130  }
131  if (presentLumi_ != iEvent.luminosityBlock()) {
132  throw cms::Exception("MissingLuminosityBlockTransitionForEvent")
133  << "expected LuminosityBlock " << presentLumi_ << " but got " << iEvent.luminosityBlock();
134  }
135 
136  ++index_;
137 }
138 
139 void EventIDChecker::beginRun(edm::Run const& iRun, edm::EventSetup const&) { presentRun_ = iRun.run(); }
141  if (presentRun_ != iLumi.run()) {
142  throw cms::Exception("WrongRunForLuminosityBlock")
143  << "at beginLuminosityBlock expected Run " << presentRun_ << " but got " << iLumi.run();
144  }
145  presentLumi_ = iLumi.luminosityBlock();
146 }
147 
149  if (presentRun_ != iLumi.run()) {
150  throw cms::Exception("WrongRunForLuminosityBlock")
151  << "at endLuminosityBlock expected Run " << presentRun_ << " but got " << iLumi.run();
152  }
153  if (presentLumi_ != iLumi.luminosityBlock()) {
154  throw cms::Exception("WrongEndLuminosityBlock")
155  << "expected LuminosityBlock " << presentLumi_ << " but got " << iLumi.luminosityBlock();
156  }
157 }
159  if (presentRun_ != iRun.run()) {
160  throw cms::Exception("WrongEndRun") << "expected Run " << presentRun_ << " but got " << iRun.run();
161  }
162 }
163 
164 // ------------ method called once each job just before starting event loop ------------
166 
167 // ------------ method called once each job just after ending the event loop ------------
169 
170 // ------------ method called once each job for validation
173  desc.addUntracked<std::vector<edm::EventID> >("eventSequence");
174  desc.addUntracked<unsigned int>("multiProcessSequentialEvents", 0U);
175  descriptions.add("eventIDChecker", desc);
176 }
177 
178 //define this as a plug-in
ConfigurationDescriptions.h
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
EDAnalyzer.h
funct::false
false
Definition: Factorize.h:29
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
EventIDChecker::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EventIDChecker.cc:148
edm
HLT enums.
Definition: AlignableModifier.h:19
EventIDChecker::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: EventIDChecker.cc:158
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::LuminosityBlockBase::run
RunNumber_t run() const
Definition: LuminosityBlockBase.h:42
EventIDChecker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EventIDChecker.cc:171
EventIDChecker::endJob
void endJob() override
Definition: EventIDChecker.cc:168
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
EventIDChecker::numberOfEventsLeftBeforeSearch_
unsigned int numberOfEventsLeftBeforeSearch_
Definition: EventIDChecker.cc:59
EventIDChecker::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: EventIDChecker.cc:103
EventIDChecker::beginJob
void beginJob() override
Definition: EventIDChecker.cc:165
MakerMacros.h
EventIDChecker::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EventIDChecker.cc:140
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
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
EventID.h
ParameterSetDescription.h
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
EventIDChecker::EventIDChecker
EventIDChecker(edm::ParameterSet const &)
Definition: EventIDChecker.cc:74
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EventIDChecker::mustSearch_
bool mustSearch_
Definition: EventIDChecker.cc:60
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:57
EventIDChecker::multiProcessSequentialEvents_
unsigned int multiProcessSequentialEvents_
Definition: EventIDChecker.cc:58
EventIDChecker
Definition: EventIDChecker.cc:37
EventIDChecker::~EventIDChecker
~EventIDChecker() override
Definition: EventIDChecker.cc:83
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
EventIDChecker::presentLumi_
edm::LuminosityBlockNumber_t presentLumi_
Definition: EventIDChecker.cc:56
Exception
Definition: hltDiff.cc:246
EventIDChecker::presentRun_
edm::RunNumber_t presentRun_
Definition: EventIDChecker.cc:55
EventIDChecker::ids_
std::vector< edm::EventID > ids_
Definition: EventIDChecker.cc:53
ParameterSet.h
EventIDChecker::index_
unsigned int index_
Definition: EventIDChecker.cc:54
edm::EventID
Definition: EventID.h:31
edm::Event
Definition: Event.h:73
EventIDChecker::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: EventIDChecker.cc:139