CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edm::streamer::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 9 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 12 of file EventMsgBuilder.cc.

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

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

Definition at line 32 of file EventMsgBuilder.h.

References size_.

32 { return size_; }

◆ computeHeaderSize()

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

Definition at line 113 of file EventMsgBuilder.cc.

References MAX_HOSTNAME_LEN, and size().

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

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

◆ eventAddr()

uint8* edm::streamer::EventMsgBuilder::eventAddr ( ) const
inline

Definition at line 29 of file EventMsgBuilder.h.

References event_addr_.

◆ headerSize()

uint32 edm::streamer::EventMsgBuilder::headerSize ( ) const
inline

Definition at line 30 of file EventMsgBuilder.h.

References buf_, and event_addr_.

Referenced by EventMsgBuilder().

◆ setBufAddr()

void edm::streamer::EventMsgBuilder::setBufAddr ( uint8 buf_addr)
inline

Definition at line 27 of file EventMsgBuilder.h.

References buf_.

27 { buf_ = buf_addr; }

◆ setEventAddr()

void edm::streamer::EventMsgBuilder::setEventAddr ( uint8 event_addr)
inline

Definition at line 28 of file EventMsgBuilder.h.

References event_addr_.

28 { event_addr_ = event_addr; }

◆ setEventLength()

void EventMsgBuilder::setEventLength ( uint32  len)

Definition at line 102 of file EventMsgBuilder.cc.

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

Referenced by EventMsgBuilder().

102  {
103  convert(len, event_addr_ - sizeof(char_uint32));
105  new (&h->header_) Header(Header::EVENT, event_addr_ - buf_ + len);
106 }
void convert(uint32 i, char_uint32 v)
Definition: MsgTools.h:43
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:17
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 97 of file EventMsgBuilder.cc.

References buf_, edm::streamer::convert(), and h.

97  {
99  convert(value, h->origDataSize_);
100 }
void convert(uint32 i, char_uint32 v)
Definition: MsgTools.h:43
Definition: value.py:1
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* edm::streamer::EventMsgBuilder::startAddress ( ) const
inline

Definition at line 25 of file EventMsgBuilder.h.

References buf_.

Referenced by edm::streamer::StreamerOutputFile::write().

25 { return buf_; }

Member Data Documentation

◆ buf_

uint8* edm::streamer::EventMsgBuilder::buf_
private

◆ event_addr_

uint8* edm::streamer::EventMsgBuilder::event_addr_
private

◆ size_

uint32 edm::streamer::EventMsgBuilder::size_
private

Definition at line 38 of file EventMsgBuilder.h.

Referenced by bufferSize(), and EventMsgBuilder().