#include <IORawData/EcalTBInputService/src/DAQEcalTBInputService.h>
Public Member Functions | |
DAQEcalTBInputService (const edm::ParameterSet &pset, const edm::InputSourceDescription &desc) | |
virtual | ~DAQEcalTBInputService () |
Protected Member Functions | |
virtual bool | produce (edm::Event &e) |
virtual void | setRunAndEventInfo () |
Private Attributes | |
bool | eventRead_ |
unsigned int | fileCounter_ |
bool | isBinary_ |
EcalTBDaqFileReader * | reader_ |
unsigned int | runNumber_ |
Definition at line 27 of file DAQEcalTBInputService.h.
DAQEcalTBInputService::DAQEcalTBInputService | ( | const edm::ParameterSet & | pset, | |
const edm::InputSourceDescription & | desc | |||
) |
Definition at line 20 of file DAQEcalTBInputService.cc.
References edm::ParameterSet::getUntrackedParameter(), isBinary_, reader_, and runNumber_.
00021 : 00022 edm::ExternalInputSource(pset,desc), reader_(0), fileCounter_(0), eventRead_(0) 00023 { 00024 isBinary_= pset.getUntrackedParameter<bool>("isBinary",true); 00025 if ( isBinary_ ) { 00026 LogInfo("EcalTBInputService") << "@SUB=DAQEcalTBInputService" << "BINARY input data file"; 00027 } else { 00028 LogInfo("EcalTBInputService") << "@SUB=DAQEcalTBInputService" << "ASCII input data file"; 00029 } 00030 runNumber_ = pset.getUntrackedParameter<unsigned int>("runNumber", 1); 00031 reader_ = new EcalTBDaqFileReader(); 00032 produces<FEDRawDataCollection>(); 00033 }
DAQEcalTBInputService::~DAQEcalTBInputService | ( | ) | [virtual] |
bool DAQEcalTBInputService::produce | ( | edm::Event & | e | ) | [protected, virtual] |
Implements edm::ConfigurableInputSource.
Definition at line 83 of file DAQEcalTBInputService.cc.
References edmNew::copy(), FEDRawData::data(), eventRead_, FedDataPair::fedData, EcalTBDaqFileReader::getEventNumber(), EcalTBDaqFileReader::getFedData(), EcalTBDaqFileReader::getFedId(), EcalTBDaqFileReader::getRunNumber(), FedDataPair::len, edm::Event::put(), reader_, and FEDRawData::resize().
00084 { 00085 if (! eventRead_ ) 00086 return false; 00087 00088 std::auto_ptr<FEDRawDataCollection> bare_product(new FEDRawDataCollection()); 00089 00090 FEDRawData& eventfeddata = (*bare_product).FEDData(reader_->getFedId()); 00091 eventfeddata.resize(reader_->getFedData().len); 00092 copy(reader_->getFedData().fedData, reader_->getFedData().fedData + reader_->getFedData().len , eventfeddata.data()); 00093 00094 LogInfo("EcalTBInputService") << "@SUB=DAQEcalTBInputService::produce" << "read run " << reader_->getRunNumber() << " ev " << reader_->getEventNumber(); 00095 00096 e.put(bare_product); 00097 00098 return true; 00099 }
void DAQEcalTBInputService::setRunAndEventInfo | ( | ) | [protected, virtual] |
Reimplemented from edm::ConfigurableInputSource.
Definition at line 51 of file DAQEcalTBInputService.cc.
References EcalTBDaqFileReader::checkEndOfFile(), eventRead_, fileCounter_, edm::ExternalInputSource::fileNames(), EcalTBDaqFileReader::fillDaqEventData(), EcalTBDaqFileReader::getEventNumber(), EcalTBDaqFileReader::getRunNumber(), EcalTBDaqFileReader::initialize(), isBinary_, EcalTBDaqFileReader::isInitialized(), edm::ConfigurableInputSource::presentTime(), reader_, runNumber_, edm::ConfigurableInputSource::setEventNumber(), edm::InputSource::setRunNumber(), edm::ConfigurableInputSource::setTime(), and edm::ConfigurableInputSource::timeBetweenEvents().
00052 { 00053 00054 eventRead_=false; 00055 00056 if ( !reader_->isInitialized() || reader_->checkEndOfFile() ) 00057 { 00058 if (fileCounter_>=(unsigned int)(fileNames().size())) return; // nothing good 00059 reader_->initialize(fileNames()[fileCounter_],isBinary_); 00060 fileCounter_++; 00061 } 00062 00063 eventRead_=reader_->fillDaqEventData(); 00064 00065 if (eventRead_) 00066 { 00067 if ( reader_->getRunNumber() != 0 ) { 00068 setRunNumber(reader_->getRunNumber()); 00069 } else { 00070 setRunNumber( runNumber_ ); 00071 } 00072 //For the moment adding 1 by hand (CMS has event number starting from 1) 00073 setEventNumber(reader_->getEventNumber()+1); 00074 // time is a hack 00075 edm::TimeValue_t present_time = presentTime(); 00076 unsigned long time_between_events = timeBetweenEvents(); 00077 setTime(present_time + time_between_events); 00078 } 00079 else 00080 return; 00081 }
bool DAQEcalTBInputService::eventRead_ [private] |
Definition at line 47 of file DAQEcalTBInputService.h.
Referenced by produce(), and setRunAndEventInfo().
unsigned int DAQEcalTBInputService::fileCounter_ [private] |
bool DAQEcalTBInputService::isBinary_ [private] |
Definition at line 45 of file DAQEcalTBInputService.h.
Referenced by DAQEcalTBInputService(), and setRunAndEventInfo().
Definition at line 44 of file DAQEcalTBInputService.h.
Referenced by DAQEcalTBInputService(), produce(), setRunAndEventInfo(), and ~DAQEcalTBInputService().
unsigned int DAQEcalTBInputService::runNumber_ [private] |
Definition at line 49 of file DAQEcalTBInputService.h.
Referenced by DAQEcalTBInputService(), and setRunAndEventInfo().