#include <TestFileReader.h>
Public Member Functions | |
void | join () |
void | start () |
TestFileReader (std::string const &filename, edm::EventBuffer &to, edm::ProductRegistry &prods) | |
virtual | ~TestFileReader () |
Private Member Functions | |
void | readEvents () |
Static Private Member Functions | |
static void | run (TestFileReader *) |
Private Attributes | |
std::string | filename_ |
boost::shared_ptr< boost::thread > | me_ |
boost::shared_ptr < edm::StreamerInputFile > | streamReader_ |
edm::EventBuffer & | to_ |
Definition at line 17 of file TestFileReader.h.
edmtestp::TestFileReader::TestFileReader | ( | std::string const & | filename, |
edm::EventBuffer & | to, | ||
edm::ProductRegistry & | prods | ||
) |
if(!ist_) { throw edm::Exception(errors::Configuration,"TestFileReader") << "cannot open file " << filename_; }
std::auto_ptr<SendJobHeader> p = readHeaderFromStream(ist_); just get rid of the header
Definition at line 41 of file TestFileReader.cc.
References b, buf_, edm::EventBuffer::OperateBuffer< T >::buffer(), InitMsgView::code(), edm::EventBuffer::OperateBuffer< T >::commit(), edm::errors::Configuration, Exception, filename_, init, InitMsgView::outputModuleId(), L1TEmulatorMonitor_cff::p, edm::registryIsSubset(), InitMsgView::run(), InitMsgView::size(), InitMsgView::startAddress(), streamReader_, and to_.
: filename_(filename), //ist_(filename_.c_str(),ios_base::binary | ios_base::in), //reader_(ist_), streamReader_(new StreamerInputFile(filename)), to_(to) { const InitMsgView* init = streamReader_->startMessage(); std::auto_ptr<edm::SendJobHeader> p = StreamerInputSource::deserializeRegistry(*init); if(edm::registryIsSubset(*p, prods) == false) { throw edm::Exception(errors::Configuration,"TestFileReader") << "the header record in file " << filename_ << "is not consistent with the one for the program \n"; } // 13-Oct-2008, KAB - Added the following code to put the // INIT message on the input queue. EventBuffer::ProducerBuffer b(to_); int len = init->size(); char* buf_ = new char[len]; memcpy(buf_, init->startAddress(), len); new (b.buffer()) stor::FragEntry(buf_, buf_, len, 1, 1, init->code(), init->run(), 0, init->outputModuleId(), getpid(), 0); b.commit(sizeof(stor::FragEntry)); }
edmtestp::TestFileReader::~TestFileReader | ( | ) | [virtual] |
Definition at line 83 of file TestFileReader.cc.
{ }
void edmtestp::TestFileReader::join | ( | ) |
void edmtestp::TestFileReader::readEvents | ( | ) | [private] |
Definition at line 98 of file TestFileReader.cc.
References b, buf_, edm::EventBuffer::OperateBuffer< T >::buffer(), EventMsgView::code(), edm::EventBuffer::OperateBuffer< T >::commit(), EventMsgView::event(), EventMsgView::outModId(), EventMsgView::run(), EventMsgView::size(), EventMsgView::startAddress(), streamReader_, and to_.
Referenced by run().
{ while(streamReader_->next()) { EventBuffer::ProducerBuffer b(to_); const EventMsgView* eview = streamReader_->currentRecord(); // 13-Oct-2008, KAB - we need to make a copy of the event message // for two reasons: 1) the processing of the events is often done // asynchronously in the code that uses this reader, so we can't // keep re-using the same buffer from the stream_reader, and // 2) the code that uses this reader often uses deleters to // free up the memory used by the FragEntry, so we want the // first argument to the FragEntry to be something that can // be deleted successfully. int len = eview->size(); char* buf_ = new char[len]; memcpy(buf_, eview->startAddress(), len); //stor::FragEntry* msg = // new (b.buffer()) stor::FragEntry(eview->startAddress(), // eview->startAddress(), // the first arg should be startAddress() right? //new (b.buffer()) stor::FragEntry((void*)eview->eventData(), new (b.buffer()) stor::FragEntry(buf_, buf_, len, 1, 1, eview->code(), eview->run(), eview->event(), eview->outModId(), getpid(), 0); b.commit(sizeof(stor::FragEntry)); } /*** while(1) { int len=0; ist_.read((char*)&len,sizeof(int)); if(!ist_ || len==0 || ist_.eof()) break; EventBuffer::ProducerBuffer b(to_); // Pay attention here. // This is a bit of a mess. // Here we allocate an array (on the heap), fill it with data // from the file, then pass the bare pointer off onto the queue. // The ownership is to be picked up by the code that pulls it // off the queue. The current implementation of the queue // is primitive - it knows nothing about the types of things // that are on the queue. BufHelper data(len); //std::cout << "allocated frag " << len << std::endl; ist_.read((char*)data.get(),len); //std::cout << "read frag to " << (void*)data.get() << std::endl; if(!ist_ || ist_.eof()) std::cerr << "got end!!!!" << std::endl; //HEREHERE need a real event number here for id stor::FragEntry* msg = new (b.buffer()) stor::FragEntry(data.get(),data.get(),len,1,1,Header::EVENT,0,1,0); assert(msg); // Suppresses compiler warning about unused variable //new (b.buffer()) stor::FragEntry(0,0,len); //std::cout << "make entry for frag " << (void*)msg << " " << msg->buffer_address_ << std::endl; data.release(); //std::cout << "release frag" << std::endl; b.commit(sizeof(stor::FragEntry)); //std::cout << "commit frag " << sizeof(stor::FragEntry) << std::endl; //sleep(2); } **/ }
void edmtestp::TestFileReader::run | ( | TestFileReader * | t | ) | [static, private] |
Definition at line 94 of file TestFileReader.cc.
References readEvents().
Referenced by start().
{ t->readEvents(); }
void edmtestp::TestFileReader::start | ( | void | ) |
Definition at line 86 of file TestFileReader.cc.
{ me_.reset(new boost::thread(boost::bind(TestFileReader::run,this))); }
std::string edmtestp::TestFileReader::filename_ [private] |
Definition at line 30 of file TestFileReader.h.
Referenced by TestFileReader().
boost::shared_ptr<boost::thread> edmtestp::TestFileReader::me_ [private] |
Definition at line 35 of file TestFileReader.h.
boost::shared_ptr<edm::StreamerInputFile> edmtestp::TestFileReader::streamReader_ [private] |
Definition at line 31 of file TestFileReader.h.
Referenced by readEvents(), and TestFileReader().
edm::EventBuffer& edmtestp::TestFileReader::to_ [private] |
Definition at line 34 of file TestFileReader.h.
Referenced by readEvents(), and TestFileReader().