CMS 3D CMS Logo

EventCountProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EventCountProducer
4 // Class: EventCountProducer
5 //
12 // system include files
13 #include <memory>
14 #include <vector>
15 #include <algorithm>
16 #include <iostream>
17 
18 // user include files
25 
27 
29  : public edm::one::EDProducer<edm::one::WatchLuminosityBlocks, edm::EndLuminosityBlockProducer> {
30 public:
31  explicit EventCountProducer(const edm::ParameterSet&);
32  ~EventCountProducer() override;
33 
34 private:
35  void produce(edm::Event&, const edm::EventSetup&) override;
36  void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
37  void endLuminosityBlock(edm::LuminosityBlock const&, const edm::EventSetup&) override;
39 
40  // ----------member data ---------------------------
41 
42  unsigned int eventsProcessedInLumi_;
43 };
44 
45 using namespace edm;
46 using namespace std;
47 
49  produces<edm::MergeableCounter, edm::Transition::EndLuminosityBlock>();
50 }
51 
53 
55  eventsProcessedInLumi_++;
56  return;
57 }
58 
59 void EventCountProducer::beginLuminosityBlock(const LuminosityBlock& theLuminosityBlock, const EventSetup& theSetup) {
60  eventsProcessedInLumi_ = 0;
61  return;
62 }
63 
64 void EventCountProducer::endLuminosityBlock(LuminosityBlock const& theLuminosityBlock, const EventSetup& theSetup) {}
65 
66 void EventCountProducer::endLuminosityBlockProduce(LuminosityBlock& theLuminosityBlock, const EventSetup& theSetup) {
67  LogTrace("EventCounting") << "endLumi: adding " << eventsProcessedInLumi_ << " events" << endl;
68 
69  unique_ptr<edm::MergeableCounter> numEventsPtr(new edm::MergeableCounter);
70  numEventsPtr->value = eventsProcessedInLumi_;
71  theLuminosityBlock.put(std::move(numEventsPtr));
72 
73  return;
74 }
75 
76 //define this as a plug-in
unsigned int eventsProcessedInLumi_
void produce(edm::Event &, const edm::EventSetup &) override
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
EventCountProducer(const edm::ParameterSet &)
void put(std::unique_ptr< PROD > product)
Put a new product.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void endLuminosityBlockProduce(edm::LuminosityBlock &, const edm::EventSetup &) override
HLT enums.
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
void endLuminosityBlock(edm::LuminosityBlock const &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511
~EventCountProducer() override