00001 #ifndef Framework_Sources_ProducerSourceBase_h 00002 #define Framework_Sources_ProducerSourceBase_h 00003 00004 /*---------------------------------------------------------------------- 00005 ----------------------------------------------------------------------*/ 00006 00007 #include "FWCore/Framework/interface/InputSource.h" 00008 #include "FWCore/Framework/interface/Frameworkfwd.h" 00009 #include "DataFormats/Provenance/interface/EventAuxiliary.h" 00010 #include "DataFormats/Provenance/interface/EventID.h" 00011 #include "DataFormats/Provenance/interface/Timestamp.h" 00012 #include "DataFormats/Provenance/interface/RunID.h" 00013 00014 #include "boost/shared_ptr.hpp" 00015 00016 namespace edm { 00017 class ParameterSet; 00018 class ParameterSetDescription; 00019 class ProducerSourceBase : public InputSource { 00020 public: 00021 explicit ProducerSourceBase(ParameterSet const& pset, InputSourceDescription const& desc, bool realData); 00022 virtual ~ProducerSourceBase(); 00023 00024 unsigned int numberEventsInRun() const {return numberEventsInRun_;} 00025 unsigned int numberEventsInLumi() const {return numberEventsInLumi_;} 00026 TimeValue_t presentTime() const {return presentTime_;} 00027 unsigned int timeBetweenEvents() const {return timeBetweenEvents_;} 00028 unsigned int eventCreationDelay() const {return eventCreationDelay_;} 00029 unsigned int numberEventsInThisRun() const {return numberEventsInThisRun_;} 00030 unsigned int numberEventsInThisLumi() const {return numberEventsInThisLumi_;} 00031 RunNumber_t run() const {return eventID_.run();} 00032 EventNumber_t event() const {return eventID_.event();} 00033 LuminosityBlockNumber_t luminosityBlock() const {return eventID_.luminosityBlock();} 00034 00035 static void fillDescription(ParameterSetDescription& desc); 00036 00037 protected: 00038 00039 private: 00040 virtual ItemType getNextItemType() override; 00041 virtual void initialize(EventID& id, TimeValue_t& time, TimeValue_t& interval); 00042 virtual bool setRunAndEventInfo(EventID& id, TimeValue_t& time) = 0; 00043 virtual void produce(Event& e) = 0; 00044 virtual bool noFiles() const; 00045 virtual size_t fileIndex() const; 00046 virtual void beginJob() override; 00047 virtual void beginRun(Run&) override; 00048 virtual void endRun(Run&) override; 00049 virtual void beginLuminosityBlock(LuminosityBlock&) override; 00050 virtual void endLuminosityBlock(LuminosityBlock&) override; 00051 virtual EventPrincipal* readEvent_(EventPrincipal& eventPrincipal) override; 00052 virtual boost::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() override; 00053 virtual boost::shared_ptr<RunAuxiliary> readRunAuxiliary_() override; 00054 virtual void skip(int offset) override; 00055 virtual void rewind_() override; 00056 00057 void advanceToNext(EventID& eventID, TimeValue_t& time); 00058 void retreatToPrevious(EventID& eventID, TimeValue_t& time); 00059 00060 unsigned int numberEventsInRun_; 00061 unsigned int numberEventsInLumi_; 00062 TimeValue_t presentTime_; 00063 TimeValue_t origTime_; 00064 TimeValue_t timeBetweenEvents_; 00065 unsigned int eventCreationDelay_; /* microseconds */ 00066 00067 unsigned int numberEventsInThisRun_; 00068 unsigned int numberEventsInThisLumi_; 00069 unsigned int const zerothEvent_; 00070 EventID eventID_; 00071 EventID origEventID_; 00072 bool isRealData_; 00073 EventAuxiliary::ExperimentType eType_; 00074 }; 00075 } 00076 #endif