#include <StreamDQMInputFile.h>
Public Member Functions | |
const DQMEventMsgView * | currentRecord () const |
bool | next () |
StreamDQMInputFile (const std::string &name) | |
~StreamDQMInputFile () | |
Private Member Functions | |
int | readDQMEventMessage () |
Private Attributes | |
boost::shared_ptr < DQMEventMsgView > | currentEvMsg_ |
std::vector< char > | eventBuf_ |
std::auto_ptr< std::ifstream > | ist_ |
Definition at line 12 of file StreamDQMInputFile.h.
StreamDQMInputFile::StreamDQMInputFile | ( | const std::string & | name | ) | [explicit] |
Reads a Streamer file
Definition at line 13 of file StreamDQMInputFile.cc.
References Exception, and ist_.
: currentEvMsg_(), ist_(new ifstream(name.c_str())), eventBuf_(1000*1000*7) { if (!ist_->is_open()) { throw cms::Exception("StreamDQMInputFile","StreamDQMInputFile") << "Error Opening Input File: " << name << "\n"; } }
StreamDQMInputFile::~StreamDQMInputFile | ( | ) |
Definition at line 8 of file StreamDQMInputFile.cc.
{
//ist_->close();
}
const DQMEventMsgView* StreamDQMInputFile::currentRecord | ( | ) | const [inline] |
Moves the handler to next Event Record
Definition at line 23 of file StreamDQMInputFile.h.
References currentEvMsg_.
{ return currentEvMsg_.get(); }
bool StreamDQMInputFile::next | ( | void | ) |
Definition at line 26 of file StreamDQMInputFile.cc.
References readDQMEventMessage().
{ if (this->readDQMEventMessage()) { return true; } return false; }
int StreamDQMInputFile::readDQMEventMessage | ( | ) | [private] |
Points to current Record
Definition at line 35 of file StreamDQMInputFile.cc.
References HeaderView::code(), currentEvMsg_, Header::DQM_EVENT, eventBuf_, ist_, and HeaderView::size().
Referenced by next().
{ uint32 last_pos = ist_->tellg(); uint32 nWant = sizeof(HeaderView); ist_->read(&eventBuf_[0], nWant); if (ist_->eof() || static_cast<unsigned int>(ist_->gcount()) < nWant) { return 0; } HeaderView head(&eventBuf_[0]); uint32 code = head.code(); if (code != Header::DQM_EVENT) return 0; //This includes header uint32 eventSize = head.size(); if (eventBuf_.size() < eventSize) eventBuf_.resize(eventSize); if (eventSize > sizeof(DQMEventMsgView)) { //Lets read the whole thing again nWant = eventSize; ist_->seekg(last_pos, std::ios::beg); ist_->read(&eventBuf_[0], nWant); if (ist_->eof() || static_cast<unsigned int>(ist_->gcount()) < nWant) { return 0; } } currentEvMsg_.reset(new DQMEventMsgView((void*)&eventBuf_[0])); uint32 new_len = last_pos + eventSize; ist_->seekg(new_len, std::ios::beg); return 1; }
boost::shared_ptr<DQMEventMsgView> StreamDQMInputFile::currentEvMsg_ [private] |
Definition at line 30 of file StreamDQMInputFile.h.
Referenced by currentRecord(), and readDQMEventMessage().
std::vector<char> StreamDQMInputFile::eventBuf_ [private] |
Definition at line 32 of file StreamDQMInputFile.h.
Referenced by readDQMEventMessage().
std::auto_ptr<std::ifstream> StreamDQMInputFile::ist_ [private] |
Definition at line 31 of file StreamDQMInputFile.h.
Referenced by readDQMEventMessage(), and StreamDQMInputFile().