CMS 3D CMS Logo

FileBasedEmptySource.cc
Go to the documentation of this file.
5 #include <string>
6 #include <fstream>
7 #include <unistd.h>
8 namespace cond {
10  public:
12  ~FileBasedEmptySource() override;
13  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
14 
15  private:
16  void produce(edm::Event& e) override;
19  edm::EventAuxiliary::ExperimentType& eType) override;
21 
22  private:
23  unsigned int m_interval;
24  unsigned long long m_eventId;
25  unsigned int m_eventsPerLumi;
27  unsigned int m_currentRun;
28  unsigned int m_currentLumi;
29  boost::posix_time::ptime m_currentLumiTime;
30  };
31 } // namespace cond
32 
36 //#include "DataFormats/Provenance/interface/EventID.h"
37 
38 namespace cond {
39  //allowed parameters: firstRun, firstTime, lastRun, lastTime,
40  //common paras: timetype,interval
42  : edm::ProducerSourceBase(pset, desc, true),
43  m_interval(pset.getParameter<unsigned int>("interval")),
44  m_eventId(0),
45  m_eventsPerLumi(pset.getUntrackedParameter<unsigned int>("numberEventsInLuminosityBlock")),
46  m_pathForLastLumiFile(pset.getParameter<std::string>("pathForLastLumiFile")),
47  m_currentRun(0),
48  m_currentLumi(0),
49  m_currentLumiTime() {}
50 
52 
54 
59  {
60  std::ifstream lastLumiFile(m_pathForLastLumiFile);
61  if (lastLumiFile) {
62  lastLumiFile >> lastLumi;
63  } else {
64  std::cout << "Error: last lumi file can't be read." << std::endl;
65  return false;
66  }
67  }
68  auto t = cond::time::unpack(lastLumi);
69  unsigned int runId = t.first;
70  unsigned int lumiId = t.second;
71  //std::cout <<"###### setRunAndEventInfo Run: "<<runId<<" lumi: "<<lumiId<<std::endl;
72  boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
73  if (runId == m_currentRun && lumiId == m_currentLumi) {
74  m_eventId += 1;
75  if (m_eventId >= m_eventsPerLumi) {
76  return false;
77  }
78  } else {
79  m_currentRun = runId;
80  m_currentLumi = lumiId;
82  m_eventId = 1;
83  }
84  std::cout << "###### setRunAndEventInfo Run: " << runId << " lumi: " << lumiId << " event id: " << m_eventId
85  << " time:" << boost::posix_time::to_simple_string(now) << std::endl;
87  id = edm::EventID(runId, lumiId, m_eventId);
88  usleep(20000);
89  return true;
90  }
91 
94  {
95  std::ifstream lastLumiFile(m_pathForLastLumiFile);
96  if (lastLumiFile) {
97  lastLumiFile >> lastLumi;
98  } else {
99  std::cout << "Error: last lumi file can't be read." << std::endl;
100  return;
101  }
102  }
103  m_eventId = 0;
104  auto t = cond::time::unpack(lastLumi);
105  unsigned int runId = t.first;
106  unsigned int lumiId = t.second;
107  std::cout << "###### initialize Run: " << runId << " lumi: " << lumiId << std::endl;
108  m_currentRun = runId;
109  m_currentLumi = lumiId;
110  boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
113  id = edm::EventID(runId, lumiId, m_eventId);
115  }
116 
119  desc.setComment("Creates runs, lumis and events containing no products.");
120  ProducerSourceBase::fillDescription(desc);
121 
122  //desc.add<unsigned int>("firstRunnumber")->setComment("The first run number to use");
123  //desc.add<unsigned int>("lastRunnumber")->setComment("The last run number to use");
124  //desc.add<unsigned int>("firstLumi")->setComment("The first lumi id to use");
125  //desc.add<unsigned int>("lastLumi")->setComment("The last lumi id to use");
126  //desc.add<unsigned int>("maxLumiInRun");
127  //desc.add<std::string>("startTime");
128  //desc.add<std::string>("endTime");
129  desc.add<unsigned int>("interval");
130  desc.add<unsigned int>("maxEvents");
131  desc.add<std::string>("pathForLastLumiFile");
132  descriptions.add("source", desc);
133  }
134 
135 } // namespace cond
136 
139 
ConfigurationDescriptions.h
cond::time::MIN_VAL
const Time_t MIN_VAL(0)
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
cond::FileBasedEmptySource::FileBasedEmptySource
FileBasedEmptySource(edm::ParameterSet const &, edm::InputSourceDescription const &)
Definition: FileBasedEmptySource.cc:41
cond::FileBasedEmptySource::m_eventsPerLumi
unsigned int m_eventsPerLumi
Definition: FileBasedEmptySource.cc:25
edm
HLT enums.
Definition: AlignableModifier.h:19
cond::FileBasedEmptySource::m_currentLumi
unsigned int m_currentLumi
Definition: FileBasedEmptySource.cc:28
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cond::FileBasedEmptySource::m_pathForLastLumiFile
std::string m_pathForLastLumiFile
Definition: FileBasedEmptySource.cc:26
cond::FileBasedEmptySource
Definition: FileBasedEmptySource.cc:9
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ProducerSourceBase
Definition: ProducerSourceBase.h:23
beam_dqm_sourceclient-live_cfg.lastLumiFile
lastLumiFile
Definition: beam_dqm_sourceclient-live_cfg.py:367
edm::InputSourceDescription
Definition: InputSourceDescription.h:20
cond::FileBasedEmptySource::initialize
void initialize(edm::EventID &id, edm::TimeValue_t &time, edm::TimeValue_t &interval) override
Definition: FileBasedEmptySource.cc:92
cond::FileBasedEmptySource::produce
void produce(edm::Event &e) override
Definition: FileBasedEmptySource.cc:53
EDMException.h
fileCollector.now
now
Definition: fileCollector.py:207
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
DEFINE_FWK_INPUT_SOURCE
#define DEFINE_FWK_INPUT_SOURCE(type)
Definition: InputSourceMacros.h:8
cond::FileBasedEmptySource::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: FileBasedEmptySource.cc:117
ParameterSetDescription.h
OrderedSet.t
t
Definition: OrderedSet.py:90
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::FileBasedEmptySource::m_currentLumiTime
boost::posix_time::ptime m_currentLumiTime
Definition: FileBasedEmptySource.cc:29
cond::FileBasedEmptySource::setRunAndEventInfo
bool setRunAndEventInfo(edm::EventID &id, edm::TimeValue_t &time, edm::EventAuxiliary::ExperimentType &eType) override
Definition: FileBasedEmptySource.cc:55
cond
Definition: plugin.cc:23
funct::true
true
Definition: Factorize.h:173
Time.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::ParameterSetDescription::setComment
void setComment(std::string const &value)
Definition: ParameterSetDescription.cc:33
cond::FileBasedEmptySource::~FileBasedEmptySource
~FileBasedEmptySource() override
Definition: FileBasedEmptySource.cc:51
cond::time::from_boost
Time_t from_boost(boost::posix_time::ptime bt)
Definition: TimeConversions.h:43
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
createfilelist.int
int
Definition: createfilelist.py:10
readEcalDQMStatus.interval
interval
Definition: readEcalDQMStatus.py:18
InputSourceMacros.h
std
Definition: JetResolutionObject.h:76
edm::EventAuxiliary::ExperimentType
ExperimentType
Definition: EventAuxiliary.h:18
cond::FileBasedEmptySource::m_interval
unsigned int m_interval
Definition: FileBasedEmptySource.cc:23
cond::time::unpack
cond::UnpackedTime unpack(cond::Time_t iValue)
Definition: TimeConversions.h:22
ParameterSet.h
ntuplemaker.time
time
Definition: ntuplemaker.py:310
edm::EventID
Definition: EventID.h:31
edm::Event
Definition: Event.h:73
IOVSyncValue.h
cond::FileBasedEmptySource::m_currentRun
unsigned int m_currentRun
Definition: FileBasedEmptySource.cc:27
edm::TimeValue_t
unsigned long long TimeValue_t
Definition: Timestamp.h:28
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
cond::FileBasedEmptySource::m_eventId
unsigned long long m_eventId
Definition: FileBasedEmptySource.cc:24
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
ProducerSourceBase.h