CMS 3D CMS Logo

EventMsgBuilder.cc
Go to the documentation of this file.
4 #include <cassert>
5 #include <cstring>
6 
7 #define MAX_HOSTNAME_LEN 25
8 
10  uint32 size,
11  uint32 run,
12  uint64 event,
13  uint32 lumi,
14  uint32 outModId,
15  uint32 droppedEventsCount,
16  std::vector<bool>& l1_bits,
17  uint8* hlt_bits,
18  uint32 hlt_bit_count,
19  uint32 adler_chksum,
20  const char* host_name)
21  : buf_((uint8*)buf), size_(size) {
23  h->protocolVersion_ = 11;
24  convert(run, h->run_);
25  convert(event, h->event_);
26  convert(lumi, h->lumi_);
27  convert(outModId, h->outModId_);
28  convert(droppedEventsCount, h->droppedEventsCount_);
29  uint8* pos = buf_ + sizeof(EventHeader);
30 
31  // l1 count
32  uint32 l1_count = l1_bits.size();
33  convert(l1_count, pos);
34  pos = pos + sizeof(uint32);
35 
36  // set the l1
37  uint32 l1_sz = l1_bits.size();
38  if (l1_sz != 0)
39  l1_sz = 1 + ((l1_sz - 1) / 8);
40 
41  uint8* pos_end = pos + l1_sz;
42  memset(pos, 0x00, pos_end - pos); // clear the bits
43  for (std::vector<bool>::size_type i = 0; i < l1_bits.size(); ++i) {
44  uint8 v = l1_bits[i] ? 1 : 0;
45  pos[i / 8] |= (v << (i & 0x07));
46  }
47  pos = pos_end;
48 
49  // hlt count
50  convert(hlt_bit_count, pos);
51  pos = pos + sizeof(uint32);
52 
53  uint32 hlt_sz = hlt_bit_count;
54  if (hlt_sz != 0)
55  hlt_sz = 1 + ((hlt_sz - 1) / 4);
56 
57  // copy the hlt bits over
58  pos = std::copy(hlt_bits, hlt_bits + hlt_sz, pos);
59 
60  // adler32 check sum of data blob
61  convert(adler_chksum, pos);
62  pos = pos + sizeof(uint32);
63 
64  // put host name (Length and then Name) right after check sum
65  //uint32 host_name_len = strlen(host_name);
66  // actually make the host_name a fixed length as the event header size appears in the
67  // Init message and only one goes to a file whereas events can come from any node
68  // We want the max length to be determined inside this Event Message Builder
69  uint32 host_name_len = MAX_HOSTNAME_LEN;
70  assert(host_name_len < 0x00ff);
71  //Put host_name_len
72  *pos++ = host_name_len;
73 
74  //Put host_name
75  uint32 real_len = strlen(host_name);
76  if (real_len < host_name_len) {
77  char hostname_2use[MAX_HOSTNAME_LEN];
78  memset(hostname_2use, '\0', host_name_len);
79  memcpy(hostname_2use, host_name, real_len);
80  memcpy(pos, hostname_2use, host_name_len);
81  } else {
82  memcpy(pos, host_name, host_name_len);
83  }
84  pos += host_name_len;
85 
86  event_addr_ = pos + sizeof(char_uint32);
87  setEventLength(0);
88 }
89 
92  convert(value, h->origDataSize_);
93 }
94 
96  convert(len, event_addr_ - sizeof(char_uint32));
98  new (&h->header_) Header(Header::EVENT, event_addr_ - buf_ + len);
99 }
100 
102  HeaderView v(buf_);
103  return v.size();
104 }
size
Write out results.
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
EventMsgBuilder(void *buf, uint32 size, uint32 run, uint64 event, uint32 lumi, uint32 outModId, uint32 droppedEventsCount, std::vector< bool > &l1_bits, uint8 *hlt_bits, uint32 hlt_bit_count, uint32 adler32_chksum, const char *host_name)
void setEventLength(uint32 len)
char_uint32 lumi_
Definition: EventMessage.h:66
char_uint32 origDataSize_
Definition: EventMessage.h:67
uint16_t size_type
void setOrigDataSize(uint32)
#define MAX_HOSTNAME_LEN
uint8 protocolVersion_
Definition: EventMessage.h:63
Definition: value.py:1
Header header_
Definition: EventMessage.h:62
def convert(infile, ofile)
char_uint32 droppedEventsCount_
Definition: EventMessage.h:69
unsigned int uint32
Definition: MsgTools.h:13
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
char_uint32 run_
Definition: EventMessage.h:64
char_uint64 event_
Definition: EventMessage.h:65
unsigned long long uint64
Definition: MsgTools.h:14
uint32 size() const
Definition: MsgHeader.h:44
char_uint32 outModId_
Definition: EventMessage.h:68
unsigned char uint8
Definition: MsgTools.h:11
Definition: event.py:1
uint32 size() const