CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CommonTools/UtilAlgos/plugins/EventCountProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EventCountProducer
00004 // Class:      EventCountProducer
00005 // 
00013 // system include files
00014 #include <memory>
00015 #include <vector>
00016 #include <algorithm>
00017 #include <iostream>
00018 
00019 // user include files
00020 #include "FWCore/Framework/interface/Frameworkfwd.h"
00021 #include "FWCore/Framework/interface/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::EDProducer {
00031 public:
00032   explicit EventCountProducer(const edm::ParameterSet&);
00033   ~EventCountProducer();
00034 
00035 private:
00036   virtual void produce(edm::Event &, const edm::EventSetup &);
00037   virtual void beginLuminosityBlock(edm::LuminosityBlock &, const edm::EventSetup &);
00038   virtual void endLuminosityBlock(edm::LuminosityBlock &, const edm::EventSetup &);
00039       
00040   // ----------member data ---------------------------
00041 
00042   unsigned int eventsProcessedInLumi_;
00043 
00044 };
00045 
00046 
00047 
00048 using namespace edm;
00049 using namespace std;
00050 
00051 
00052 
00053 EventCountProducer::EventCountProducer(const edm::ParameterSet& iConfig){
00054   produces<edm::MergeableCounter, edm::InLumi>();
00055 }
00056 
00057 
00058 EventCountProducer::~EventCountProducer(){}
00059 
00060 
00061 void
00062 EventCountProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){
00063   eventsProcessedInLumi_++;
00064   return;
00065 }
00066 
00067 
00068 void 
00069 EventCountProducer::beginLuminosityBlock(LuminosityBlock & theLuminosityBlock, const EventSetup & theSetup) {
00070   eventsProcessedInLumi_ = 0;
00071   return;
00072 }
00073 
00074 
00075 void 
00076 EventCountProducer::endLuminosityBlock(LuminosityBlock & theLuminosityBlock, const EventSetup & theSetup) {
00077   LogTrace("EventCounting") << "endLumi: adding " << eventsProcessedInLumi_ << " events" << endl;
00078 
00079   auto_ptr<edm::MergeableCounter> numEventsPtr(new edm::MergeableCounter);
00080   numEventsPtr->value = eventsProcessedInLumi_;
00081   theLuminosityBlock.put(numEventsPtr);
00082 
00083   return;
00084 }
00085 
00086 
00087 
00088 //define this as a plug-in
00089 DEFINE_FWK_MODULE(EventCountProducer);