CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "FWCore/Sources/interface/ProducerSourceBase.h"
00002 #include <string>
00003 namespace cond {
00004   class EmptyIOVSource : public edm::ProducerSourceBase {
00005   public:
00006     typedef unsigned long long Time_t;
00007     EmptyIOVSource(edm::ParameterSet const&, edm::InputSourceDescription const&);
00008     ~EmptyIOVSource();
00009   private:
00010     virtual void produce(edm::Event & e);
00011     virtual bool setRunAndEventInfo(edm::EventID& id, edm::TimeValue_t& time);
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::ProducerSourceBase(pset,desc,true),
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   }
00038   EmptyIOVSource::~EmptyIOVSource() {
00039   }
00040   void EmptyIOVSource::produce( edm::Event & ) {
00041   }  
00042   bool EmptyIOVSource::setRunAndEventInfo(edm::EventID& id, edm::TimeValue_t& time){
00043     if(m_current<=m_lastValid){
00044       if( m_timeType=="runnumber" ){
00045         id = edm::EventID(m_current, id.luminosityBlock(), 1);
00046       }else if( m_timeType=="timestamp" ){
00047         time = m_current;
00048       }else if( m_timeType=="lumiid" ){
00049         edm::LuminosityBlockID l(m_current);
00050         id = edm::EventID(l.run(), l.luminosityBlock(), 1);
00051         //std::cout<<"run "<<l.run()<<std::endl;
00052         //std::cout<<"luminosityBlock "<<l.luminosityBlock()<<std::endl;
00053       }else{
00054         throw edm::Exception(edm::errors::Configuration, std::string("EmptyIOVSource::setRunAndEventInfo: ")+m_timeType+std::string("is not one of the supported types: runnumber,timestamp,lumiid") );
00055       }
00056     }
00057     bool ok = !(m_lastValid<m_current);
00058     m_current += m_interval;
00059     return ok;
00060   }
00061 }//ns cond
00062 
00063 #include "FWCore/Framework/interface/InputSourceMacros.h"
00064 using cond::EmptyIOVSource;
00065 
00066 DEFINE_FWK_INPUT_SOURCE(EmptyIOVSource);