1 #include "FWCore/Framework/interface/Event.h"
2 #include "FWCore/ParameterSet/interface/ParameterSet.h"
3 #include "FWCore/Sources/interface/ProducerSourceFromFiles.h"
4 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
6 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
7 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
24 explicit HGCalTBTextSource(
const edm::ParameterSet & pset, edm::InputSourceDescription
const& desc) : edm::ProducerSourceFromFiles(pset, desc, true),
26 m_run(pset.getUntrackedParameter<int>(
"run", 101))
29 m_sourceId = pset.getUntrackedParameter<
int>(
"fed", 1000);
30 produces<FEDRawDataCollection>();
35 if (m_file != 0) fclose(m_file);
42 virtual bool setRunAndEventInfo(edm::EventID&
id, edm::TimeValue_t& time, edm::EventAuxiliary::ExperimentType&)
45 if (!(fileNames().size()))
return false;
47 std::string name = fileNames()[0].c_str();
48 if (name.find(
"file:") == 0) name = name.substr(5);
49 m_file = fopen(name.c_str(),
"r");
51 throw cms::Exception(
"FileNotFound") <<
"Unable to open file " << name;
55 if (feof(m_file))
return false;
56 if (!readLines())
return false;
59 id = edm::EventID(m_run, 1, m_event);
61 edm::TimeValue_t present_time = presentTime();
62 unsigned long time_between_events = timeBetweenEvents();
64 time = present_time + time_between_events;
67 virtual void produce(edm::Event & e);
70 std::vector<std::string> m_lines;
72 unsigned int m_time_tmp, m_run_tmp;
virtual ~HGCalTBTextSource()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
convert data from txt file to FEDRawData
HGCalTBTextSource(const edm::ParameterSet &pset, edm::InputSourceDescription const &desc)