CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/DPGAnalysis/SiStripTools/plugins/EventWithHistoryProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EventWithHistoryProducer
00004 // Class:      EventWithHistoryProducer
00005 // 
00013 //
00014 // Original Author:  Andrea Venturi
00015 //         Created:  Sun Nov 30 19:05:41 CET 2008
00016 // $Id: EventWithHistoryProducer.cc,v 1.2 2010/01/12 09:13:04 venturia Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 
00034 //#include "DPGAnalysis/SiStripTools/interface/TinyEvent.h"
00035 #include "DPGAnalysis/SiStripTools/interface/EventWithHistory.h"
00036 
00037 //
00038 // class decleration
00039 //
00040 
00041 class EventWithHistoryProducer : public edm::EDProducer {
00042    public:
00043       explicit EventWithHistoryProducer(const edm::ParameterSet&);
00044       ~EventWithHistoryProducer();
00045 
00046    private:
00047       virtual void beginJob() ;
00048       virtual void produce(edm::Event&, const edm::EventSetup&);
00049       virtual void endJob() ;
00050       
00051       // ----------member data ---------------------------
00052 
00053   const unsigned int _depth;
00054   EventWithHistory _prevHE;
00055 };
00056 
00057 //
00058 // constants, enums and typedefs
00059 //
00060 
00061 
00062 //
00063 // static data member definitions
00064 //
00065 
00066 //
00067 // constructors and destructor
00068 //
00069 EventWithHistoryProducer::EventWithHistoryProducer(const edm::ParameterSet& iConfig):
00070   _depth(iConfig.getUntrackedParameter<unsigned int>("historyDepth")),
00071   _prevHE() 
00072 {
00073 
00074   produces<EventWithHistory>();
00075 
00076    //now do what ever other initialization is needed
00077   
00078 }
00079 
00080 
00081 EventWithHistoryProducer::~EventWithHistoryProducer()
00082 {
00083  
00084    // do anything here that needs to be done at desctruction time
00085    // (e.g. close files, deallocate resources etc.)
00086 
00087 }
00088 
00089 
00090 //
00091 // member functions
00092 //
00093 
00094 // ------------ method called to produce the data  ------------
00095 void
00096 EventWithHistoryProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00097 {
00098 
00099   using namespace edm;
00100 
00101   std::auto_ptr<EventWithHistory> heOut(new EventWithHistory(iEvent.id().event(),iEvent.orbitNumber(),iEvent.bunchCrossing()));
00102   heOut->add(_prevHE,_depth);
00103 
00104   if(*heOut < _prevHE) edm::LogInfo("EventsNotInOrder") << " Events not in order " << _prevHE._event;
00105 
00106   _prevHE = *heOut;
00107   iEvent.put(heOut);
00108   
00109 }
00110 
00111 // ------------ method called once each job just before starting event loop  ------------
00112 void 
00113 EventWithHistoryProducer::beginJob()
00114 {
00115 }
00116 
00117 // ------------ method called once each job just after ending the event loop  ------------
00118 void 
00119 EventWithHistoryProducer::endJob() {
00120 }
00121 
00122 //define this as a plug-in
00123 DEFINE_FWK_MODULE(EventWithHistoryProducer);