00001 #include "IOPool/Streamer/interface/InitMsgBuilder.h"
00002 #include "IOPool/Streamer/interface/EventMsgBuilder.h"
00003 #include "IOPool/Streamer/interface/MsgHeader.h"
00004 #include "FWCore/Utilities/interface/Algorithms.h"
00005 #include <cassert>
00006
00007 InitMsgBuilder::InitMsgBuilder(void* buf, uint32 size,
00008 uint32 run, const Version& v,
00009 const char* release_tag,
00010 const char* process_name,
00011 const char* output_module_label,
00012 uint32 output_module_id,
00013 const Strings& hlt_names,
00014 const Strings& hlt_selections,
00015 const Strings& l1_names):
00016 buf_((uint8*)buf),size_(size)
00017 {
00018 InitHeader* h = (InitHeader*)buf_;
00019
00020 new (&h->version_) Version(v);
00021 convert(run,h->run_);
00022
00023 uint32 tag_len = strlen(release_tag);
00024 assert(tag_len < 0x00ff);
00025 uint8* pos = buf_+sizeof(InitHeader);
00026
00027 *pos++ = tag_len;
00028 memcpy(pos,release_tag,tag_len);
00029 pos += tag_len;
00030
00031
00032 uint32 process_name_len = strlen(process_name);
00033 assert(process_name_len < 0x00ff);
00034
00035 *pos++ = process_name_len;
00036
00037 memcpy(pos,process_name,process_name_len);
00038 pos += process_name_len;
00039
00040
00041 uint32 outmod_label_len = strlen(output_module_label);
00042 assert(outmod_label_len < 0x00ff);
00043 *pos++ = outmod_label_len;
00044 memcpy(pos,output_module_label,outmod_label_len);
00045 pos += outmod_label_len;
00046
00047
00048 convert(output_module_id, pos);
00049 pos += sizeof(char_uint32);
00050
00051 pos = MsgTools::fillNames(hlt_names,pos);
00052 pos = MsgTools::fillNames(hlt_selections,pos);
00053 pos = MsgTools::fillNames(l1_names,pos);
00054
00055 data_addr_ = pos + sizeof(char_uint32);
00056 setDataLength(0);
00057
00058
00059
00060 convert((uint32)(data_addr_ - buf_), h->init_header_size_);
00061
00062
00063
00064
00065 std::vector<bool> dummyL1Bits(l1_names.size());
00066 std::vector<char> dummyHLTBits(hlt_names.size());
00067 const uint32 TEMP_BUFFER_SIZE = 256;
00068 char msgBuff[TEMP_BUFFER_SIZE];
00069 EventMsgBuilder dummyMsg(&msgBuff[0], TEMP_BUFFER_SIZE, 0, 0, 0, 0,
00070 dummyL1Bits, (uint8*) &dummyHLTBits[0],
00071 hlt_names.size());
00072
00073
00074 uint32 eventHeaderSize = dummyMsg.headerSize();
00075 convert(eventHeaderSize, h->event_header_size_);
00076 }
00077
00078 void InitMsgBuilder::setDataLength(uint32 len)
00079 {
00080 convert(len,data_addr_-sizeof(char_uint32));
00081 InitHeader* h = (InitHeader*)buf_;
00082 new (&h->header_) Header(Header::INIT, data_addr_ - buf_ + len);
00083 }
00084
00085
00086 uint32 InitMsgBuilder::size() const
00087 {
00088
00089 HeaderView v(buf_);
00090 return v.size();
00091 }
00092
00093
00094 uint32 InitMsgBuilder::run() const
00095 {
00096 InitHeader* h = (InitHeader*)buf_;
00097 return convert32(h->run_);
00098 }
00099