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 
38 public:
39  explicit EventIDChecker(edm::ParameterSet const&);
41  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
42 
43 
44 private:
45  virtual void beginJob() override;
46  virtual void analyze(edm::Event const&, edm::EventSetup const&) override;
47  virtual void endJob() override;
48 
49  // ----------member data ---------------------------
50  std::vector<edm::EventID> ids_;
51  unsigned int index_;
52 
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 //
63 // static data member definitions
64 //
65 
66 //
67 // constructors and destructor
68 //
70  ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventSequence")),
71  index_(0),
72  multiProcessSequentialEvents_(iConfig.getUntrackedParameter<unsigned int>("multiProcessSequentialEvents")),
75 {
76  //now do what ever initialization is needed
77 
78 }
79 
80 
82 
83  // do anything here that needs to be done at desctruction time
84  // (e.g. close files, deallocate resources etc.)
85 
86 }
87 
88 
89 //
90 // member functions
91 //
92 
93 namespace {
94  struct CompareWithoutLumi {
95  CompareWithoutLumi(edm::EventID const& iThis) : m_this(iThis) {
96  }
97  bool operator()(edm::EventID const& iOther) {
98  return m_this.run() == iOther.run() && m_this.event() == iOther.event();
99  }
100  edm::EventID m_this;
101  };
102 }
103 
104 // ------------ method called to for each event ------------
105 void
107  if(mustSearch_) {
110  //the event must be after the last event in our list since multicore doesn't go backwards
111  std::vector<edm::EventID>::iterator itFind= std::find_if(ids_.begin()+index_, ids_.end(), CompareWithoutLumi(iEvent.id()));
112  if(itFind == ids_.end()) {
113  throw cms::Exception("MissedEvent") << "The event " << iEvent.id() << "is not in the list.\n";
114  }
115  index_ = itFind-ids_.begin();
116  }
118  }
119 
120  if(index_ >= ids_.size()) {
121  throw cms::Exception("TooManyEvents") << "Was passes " << ids_.size() << " EventIDs but have processed more events than that\n";
122  }
123  if(iEvent.id().run() != ids_[index_].run() || iEvent.id().event() != ids_[index_].event()) {
124  throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEvent.id() << "\n";
125  }
126  ++index_;
127 }
128 
129 // ------------ method called once each job just before starting event loop ------------
130 void
132 }
133 
134 // ------------ method called once each job just after ending the event loop ------------
135 void
137 }
138 
139 // ------------ method called once each job for validation
140 void
143  desc.addUntracked<std::vector<edm::EventID> >("eventSequence");
144  desc.addUntracked<unsigned int>("multiProcessSequentialEvents", 0U);
145  descriptions.add("eventIDChecker", desc);
146 }
147 
148 
149 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int multiProcessSequentialEvents_
int iEvent
Definition: GenABIO.cc:230
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
unsigned int index_
std::vector< edm::EventID > ids_
unsigned int numberOfEventsLeftBeforeSearch_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
EventIDChecker(edm::ParameterSet const &)
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
virtual void endJob() override
virtual void beginJob() override