CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StreamerOutputFile.cc
Go to the documentation of this file.
4 
6  }
7 
9  streamerfile_(new OutputFile(name))
10  {
11  streamerfile_->set_do_adler(1);
12  }
13 
15  {
16  EventMsgView tmpView(ineview.startAddress());
17  return write(tmpView);
18  }
19 
21  {
23  uint64 offset_to_return = streamerfile_->current_offset();
24 
26  streamerfile_->set_last_event_offset(streamerfile_->current_offset());
27 
28  writeEventHeader(ineview);
29  bool ret = streamerfile_->write((const char*) ineview.eventData(),
30  ineview.size() - ineview.headerSize());
31  if (ret) {
32  throw cms::Exception("OutputFile", "write(EventMsgView)")
33  << "Error writing streamer event data to "
34  << streamerfile_->fileName() << ". Possibly the output disk "
35  << "is full?" << std::endl;
36  }
37 
38  streamerfile_->inc_events();
39 
40  return offset_to_return;
41  }
42 
44  writeEventFragment(uint32 fragIndex, uint32 fragCount,
45  const char *dataPtr, uint32 dataSize)
46  {
48  uint64 offset_to_return = streamerfile_->current_offset();
49 
50  if (fragIndex == 0) {
52  streamerfile_->set_last_event_offset(streamerfile_->current_offset());
53  }
54 
55  bool ret = streamerfile_->write(dataPtr, dataSize);
56  if (ret) {
57  throw cms::Exception("OutputFile", "writeEventFragment()")
58  << "Error writing streamer event data to "
59  << streamerfile_->fileName() << ". Possibly the output disk "
60  << "is full?" << std::endl;
61  }
62 
63  if (fragIndex == fragCount-1) {streamerfile_->inc_events();}
64 
65  return offset_to_return;
66  }
67 
69  {
70  bool ret = streamerfile_->write((const char*)
71  ineview.startAddress(),
72  ineview.headerSize()) ;
73  if (ret) {
74  throw cms::Exception("OutputFile", "writeEventHeader")
75  << "Error writing streamer event data to "
76  << streamerfile_->fileName() << ". Possibly the output disk "
77  << "is full?" << std::endl;
78  }
79  }
80 
82  {
83  InitMsgView tmpView(inview.startAddress());
84  return write(tmpView);
85  }
86 
88  {
89  writeStart(inview);
90  bool ret = streamerfile_->write((const char*) inview.descData(),
91  inview.size() - inview.headerSize());
92  if (ret) {
93  throw cms::Exception("OutputFile", "write(InitMsgView)")
94  << "Error writing streamer header data to "
95  << streamerfile_->fileName() << ". Possibly the output disk "
96  << "is full?" << std::endl;
97  }
98 
100  streamerfile_->set_first_event_offset(streamerfile_->current_offset());
101  }
102 
104  writeInitFragment(uint32 fragIndex, uint32 fragCount,
105  const char *dataPtr, uint32 dataSize)
106  {
107  bool ret = streamerfile_->write((const char*) dataPtr, dataSize);
108  if (ret) {
109  throw cms::Exception("OutputFile", "writeInitFragment()")
110  << "Error writing streamer header data to "
111  << streamerfile_->fileName() << ". Possibly the output disk "
112  << "is full?" << std::endl;
113  }
114 
115  if (fragIndex == fragCount-1) {
117  streamerfile_->set_first_event_offset(streamerfile_->current_offset());
118  }
119  }
120 
122  {
123  bool ret = streamerfile_->write((const char*)
124  inview.startAddress(),
125  inview.headerSize()) ;
126  if (ret) {
127  throw cms::Exception("OutputFile", "writeStart")
128  << "Error writing streamer header data to "
129  << streamerfile_->fileName() << ". Possibly the output disk "
130  << "is full?" << std::endl;
131  }
132  streamerfile_->set_run(inview.run());
133  }
134 
136  const std::vector<uint32>& hltStats)
137  {
138  EOFRecordBuilder eof(streamerfile_->run(),
139  streamerfile_->events(),
140  statusCode,
141  hltStats,
142  streamerfile_->first_event_offset(),
143  streamerfile_->last_event_offset());
144 
145  bool ret = streamerfile_->write((const char*)
146  eof.recAddress(),
147  eof.size());
148  if (ret) {
149  throw cms::Exception("OutputFile", "writeEOF")
150  << "Error writing streamer end-of-file to "
151  << streamerfile_->fileName() << ". Possibly the output disk "
152  << "is full?" << std::endl;
153  }
154  return eof.size();
155  }
const uint8 * eventData() const
Definition: EventMessage.h:78
uint8 * startAddress() const
Definition: EventMessage.h:79
const uint8 * descData() const
Definition: InitMessage.h:87
uint64 writeEventFragment(uint32 fragIndex, uint32 fragCount, const char *dataPtr, uint32 dataSize)
void write(const InitMsgBuilder &)
uint8 * startAddress() const
boost::shared_ptr< OutputFile > streamerfile_
uint8 * startAddress() const
Definition: InitMessage.h:68
void writeEventHeader(const EventMsgView &ineview)
uint32 headerSize() const
Definition: EventMessage.h:81
unsigned int uint32
Definition: MsgTools.h:13
uint32 writeEOF(uint32 statusCode, const std::vector< uint32 > &hltStats)
StreamerOutputFile(const std::string &name)
uint32 headerSize() const
Definition: InitMessage.h:88
unsigned long long uint64
Definition: MsgTools.h:14
uint32 size() const
Definition: EventMessage.h:76
void writeInitFragment(uint32 fragIndex, uint32 fragCount, const char *dataPtr, uint32 dataSize)
uint32 run() const
Definition: InitMessage.cc:100
uint8 * startAddress() const
uint32 size() const
Definition: InitMessage.h:67
void writeStart(const InitMsgView &inview)