CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
EventMsgBuilder Class Reference

#include <EventMsgBuilder.h>

Public Member Functions

uint32 bufferSize () const
 
uint8eventAddr () const
 
 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)
 
uint32 headerSize () const
 
void setBufAddr (uint8 *buf_addr)
 
void setEventAddr (uint8 *event_addr)
 
void setEventLength (uint32 len)
 
void setOrigDataSize (uint32)
 
uint32 size () const
 
uint8startAddress () const
 

Static Public Member Functions

static uint32 computeHeaderSize (uint32 l1t_bit_count, uint32 hlt_bit_count)
 

Private Attributes

uint8buf_
 
uint8event_addr_
 
uint32 size_
 

Detailed Description

Definition at line 8 of file EventMsgBuilder.h.

Constructor & Destructor Documentation

◆ 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 at line 10 of file EventMsgBuilder.cc.

References cms::cuda::assert(), buf_, computeHeaderSize(), fileCollector::convert(), filterCSVwithJSON::copy, event_addr_, Exception, h, headerSize(), mps_fire::i, MAX_HOSTNAME_LEN, writedatasetfile::run, setEventLength(), size_, and findQualityFiles::v.

22  : buf_((uint8*)buf), size_(size) {
23  uint32 expectedHeaderSize = computeHeaderSize(l1_bits.size(), hlt_bit_count);
24  if (expectedHeaderSize > size_) {
25  throw cms::Exception("EventMsgBuilder")
26  << "The buffer used to build the event message (" << size_
27  << " bytes) is not large enough to holde the event header (" << expectedHeaderSize << " bytes)";
28  }
29 
30  // Note: any change to the pos increment logic should be reflected in computeHeaderSize()
31  uint8* pos = buf_;
32 
33  // Set the event header
35  h->protocolVersion_ = 11;
36  convert(run, h->run_);
37  convert(event, h->event_);
38  convert(lumi, h->lumi_);
39  convert(outModId, h->outModId_);
40  convert(droppedEventsCount, h->droppedEventsCount_);
41  pos += sizeof(EventHeader);
42 
43  // Set the L1T triggers count
44  uint32 l1_count = l1_bits.size();
45  convert(l1_count, pos);
46  pos += sizeof(uint32);
47 
48  // Set the L1T bits
49  uint32 l1_sz = (l1_bits.size() + 8 - 1) / 8; // L1T results (1 bit per trigger)
50  memset(pos, 0x00, l1_sz); // clear the bits
51  for (std::vector<bool>::size_type i = 0; i < l1_bits.size(); ++i) {
52  uint8 v = l1_bits[i] ? 1 : 0;
53  pos[i / 8] |= (v << (i & 0x07));
54  }
55  pos += l1_sz;
56 
57  // Set HLT triggers count
58  convert(hlt_bit_count, pos);
59  pos += sizeof(uint32);
60 
61  // Copy the HLT bits and increment pos
62  uint32 hlt_sz = (hlt_bit_count + 4 - 1) / 4; // HLT results (2 bits per trigger)
63  pos = std::copy(hlt_bits, hlt_bits + hlt_sz, pos);
64 
65  // Set the Adler32 check sum of data blob
66  convert(adler_chksum, pos);
67  pos += sizeof(uint32);
68 
69  // Put the host name (length and then name) right after the check sum.
70  // Use a fixed length for the host_name because the event header size appears in the
71  // init message and only one goes to a file whereas events can come from any node,
72  // while we want the max length to be determined inside this Event Message Builder.
73 
74  // Set the host_name_len and increment pos
75  assert(MAX_HOSTNAME_LEN < 0x00ff);
76  *pos++ = MAX_HOSTNAME_LEN;
77 
78  // Copy up to MAX_HOSTNAME_LEN characters of the host_name and pad any extra space
79  // with null characters
80  memset(pos, '\0', MAX_HOSTNAME_LEN);
81  strncpy((char*)pos, host_name, MAX_HOSTNAME_LEN - 1);
83 
84  event_addr_ = pos + sizeof(char_uint32);
85  setEventLength(0);
86 
87  // Check that the size computed by computeHeaderSize() matches what is actually used.
88  if (headerSize() != expectedHeaderSize) {
89  throw cms::Exception("EventMsgBuilder")
90  << "The event message header size (" << headerSize() << " bytes) does not match the computed value ("
91  << expectedHeaderSize << " bytes)";
92  }
93 }
void setEventLength(uint32 len)
static uint32 computeHeaderSize(uint32 l1t_bit_count, uint32 hlt_bit_count)
assert(be >=bs)
uint16_t size_type
uint32 headerSize() const
uint32 size() const
#define MAX_HOSTNAME_LEN
def convert(infile, ofile)
unsigned int uint32
Definition: MsgTools.h:13
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
unsigned char uint8
Definition: MsgTools.h:11
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Definition: event.py:1

