CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/FWCore/Framework/interface/EDProducer.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_EDProducer_h
00002 #define FWCore_Framework_EDProducer_h
00003 
00004 /*----------------------------------------------------------------------
00005   
00006 EDProducer: The base class of "modules" whose main purpose is to insert new
00007 EDProducts into an Event.
00008 
00009 
00010 ----------------------------------------------------------------------*/
00011 
00012 #include "FWCore/Framework/interface/ProducerBase.h"
00013 #include "FWCore/Framework/interface/Frameworkfwd.h"
00014 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
00016 
00017 #include <string>
00018 #include <vector>
00019 
00020 namespace edm {
00021   class EDProducer : public ProducerBase {
00022   public:
00023     template <typename T> friend class WorkerT;
00024     typedef EDProducer ModuleType;
00025     typedef WorkerT<EDProducer> WorkerType;
00026 
00027     EDProducer ();
00028     virtual ~EDProducer();
00029 
00030     static void fillDescriptions(ConfigurationDescriptions& descriptions);
00031     static void prevalidate(ConfigurationDescriptions& descriptions);
00032     static const std::string& baseType();
00033 
00034   protected:
00035     // The returned pointer will be null unless the this is currently
00036     // executing its event loop function ('produce').
00037     CurrentProcessingContext const* currentContext() const;
00038 
00039   private:
00040     bool doEvent(EventPrincipal& ep, EventSetup const& c,
00041                    CurrentProcessingContext const* cpcp);
00042     void doBeginJob();
00043     void doEndJob();
00044     bool doBeginRun(RunPrincipal& rp, EventSetup const& c,
00045                    CurrentProcessingContext const* cpc);
00046     bool doEndRun(RunPrincipal& rp, EventSetup const& c,
00047                    CurrentProcessingContext const* cpc);
00048     bool doBeginLuminosityBlock(LuminosityBlockPrincipal& lbp, EventSetup const& c,
00049                    CurrentProcessingContext const* cpc);
00050     bool doEndLuminosityBlock(LuminosityBlockPrincipal& lbp, EventSetup const& c,
00051                    CurrentProcessingContext const* cpc);
00052     void doRespondToOpenInputFile(FileBlock const& fb);
00053     void doRespondToCloseInputFile(FileBlock const& fb);
00054     void doRespondToOpenOutputFiles(FileBlock const& fb);
00055     void doRespondToCloseOutputFiles(FileBlock const& fb);
00056     void doPreForkReleaseResources();
00057     void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
00058     void registerAnyProducts(EDProducer* module, ProductRegistry* reg) {
00059       registerProducts(module, reg, moduleDescription_);
00060     }
00061 
00062     std::string workerType() const {return "WorkerT<EDProducer>";}
00063 
00064     virtual void produce(Event&, EventSetup const&) = 0;
00065     virtual void beginJob() {}
00066     virtual void endJob(){}
00067     virtual void beginRun(Run&, EventSetup const&){}
00068     virtual void endRun(Run&, EventSetup const&){}
00069     virtual void beginLuminosityBlock(LuminosityBlock&, EventSetup const&){}
00070     virtual void endLuminosityBlock(LuminosityBlock&, EventSetup const&){}
00071     virtual void respondToOpenInputFile(FileBlock const&) {}
00072     virtual void respondToCloseInputFile(FileBlock const&) {}
00073     virtual void respondToOpenOutputFiles(FileBlock const&) {}
00074     virtual void respondToCloseOutputFiles(FileBlock const&) {}
00075     virtual void preForkReleaseResources() {}
00076     virtual void postForkReacquireResources(unsigned int /*iChildIndex*/, unsigned int /*iNumberOfChildren*/) {}
00077 
00078     void setModuleDescription(ModuleDescription const& md) {
00079       moduleDescription_ = md;
00080     }
00081     ModuleDescription moduleDescription_;
00082     CurrentProcessingContext const* current_context_;
00083     std::vector<BranchID> previousParentage_;
00084     ParentageID previousParentageId_;
00085   };
00086 }
00087 
00088 #endif