CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CondCore/Utilities/plugins/EmptyIOVSource.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/ConfigurableInputSource.h"
00002 #include <string>
00003 namespace cond {
00004   class EmptyIOVSource : public edm::ConfigurableInputSource {
00005   public:
00006     typedef unsigned long long Time_t;
00007     EmptyIOVSource(edm::ParameterSet const&, edm::InputSourceDescription const&);
00008     ~EmptyIOVSource();
00009   private:
00010     virtual bool produce(edm::Event & e);
00011     virtual void setRunAndEventInfo();
00012   private:
00013     std::string m_timeType;
00014     Time_t m_firstValid;
00015     Time_t m_lastValid;
00016     Time_t m_interval;
00017     Time_t m_current;
00018   };
00019 }
00020 
00021 #include "FWCore/Utilities/interface/EDMException.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 #include "FWCore/Framework/interface/IOVSyncValue.h"
00024 //#include "DataFormats/Provenance/interface/EventID.h"
00025 //#include <iostream>
00026 namespace cond{
00027   //allowed parameters: firstRun, firstTime, lastRun, lastTime, 
00028   //common paras: timetype,interval
00029   EmptyIOVSource::EmptyIOVSource(edm::ParameterSet const& pset,
00030                                  edm::InputSourceDescription const& desc):
00031     edm::ConfigurableInputSource(pset,desc),
00032     m_timeType(pset.getParameter<std::string>("timetype")),
00033     m_firstValid(pset.getParameter<unsigned long long>("firstValue")),
00034     m_lastValid(pset.getParameter<unsigned long long>("lastValue")),
00035     m_interval(pset.getParameter<unsigned long long>("interval")){
00036     m_current=m_firstValid;
00037     setRunAndEventInfo(); 
00038   }
00039   EmptyIOVSource::~EmptyIOVSource() {
00040   }
00041   bool EmptyIOVSource::produce( edm::Event & e ) {
00042     bool ok = !(m_lastValid<m_current);
00043     m_current += m_interval;
00044     return ok;
00045   }  
00046   void EmptyIOVSource::setRunAndEventInfo(){
00047     if(m_current<=m_lastValid){
00048       if( m_timeType=="runnumber" ){
00049         setRunNumber(m_current);
00050       }else if( m_timeType=="timestamp" ){
00051         setTime(m_current);
00052       }else if( m_timeType=="lumiid" ){
00053         edm::LuminosityBlockID l(m_current);
00054         setRunNumber(l.run());
00055         //std::cout<<"run "<<l.run()<<std::endl;
00056         //std::cout<<"luminosityBlock "<<l.luminosityBlock()<<std::endl;
00057         setLuminosityBlockNumber_t(l.luminosityBlock());
00058       }else{
00059         throw edm::Exception(edm::errors::Configuration, std::string("EmptyIOVSource::setRunAndEventInfo: ")+m_timeType+std::string("is not one of the supported types: runnumber,timestamp,lumiid") );
00060       }
00061       setEventNumber(1);
00062     }
00063   }
00064 }//ns cond
00065 
00066 #include "FWCore/PluginManager/interface/ModuleDef.h"
00067 #include "FWCore/Framework/interface/InputSourceMacros.h"
00068 using cond::EmptyIOVSource;
00069 
00070 DEFINE_FWK_INPUT_SOURCE(EmptyIOVSource);