Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014 #include <memory>
00015 #include <vector>
00016 #include <algorithm>
00017 #include <iostream>
00018
00019
00020 #include "FWCore/Framework/interface/Frameworkfwd.h"
00021 #include "FWCore/Framework/interface/one/EDProducer.h"
00022 #include "FWCore/Framework/interface/Event.h"
00023 #include "FWCore/Framework/interface/LuminosityBlock.h"
00024 #include "FWCore/Framework/interface/MakerMacros.h"
00025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00026
00027 #include "DataFormats/Common/interface/MergeableCounter.h"
00028
00029
00030 class EventCountProducer : public edm::one::EDProducer<edm::one::WatchLuminosityBlocks,
00031 edm::EndLuminosityBlockProducer> {
00032 public:
00033 explicit EventCountProducer(const edm::ParameterSet&);
00034 ~EventCountProducer();
00035
00036 private:
00037 virtual void produce(edm::Event &, const edm::EventSetup&) override;
00038 virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup&) override;
00039 virtual void endLuminosityBlock(edm::LuminosityBlock const&, const edm::EventSetup&) override;
00040 virtual void endLuminosityBlockProduce(edm::LuminosityBlock &, const edm::EventSetup&) override;
00041
00042
00043
00044 unsigned int eventsProcessedInLumi_;
00045
00046 };
00047
00048
00049
00050 using namespace edm;
00051 using namespace std;
00052
00053
00054
00055 EventCountProducer::EventCountProducer(const edm::ParameterSet& iConfig){
00056 produces<edm::MergeableCounter, edm::InLumi>();
00057 }
00058
00059
00060 EventCountProducer::~EventCountProducer(){}
00061
00062
00063 void
00064 EventCountProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){
00065 eventsProcessedInLumi_++;
00066 return;
00067 }
00068
00069
00070 void
00071 EventCountProducer::beginLuminosityBlock(const LuminosityBlock & theLuminosityBlock, const EventSetup & theSetup) {
00072 eventsProcessedInLumi_ = 0;
00073 return;
00074 }
00075
00076 void
00077 EventCountProducer::endLuminosityBlock(LuminosityBlock const& theLuminosityBlock, const EventSetup & theSetup) {
00078 }
00079
00080 void
00081 EventCountProducer::endLuminosityBlockProduce(LuminosityBlock & theLuminosityBlock, const EventSetup & theSetup) {
00082 LogTrace("EventCounting") << "endLumi: adding " << eventsProcessedInLumi_ << " events" << endl;
00083
00084 auto_ptr<edm::MergeableCounter> numEventsPtr(new edm::MergeableCounter);
00085 numEventsPtr->value = eventsProcessedInLumi_;
00086 theLuminosityBlock.put(numEventsPtr);
00087
00088 return;
00089 }
00090
00091
00092
00093
00094 DEFINE_FWK_MODULE(EventCountProducer);