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 }
mps_fire.i
i
Definition: mps_fire.py:355
Header
Definition: MsgHeader.h:6
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
uint8
unsigned char uint8
Definition: MsgTools.h:11
pos
Definition: PixelAliasList.h:18
EventHeader
Definition: EventHeader.h:18
cms::cuda::assert
assert(be >=bs)
MsgHeader.h
EventMsgBuilder::setOrigDataSize
void setOrigDataSize(uint32)
Definition: EventMsgBuilder.cc:90
EventMsgBuilder::event_addr_
uint8 * event_addr_
Definition: EventMsgBuilder.h:36
char_uint32
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
EventMsgBuilder::buf_
uint8 * buf_
Definition: EventMsgBuilder.h:34
findQualityFiles.v
v
Definition: findQualityFiles.py:179
uint32
unsigned int uint32
Definition: MsgTools.h:13
EventMsgBuilder::EventMsgBuilder
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)
Definition: EventMsgBuilder.cc:9
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
Header::EVENT
Definition: MsgHeader.h:16
EventMsgBuilder.h
HeaderView
Definition: MsgHeader.h:35
h
fileCollector.convert
def convert(infile, ofile)
Definition: fileCollector.py:47
EventMsgBuilder::setEventLength
void setEventLength(uint32 len)
Definition: EventMsgBuilder.cc:95
value
Definition: value.py:1
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
MAX_HOSTNAME_LEN
#define MAX_HOSTNAME_LEN
Definition: EventMsgBuilder.cc:7
writedatasetfile.run
run
Definition: writedatasetfile.py:27
uint64
unsigned long long uint64
Definition: MsgTools.h:14
EventMessage.h
EventMsgBuilder::size
uint32 size() const
Definition: EventMsgBuilder.cc:101
event
Definition: event.py:1
lumi
Definition: LumiSectionData.h:20
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443