File indexing completed on 2024-04-06 12:01:53
0001 #include "FWCore/Sources/interface/ProducerSourceBase.h"
0002 #include "CondCore/CondDB/interface/Time.h"
0003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include <string>
0006 namespace cond {
0007 class EmptyIOVSource : public edm::ProducerSourceBase {
0008 public:
0009 EmptyIOVSource(edm::ParameterSet const&, edm::InputSourceDescription const&);
0010 ~EmptyIOVSource() override;
0011 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0012
0013 private:
0014 void produce(edm::Event& e) override;
0015 bool setRunAndEventInfo(edm::EventID& id,
0016 edm::TimeValue_t& time,
0017 edm::EventAuxiliary::ExperimentType& eType) override;
0018 void initialize(edm::EventID& id, edm::TimeValue_t& time, edm::TimeValue_t& interval) override;
0019
0020 private:
0021 TimeType m_timeType;
0022 Time_t m_firstValid;
0023 Time_t m_lastValid;
0024 Time_t m_interval;
0025 Time_t m_current;
0026 };
0027 }
0028
0029 #include "FWCore/Utilities/interface/EDMException.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Framework/interface/IOVSyncValue.h"
0032
0033
0034 namespace cond {
0035
0036
0037 EmptyIOVSource::EmptyIOVSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc)
0038 : edm::ProducerSourceBase(pset, desc, true),
0039 m_timeType(time::timeTypeFromName(pset.getParameter<std::string>("timetype"))),
0040 m_firstValid(pset.getParameter<unsigned long long>("firstValue")),
0041 m_lastValid(pset.getParameter<unsigned long long>("lastValue")),
0042 m_interval(pset.getParameter<unsigned long long>("interval")) {
0043 m_current = m_firstValid;
0044 }
0045 EmptyIOVSource::~EmptyIOVSource() {}
0046 void EmptyIOVSource::produce(edm::Event&) {}
0047 bool EmptyIOVSource::setRunAndEventInfo(edm::EventID& id,
0048 edm::TimeValue_t& time,
0049 edm::EventAuxiliary::ExperimentType& eType) {
0050 if (m_current <= m_lastValid) {
0051 if (m_timeType == cond::runnumber) {
0052 id = edm::EventID(m_current, id.luminosityBlock(), 1);
0053 } else if (m_timeType == cond::timestamp) {
0054 time = m_current;
0055 } else if (m_timeType == cond::lumiid) {
0056 edm::LuminosityBlockID l(m_current);
0057 id = edm::EventID(l.run(), l.luminosityBlock(), 1);
0058
0059
0060 }
0061 }
0062 bool ok = !(m_lastValid < m_current);
0063 m_current += m_interval;
0064 return ok;
0065 }
0066 void EmptyIOVSource::initialize(edm::EventID& id, edm::TimeValue_t& time, edm::TimeValue_t& interval) {
0067 if (m_timeType == cond::runnumber) {
0068 id = edm::EventID(m_firstValid, id.luminosityBlock(), 1);
0069 interval = 0LL;
0070 } else if (m_timeType == cond::timestamp) {
0071 time = m_firstValid;
0072 interval = m_interval;
0073 } else if (m_timeType == cond::lumiid) {
0074 edm::LuminosityBlockID l(m_firstValid);
0075 id = edm::EventID(l.run(), l.luminosityBlock(), 1);
0076 interval = 0LL;
0077 }
0078 }
0079
0080 void EmptyIOVSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0081 edm::ParameterSetDescription desc;
0082 desc.setComment("Creates runs, lumis and events containing no products.");
0083 ProducerSourceBase::fillDescription(desc);
0084
0085 desc.add<std::string>("timetype");
0086 desc.add<unsigned long long>("firstValue")->setComment("The first run number to use or the first time");
0087 desc.add<unsigned long long>("lastValue")->setComment("The last run number to use or the last time");
0088 desc.add<unsigned long long>("interval");
0089
0090 descriptions.add("source", desc);
0091 }
0092
0093 }
0094
0095 #include "FWCore/Framework/interface/InputSourceMacros.h"
0096 using cond::EmptyIOVSource;
0097
0098 DEFINE_FWK_INPUT_SOURCE(EmptyIOVSource);