CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StreamDQMInputFile.cc
Go to the documentation of this file.
4 //#include "FWCore/Utilities/interface/DebugMacros.h"
5 
6 using namespace edm;
7 
9 {
10  //ist_->close();
11 }
12 
14  currentEvMsg_(),
15  ist_(new std::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 }
25 
27 {
28  if (this->readDQMEventMessage()) {
29  return true;
30  }
31 
32  return false;
33 }
34 
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 }
70 
std::vector< char > eventBuf_
uint32 code() const
Definition: MsgHeader.h:34
boost::shared_ptr< DQMEventMsgView > currentEvMsg_
std::auto_ptr< std::ifstream > ist_
StreamDQMInputFile(const std::string &name)
unsigned int uint32
Definition: MsgTools.h:13
uint32 size() const
Definition: MsgHeader.h:35