Go to the documentation of this file.00001
00002 #include "IOPool/Streamer/interface/EOFRecordBuilder.h"
00003 #include "IOPool/Streamer/interface/EOFRecord.h"
00004 #include "IOPool/Streamer/interface/MsgHeader.h"
00005 #include <cassert>
00006 #include <cstring>
00007
00008 EOFRecordBuilder::EOFRecordBuilder(uint32 run, uint32 events,
00009 uint32 statusCode,
00010 const std::vector<uint32>& hltStats,
00011 uint64 first_event_offset,
00012 uint64 last_event_offset)
00013 {
00014 uint32 buf_size = 1 + ((sizeof(uint32)) * 8)+ ((sizeof(uint32)) * hltStats.size());
00015 buf_.resize(buf_size);
00016
00017 uint8* pos = (uint8*)&buf_[0];
00018 EOFRecordHeader* h = (EOFRecordHeader*)pos;
00019 convert(run,h->run_);
00020 convert(statusCode,h->status_code_);
00021 convert(events,h->events_);
00022 pos += sizeof(EOFRecordHeader);
00023
00024 for(unsigned int i = 0; i < hltStats.size(); ++i) {
00025 char_uint32 v;
00026 convert(hltStats.at(i), v);
00027 memcpy(pos, v, sizeof(char_uint32));
00028 pos += sizeof(char_uint32);
00029 }
00030
00031 char_uint64 v;
00032 convert(first_event_offset, v);
00033 memcpy(pos, v, sizeof(char_uint64));
00034 pos += sizeof(char_uint64);
00035
00036 convert(last_event_offset, v);
00037 memcpy(pos, v, sizeof(char_uint64));
00038 pos += sizeof(char_uint64);
00040 uint32 calculatedSize = (uint8*)pos - (uint8*)&buf_[0];
00041 assert(calculatedSize == buf_.size());
00043 new (&h->header_) Header(Header::EOFRECORD, calculatedSize);
00044 }