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) override;
00011 virtual bool setRunAndEventInfo(edm::EventID& id, edm::TimeValue_t& time) override;
00012 virtual void initialize(edm::EventID& id, edm::TimeValue_t& time, edm::TimeValue_t& interval) override;
00013 private:
00014 std::string m_timeType;
00015 Time_t m_firstValid;
00016 Time_t m_lastValid;
00017 Time_t m_interval;
00018 Time_t m_current;
00019 };
00020 }
00021
00022 #include "FWCore/Utilities/interface/EDMException.h"
00023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00024 #include "FWCore/Framework/interface/IOVSyncValue.h"
00025
00026
00027 namespace cond{
00028
00029
00030 EmptyIOVSource::EmptyIOVSource(edm::ParameterSet const& pset,
00031 edm::InputSourceDescription const& desc):
00032 edm::ProducerSourceBase(pset,desc,true),
00033 m_timeType(pset.getParameter<std::string>("timetype")),
00034 m_firstValid(pset.getParameter<unsigned long long>("firstValue")),
00035 m_lastValid(pset.getParameter<unsigned long long>("lastValue")),
00036 m_interval(pset.getParameter<unsigned long long>("interval")){
00037 m_current=m_firstValid;
00038 }
00039 EmptyIOVSource::~EmptyIOVSource() {
00040 }
00041 void EmptyIOVSource::produce( edm::Event & ) {
00042 }
00043 bool EmptyIOVSource::setRunAndEventInfo(edm::EventID& id, edm::TimeValue_t& time){
00044 if(m_current<=m_lastValid){
00045 if( m_timeType=="runnumber" ){
00046 id = edm::EventID(m_current, id.luminosityBlock(), 1);
00047 }else if( m_timeType=="timestamp" ){
00048 time = m_current;
00049 }else if( m_timeType=="lumiid" ){
00050 edm::LuminosityBlockID l(m_current);
00051 id = edm::EventID(l.run(), l.luminosityBlock(), 1);
00052
00053
00054 }
00055 }
00056 bool ok = !(m_lastValid<m_current);
00057 m_current += m_interval;
00058 return ok;
00059 }
00060 void EmptyIOVSource::initialize(edm::EventID& id, edm::TimeValue_t& time, edm::TimeValue_t& interval){
00061 if( m_timeType=="runnumber" ){
00062 id = edm::EventID(m_firstValid, id.luminosityBlock(), 1);
00063 interval = 0LL;
00064 }else if( m_timeType=="timestamp" ){
00065 time = m_firstValid;
00066 interval = m_interval;
00067 }else if( m_timeType=="lumiid" ){
00068 edm::LuminosityBlockID l(m_firstValid);
00069 id = edm::EventID(l.run(), l.luminosityBlock(), 1);
00070 interval = 0LL;
00071 }else{
00072 throw edm::Exception(edm::errors::Configuration, std::string("EmptyIOVSource::initialize: ")+m_timeType+std::string("is not one of the supported types: runnumber,timestamp,lumiid") );
00073 }
00074 }
00075
00076 }
00077
00078 #include "FWCore/Framework/interface/InputSourceMacros.h"
00079 using cond::EmptyIOVSource;
00080
00081 DEFINE_FWK_INPUT_SOURCE(EmptyIOVSource);