CMS 3D CMS Logo

RunLumiEventChecker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Modules
4 // Class: RunLumiEventChecker
5 //
13 //
14 // Original Author: Chris Jones
15 // Created: Tue Jun 16 15:42:17 CDT 2009
16 //
17 //
18 
19 // user include files
31 
32 // system include files
33 #include <algorithm>
34 #include <map>
35 #include <memory>
36 #include <vector>
37 #include <map>
38 
39 //
40 // class decleration
41 //
42 
44 public:
45  explicit RunLumiEventChecker(edm::ParameterSet const&);
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49 private:
50  virtual void beginJob() override;
51  virtual void analyze(edm::Event const&, edm::EventSetup const&) override;
52  virtual void endJob() override;
53 
54  virtual void beginRun(edm::Run const& run, edm::EventSetup const& es) override;
55  virtual void endRun(edm::Run const& run, edm::EventSetup const& es) override;
56 
57  virtual void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) override;
58  virtual void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) override;
59 
60  void check(edm::EventID const& iID, bool isEvent);
61 
62  // ----------member data ---------------------------
63  std::vector<edm::EventID> ids_;
64  unsigned int index_;
65  std::map<edm::EventID, unsigned int> seenIDs_;
66 
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81  ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventSequence")),
82  index_(0)
83 {
84  //now do what ever initialization is needed
85 }
86 
87 
89  // do anything here that needs to be done at desctruction time
90  // (e.g. close files, deallocate resources etc.)
91 }
92 
93 //
94 // member functions
95 //
96 
97 void
98 RunLumiEventChecker::check(edm::EventID const& iEventID, bool iIsEvent) {
99  if(index_ >= ids_.size()) {
100  throw cms::Exception("TooManyEvents") << "Was passes " << ids_.size() << " EventIDs but have processed more events than that\n";
101  }
102  if(iEventID != ids_[index_]) {
103  throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEventID << "\n";
104  }
105  ++index_;
106 }
107 
108 // ------------ method called to for each event ------------
109 void
111  check(iEvent.id(), true);
112 }
113 
114 void
116  check(edm::EventID(run.id().run(), 0, 0), false);
117 }
118 void
120  check(edm::EventID(run.id().run(), 0, 0), false);
121 }
122 
123 void
125  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
126 }
127 
128 void
130  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
131 }
132 
133 
134 // ------------ method called once each job just before starting event loop ------------
135 void
137 }
138 
139 // ------------ method called once each job just after ending the event loop ------------
140 void
142  if(index_ != ids_.size()) {
143  throw cms::Exception("WrongNumberOfEvents")<<"Saw "<<index_<<" events but was supposed to see "<<ids_.size()<<"\n";
144  }
145 }
146 
147 // ------------ method called once each job for validation
148 void
151  desc.addUntracked<std::vector<edm::EventID> >("eventSequence");
152  descriptions.add("runLumiEventIDChecker", desc);
153 }
154 
155 //define this as a plug-in
LuminosityBlockID id() const
virtual void beginJob() override
std::vector< edm::EventID > ids_
virtual void endJob() override
RunID const & id() const
Definition: RunBase.h:39
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
RunNumber_t run() const
Definition: RunID.h:39
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::map< edm::EventID, unsigned int > seenIDs_
RunLumiEventChecker(edm::ParameterSet const &)
int iEvent
Definition: GenABIO.cc:230
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
RunNumber_t run() const
void check(edm::EventID const &iID, bool isEvent)
virtual void beginRun(edm::Run const &run, edm::EventSetup const &es) override
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &es) override
LuminosityBlockNumber_t luminosityBlock() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void endRun(edm::Run const &run, edm::EventSetup const &es) override
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &es) override
Definition: Run.h:42