Member Function Documentation

◆ bufferSize()

uint32 EventMsgBuilder::bufferSize ( ) const
inline

Definition at line 31 of file EventMsgBuilder.h.

References size_.

31 { return size_; }

◆ computeHeaderSize()

uint32 EventMsgBuilder::computeHeaderSize ( uint32  l1t_bit_count,
uint32  hlt_bit_count 
)
static

Definition at line 111 of file EventMsgBuilder.cc.

References MAX_HOSTNAME_LEN, and size().

Referenced by EventMsgBuilder(), and InitMsgBuilder::InitMsgBuilder().

111  {
112  uint32 size = sizeof(EventHeader); // event header
113  size += sizeof(uint32); // L1T triggers count
114  size += (l1t_bit_count + 8 - 1) / 8; // L1T results (1 bit per trigger)
115  size += sizeof(uint32); // HLT triggers count
116  size += (hlt_bit_count + 4 - 1) / 4; // HLT results (2 bits per trigger)
117  size += sizeof(uint32); // adler32 check sum
118  size += 1; // host name length
119  size += MAX_HOSTNAME_LEN; // host name
120  size += sizeof(char_uint32); // event address
121  return size;
122 }
uint32 size() const
#define MAX_HOSTNAME_LEN
unsigned int uint32
Definition: MsgTools.h:13
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16

◆ eventAddr()

uint8* EventMsgBuilder::eventAddr ( ) const
inline

Definition at line 28 of file EventMsgBuilder.h.

References event_addr_.

28 { return event_addr_; }

◆ headerSize()

uint32 EventMsgBuilder::headerSize ( ) const
inline

Definition at line 29 of file EventMsgBuilder.h.

References buf_, and event_addr_.

Referenced by EventMsgBuilder().

29 { return event_addr_ - buf_; }

◆ setBufAddr()

void EventMsgBuilder::setBufAddr ( uint8 buf_addr)
inline

Definition at line 26 of file EventMsgBuilder.h.

References buf_.

26 { buf_ = buf_addr; }

◆ setEventAddr()

void EventMsgBuilder::setEventAddr ( uint8 event_addr)
inline

Definition at line 27 of file EventMsgBuilder.h.

References event_addr_.

27 { event_addr_ = event_addr; }

◆ setEventLength()

void EventMsgBuilder::setEventLength ( uint32  len)

Definition at line 100 of file EventMsgBuilder.cc.

References buf_, fileCollector::convert(), Header::EVENT, event_addr_, and h.

Referenced by EventMsgBuilder().

100  {
101  convert(len, event_addr_ - sizeof(char_uint32));
103  new (&h->header_) Header(Header::EVENT, event_addr_ - buf_ + len);
104 }
def convert(infile, ofile)
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ setOrigDataSize()

void EventMsgBuilder::setOrigDataSize ( uint32  value)

Definition at line 95 of file EventMsgBuilder.cc.

References buf_, fileCollector::convert(), and h.

95  {
97  convert(value, h->origDataSize_);
98 }
Definition: value.py:1
def convert(infile, ofile)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ size()

uint32 EventMsgBuilder::size ( void  ) const

◆ startAddress()

uint8* EventMsgBuilder::startAddress ( ) const
inline

Definition at line 24 of file EventMsgBuilder.h.

References buf_.

Referenced by StreamerOutputFile::write().

24 { return buf_; }

Member Data Documentation

◆ buf_

uint8* EventMsgBuilder::buf_
private

◆ event_addr_

uint8* EventMsgBuilder::event_addr_
private

◆ size_

uint32 EventMsgBuilder::size_
private

Definition at line 37 of file EventMsgBuilder.h.

Referenced by bufferSize(), and EventMsgBuilder().