Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-18 03:27:20

0001 #include "IOPool/Streamer/interface/InitMsgBuilder.h"
0002 #include "IOPool/Streamer/interface/EventMsgBuilder.h"
0003 #include "IOPool/Streamer/interface/MsgHeader.h"
0004 #include <cassert>
0005 #include <cstring>
0006 #include <cstdint>
0007 #include <unistd.h>
0008 
0009 InitMsgBuilder::InitMsgBuilder(void* buf,
0010                                uint32 size,
0011                                uint32 run,
0012                                const Version& v,
0013                                const char* release_tag,
0014                                const char* process_name,
0015                                const char* output_module_label,
0016                                uint32 output_module_id,
0017                                const Strings& hlt_names,
0018                                const Strings& hlt_selections,
0019                                const Strings& l1_names,
0020                                uint32 adler_chksum)
0021     : buf_((uint8*)buf), size_(size) {
0022   InitHeader* h = (InitHeader*)buf_;
0023   // fixed length parts
0024   new (&h->version_) Version(v);
0025   convert(run, h->run_);
0026   // variable length parts
0027   uint32 tag_len = strlen(release_tag);
0028   assert(tag_len < 0x00ff);
0029   uint8* pos = buf_ + sizeof(InitHeader);
0030 
0031   *pos++ = tag_len;                   // length of release tag
0032   memcpy(pos, release_tag, tag_len);  // copy release tag in
0033   pos += tag_len;
0034 
0035   //Lets put Process Name (Length and then Name) right after release_tag
0036   uint32 process_name_len = strlen(process_name);
0037   assert(process_name_len < 0x00ff);
0038   //Put process_name_len
0039   *pos++ = process_name_len;
0040   //Put process_name
0041   memcpy(pos, process_name, process_name_len);
0042   pos += process_name_len;
0043 
0044   // output module label next
0045   uint32 outmod_label_len = strlen(output_module_label);
0046   assert(outmod_label_len < 0x00ff);
0047   *pos++ = outmod_label_len;
0048   memcpy(pos, output_module_label, outmod_label_len);
0049   pos += outmod_label_len;
0050 
0051   // output module ID next
0052   convert(output_module_id, pos);
0053   pos += sizeof(char_uint32);
0054 
0055   pos = MsgTools::fillNames(hlt_names, pos);
0056   pos = MsgTools::fillNames(hlt_selections, pos);
0057   pos = MsgTools::fillNames(l1_names, pos);
0058 
0059   // adler32 check sum of data blob
0060   convert(adler_chksum, pos);
0061   pos = pos + sizeof(uint32);
0062 
0063   data_addr_ = pos + sizeof(char_uint32);
0064   setDataLength(0);
0065 
0066   // Two news fileds added to InitMsg in Proto V3 init_header_size, and event_header_size.
0067   //Set the size of Init Header Start of buf to Start of desc.
0068   convert((uint32)(data_addr_ - buf_), h->init_header_size_);
0069 
0070   //Size of Event Header
0071   uint32 eventHeaderSize = EventMsgBuilder::computeHeaderSize(l1_names.size(), hlt_names.size());
0072   convert(eventHeaderSize, h->event_header_size_);
0073 }
0074 
0075 void InitMsgBuilder::setDataLength(uint32 len) {
0076   convert(len, data_addr_ - sizeof(char_uint32));
0077   InitHeader* h = (InitHeader*)buf_;
0078   new (&h->header_) Header(Header::INIT, data_addr_ - buf_ + len);
0079 }
0080 
0081 uint32 InitMsgBuilder::size() const {
0082   HeaderView v(buf_);
0083   return v.size();
0084 }
0085 
0086 uint32 InitMsgBuilder::run() const {
0087   InitHeader* h = (InitHeader*)buf_;
0088   return convert32(h->run_);
0089 }