CMS 3D CMS Logo

StreamDQMInputFile Class Reference

#include <IOPool/Streamer/interface/StreamDQMInputFile.h>

List of all members.

Public Member Functions

const DQMEventMsgViewcurrentRecord () const
 Moves the handler to next Event Record.
bool next ()
 StreamDQMInputFile (const std::string &name)
 Reads a Streamer file.
 ~StreamDQMInputFile ()

Private Member Functions

int readDQMEventMessage ()
 Points to current Record.

Private Attributes

DQMEventMsgViewcurrentEvMsg_
std::vector< char > eventBuf_
std::auto_ptr< std::ifstream > ist_


Detailed Description

Definition at line 10 of file StreamDQMInputFile.h.


Constructor & Destructor Documentation

StreamDQMInputFile::StreamDQMInputFile ( const std::string &  name  )  [explicit]

Reads a Streamer file.

Definition at line 14 of file StreamDQMInputFile.cc.

References Exception, and ist_.

00014                                                            :
00015   currentEvMsg_(0),
00016   ist_(new ifstream(name.c_str())),
00017   eventBuf_(1000*1000*7)
00018 {
00019 
00020   if (!ist_->is_open()) {
00021       throw cms::Exception("StreamDQMInputFile","StreamDQMInputFile")
00022         << "Error Opening Input File: " << name << "\n";
00023   }
00024 
00025 }

StreamDQMInputFile::~StreamDQMInputFile (  ) 

Definition at line 8 of file StreamDQMInputFile.cc.

References currentEvMsg_.

00009 {
00010   //ist_->close();
00011   delete  currentEvMsg_;
00012 }


Member Function Documentation

const DQMEventMsgView* StreamDQMInputFile::currentRecord (  )  const [inline]

Moves the handler to next Event Record.

Definition at line 21 of file StreamDQMInputFile.h.

References currentEvMsg_.

00021 { return currentEvMsg_; }

bool StreamDQMInputFile::next ( void   ) 

Definition at line 27 of file StreamDQMInputFile.cc.

00028 {
00029   if (this->readDQMEventMessage()) {
00030        return true;
00031   }
00032 
00033   return false;
00034 }

int StreamDQMInputFile::readDQMEventMessage (  )  [private]

Points to current Record.

Definition at line 36 of file StreamDQMInputFile.cc.

References code, HeaderView::code(), currentEvMsg_, Header::DQM_EVENT, eventBuf_, ist_, NULL, and HeaderView::size().

00036                                             {
00037 
00038   uint32 last_pos = ist_->tellg();
00039   uint32 nWant = sizeof(HeaderView);
00040 
00041   ist_->read(&eventBuf_[0], nWant);
00042 
00043   if (ist_->eof() || static_cast<unsigned int>(ist_->gcount()) < nWant) {
00044         return 0;
00045   }  
00046 
00047   HeaderView head(&eventBuf_[0]);
00048   uint32 code = head.code();
00049   if (code != Header::DQM_EVENT)
00050     return 0;
00051 
00052   //This includes header
00053   uint32 eventSize = head.size();
00054   if (eventBuf_.size() < eventSize) eventBuf_.resize(eventSize);
00055 
00056   if (eventSize > sizeof(DQMEventMsgView)) {
00057     //Lets read the whole thing again
00058     nWant = eventSize;
00059     ist_->seekg(last_pos, std::ios::beg);
00060     ist_->read(&eventBuf_[0], nWant);
00061     if (ist_->eof() || static_cast<unsigned int>(ist_->gcount()) < nWant) {
00062         return 0;
00063     }
00064   }
00065 
00066   if (currentEvMsg_ != NULL) {delete currentEvMsg_;}
00067   currentEvMsg_ = new DQMEventMsgView((void*)&eventBuf_[0]);
00068   uint32 new_len = last_pos + eventSize; 
00069   ist_->seekg(new_len, std::ios::beg);
00070   return 1;
00071 }


Member Data Documentation

DQMEventMsgView* StreamDQMInputFile::currentEvMsg_ [private]

Definition at line 28 of file StreamDQMInputFile.h.

Referenced by currentRecord(), readDQMEventMessage(), and ~StreamDQMInputFile().

std::vector<char> StreamDQMInputFile::eventBuf_ [private]

Definition at line 30 of file StreamDQMInputFile.h.

Referenced by readDQMEventMessage().

std::auto_ptr<std::ifstream> StreamDQMInputFile::ist_ [private]

Definition at line 29 of file StreamDQMInputFile.h.

Referenced by readDQMEventMessage(), and StreamDQMInputFile().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:54 2009 for CMSSW by  doxygen 1.5.4