CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
StreamDQMInputFile Class Reference

#include <StreamDQMInputFile.h>

Public Member Functions

const DQMEventMsgViewcurrentRecord () 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_
 

Detailed Description

Definition at line 12 of file StreamDQMInputFile.h.

Constructor & Destructor Documentation

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

Reads a Streamer file

Definition at line 13 of file StreamDQMInputFile.cc.

References edm::hlt::Exception, and ist_.

13  :
14  currentEvMsg_(),
15  ist_(new ifstream(name.c_str())),
16  eventBuf_(1000*1000*7)
17 {
18 
19  if (!ist_->is_open()) {
20  throw cms::Exception("StreamDQMInputFile","StreamDQMInputFile")
21  << "Error Opening Input File: " << name << "\n";
22  }
23 
24 }
std::vector< char > eventBuf_
boost::shared_ptr< DQMEventMsgView > currentEvMsg_
std::auto_ptr< std::ifstream > ist_
StreamDQMInputFile::~StreamDQMInputFile ( )

Definition at line 8 of file StreamDQMInputFile.cc.

9 {
10  //ist_->close();
11 }

Member Function Documentation

const DQMEventMsgView* StreamDQMInputFile::currentRecord ( ) const
inline

Moves the handler to next Event Record

Definition at line 23 of file StreamDQMInputFile.h.

References currentEvMsg_.

23 { return currentEvMsg_.get(); }
boost::shared_ptr< DQMEventMsgView > currentEvMsg_
bool StreamDQMInputFile::next ( void  )

Definition at line 26 of file StreamDQMInputFile.cc.

References readDQMEventMessage().

27 {
28  if (this->readDQMEventMessage()) {
29  return true;
30  }
31 
32  return false;
33 }
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().

35  {
36 
37  uint32 last_pos = ist_->tellg();
38  uint32 nWant = sizeof(HeaderView);
39 
40  ist_->read(&eventBuf_[0], nWant);
41 
42  if (ist_->eof() || static_cast<unsigned int>(ist_->gcount()) < nWant) {
43  return 0;
44  }
45 
46  HeaderView head(&eventBuf_[0]);
47  uint32 code = head.code();
48  if (code != Header::DQM_EVENT)
49  return 0;
50 
51  //This includes header
52  uint32 eventSize = head.size();
53  if (eventBuf_.size() < eventSize) eventBuf_.resize(eventSize);
54 
55  if (eventSize > sizeof(DQMEventMsgView)) {
56  //Lets read the whole thing again
57  nWant = eventSize;
58  ist_->seekg(last_pos, std::ios::beg);
59  ist_->read(&eventBuf_[0], nWant);
60  if (ist_->eof() || static_cast<unsigned int>(ist_->gcount()) < nWant) {
61  return 0;
62  }
63  }
64 
65  currentEvMsg_.reset(new DQMEventMsgView((void*)&eventBuf_[0]));
66  uint32 new_len = last_pos + eventSize;
67  ist_->seekg(new_len, std::ios::beg);
68  return 1;
69 }
std::vector< char > eventBuf_
boost::shared_ptr< DQMEventMsgView > currentEvMsg_
std::auto_ptr< std::ifstream > ist_
unsigned int uint32
Definition: MsgTools.h:13

Member Data Documentation

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().