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.
3 
5  }
6 
8  streamerfile_(new OutputFile(name))
9  {
10  streamerfile_->set_do_adler(1);
11  }
12 
14  {
15  EventMsgView tmpView(ineview.startAddress());
16  return write(tmpView);
17  }
18 
20  {
22  uint64 offset_to_return = streamerfile_->current_offset();
23 
25  streamerfile_->set_last_event_offset(streamerfile_->current_offset());
26 
27  writeEventHeader(ineview);
28  bool ret = streamerfile_->write((const char*) ineview.eventData(),
29  ineview.size() - ineview.headerSize());
30  if (ret) {
31  throw cms::Exception("OutputFile", "write(EventMsgView)")
32  << "Error writing streamer event data to "
33  << streamerfile_->fileName() << ". Possibly the output disk "
34  << "is full?" << std::endl;
35  }
36 
37  streamerfile_->inc_events();
38 
39  return offset_to_return;
40  }
41 
43  writeEventFragment(uint32 fragIndex, uint32 fragCount,
44  const char *dataPtr, uint32 dataSize)
45  {
47  uint64 offset_to_return = streamerfile_->current_offset();
48 
49  if (fragIndex == 0) {
51  streamerfile_->set_last_event_offset(streamerfile_->current_offset());
52  }
53 
54  bool ret = streamerfile_->write(dataPtr, dataSize);
55  if (ret) {
56  throw cms::Exception("OutputFile", "writeEventFragment()")
57  << "Error writing streamer event data to "
58  << streamerfile_->fileName() << ". Possibly the output disk "
59  << "is full?" << std::endl;
60  }
61 
62  if (fragIndex == fragCount-1) {streamerfile_->inc_events();}
63 
64  return offset_to_return;
65  }
66 
68  {
69  bool ret = streamerfile_->write((const char*)
70  ineview.startAddress(),
71  ineview.headerSize()) ;
72  if (ret) {
73  throw cms::Exception("OutputFile", "writeEventHeader")
74  << "Error writing streamer event data to "
75  << streamerfile_->fileName() << ". Possibly the output disk "
76  << "is full?" << std::endl;
77  }
78  }
79 
81  {
82  InitMsgView tmpView(inview.startAddress());
83  return write(tmpView);
84  }
85 
87  {
88  writeStart(inview);
89  bool ret = streamerfile_->write((const char*) inview.descData(),
90  inview.size() - inview.headerSize());
91  if (ret) {
92  throw cms::Exception("OutputFile", "write(InitMsgView)")
93  << "Error writing streamer header data to "
94  << streamerfile_->fileName() << ". Possibly the output disk "
95  << "is full?" << std::endl;
96  }
97 
99  streamerfile_->set_first_event_offset(streamerfile_->current_offset());
100  }
101 
103  writeInitFragment(uint32 fragIndex, uint32 fragCount,
104  const char *dataPtr, uint32 dataSize)
105  {
106  bool ret = streamerfile_->write((const char*) dataPtr, dataSize);
107  if (ret) {
108  throw cms::Exception("OutputFile", "writeInitFragment()")
109  << "Error writing streamer header data to "
110  << streamerfile_->fileName() << ". Possibly the output disk "
111  << "is full?" << std::endl;
112  }
113 
114  if (fragIndex == fragCount-1) {
116  streamerfile_->set_first_event_offset(streamerfile_->current_offset());
117  }
118  }
119 
121  {
122  bool ret = streamerfile_->write((const char*)
123  inview.startAddress(),
124  inview.headerSize()) ;
125  if (ret) {
126  throw cms::Exception("OutputFile", "writeStart")
127  << "Error writing streamer header data to "
128  << streamerfile_->fileName() << ". Possibly the output disk "
129  << "is full?" << std::endl;
130  }
131  streamerfile_->set_run(inview.run());
132  }
133 
const uint8 * eventData() const
Definition: EventMessage.h:80
ULong64_t uint64
uint8 * startAddress() const
Definition: EventMessage.h:81
const uint8 * descData() const
Definition: InitMessage.h:91
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:72
void writeEventHeader(const EventMsgView &ineview)
uint32 headerSize() const
Definition: EventMessage.h:83
unsigned int uint32
Definition: MsgTools.h:13
StreamerOutputFile(const std::string &name)
uint32 headerSize() const
Definition: InitMessage.h:92
uint32 size() const
Definition: EventMessage.h:78
void writeInitFragment(uint32 fragIndex, uint32 fragCount, const char *dataPtr, uint32 dataSize)
uint32 run() const
Definition: InitMessage.cc:104
uint8 * startAddress() const
uint32 size() const
Definition: InitMessage.h:71
void writeStart(const InitMsgView &inview)