CMS 3D CMS Logo

Public Member Functions | Private Attributes

EventMsgBuilder Class Reference

#include <EventMsgBuilder.h>

List of all members.

Public Member Functions

uint32 bufferSize () const
uint8eventAddr () const
 EventMsgBuilder (void *buf, uint32 size, uint32 run, uint32 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 setEventLength (uint32 len)
void setOrigDataSize (uint32)
uint32 size () const
uint8startAddress () const

Private Attributes

uint8buf_
uint8event_addr_
uint32 size_

Detailed Description

Definition at line 8 of file EventMsgBuilder.h.


Constructor & Destructor Documentation

EventMsgBuilder::EventMsgBuilder ( void *  buf,
uint32  size,
uint32  run,
uint32  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 9 of file EventMsgBuilder.cc.

References buf_, lhef::cc::convert(), filterCSVwithJSON::copy, EventHeader::droppedEventsCount_, EventHeader::event_, event_addr_, h, i, EventHeader::lumi_, MAX_HOSTNAME_LEN, EventHeader::outModId_, pos, EventHeader::protocolVersion_, EventHeader::run_, setEventLength(), and findQualityFiles::v.

                                                                            :
  buf_((uint8*)buf),size_(size)
{
  EventHeader* h = (EventHeader*)buf_;
  h->protocolVersion_ = 9;
  convert(run,h->run_);
  convert(event,h->event_);
  convert(lumi,h->lumi_);
  convert(outModId,h->outModId_);
  convert(droppedEventsCount,h->droppedEventsCount_);
  uint8* pos = buf_ + sizeof(EventHeader);

  // l1 count
  uint32 l1_count = l1_bits.size();
  convert(l1_count, pos);
  pos = pos + sizeof(uint32); 

  // set the l1 
  uint32 l1_sz = l1_bits.size();
  if (l1_sz != 0) l1_sz = 1 + ((l1_sz-1)/8);
 
  uint8* pos_end = pos + l1_sz;
  memset(pos,0x00, pos_end-pos); // clear the bits
  for(std::vector<bool>::size_type i = 0; i < l1_bits.size(); ++i) {
      uint8 v = l1_bits[i] ? 1 : 0;
      pos[i/8] |= (v << (i&0x07));
  }
  pos = pos_end;

  // hlt count
  convert(hlt_bit_count, pos); 
  pos = pos + sizeof(uint32);

  uint32 hlt_sz = hlt_bit_count;
  if (hlt_sz != 0) hlt_sz = 1+ ((hlt_sz-1)/4);

  // copy the hlt bits over
  pos = std::copy(hlt_bits, hlt_bits+hlt_sz, pos);

  // adler32 check sum of data blob
  convert(adler_chksum, pos);
  pos = pos + sizeof(uint32);

  // put host name (Length and then Name) right after check sum
  //uint32 host_name_len = strlen(host_name);
  // actually make the host_name a fixed length as the event header size appears in the
  // Init message and only one goes to a file whereas events can come from any node
  // We want the max length to be determined inside this Event Message Builder
  uint32 host_name_len = MAX_HOSTNAME_LEN;
  assert(host_name_len < 0x00ff);
  //Put host_name_len
  *pos++ = host_name_len;

  //Put host_name
  uint32 real_len = strlen(host_name);
  if(real_len < host_name_len) {
    char hostname_2use[MAX_HOSTNAME_LEN];
    memset(hostname_2use,'\0',host_name_len);
    memcpy(hostname_2use,host_name,real_len);
    memcpy(pos,hostname_2use,host_name_len);
  } else {
    memcpy(pos,host_name,host_name_len);
  }
  pos += host_name_len;

  event_addr_ = pos + sizeof(char_uint32);
  setEventLength(0);
}

Member Function Documentation

uint32 EventMsgBuilder::bufferSize ( ) const [inline]

Definition at line 24 of file EventMsgBuilder.h.

References size_.

{return size_;}
uint8* EventMsgBuilder::eventAddr ( ) const [inline]

Definition at line 21 of file EventMsgBuilder.h.

References event_addr_.

{ return event_addr_; }
uint32 EventMsgBuilder::headerSize ( ) const [inline]

Definition at line 22 of file EventMsgBuilder.h.

References buf_, and event_addr_.

Referenced by InitMsgBuilder::InitMsgBuilder().

{return event_addr_-buf_;} 
void EventMsgBuilder::setEventLength ( uint32  len)
void EventMsgBuilder::setOrigDataSize ( uint32  value)
uint32 EventMsgBuilder::size ( void  ) const

Definition at line 96 of file EventMsgBuilder.cc.

References buf_, HeaderView::size(), and findQualityFiles::v.

Referenced by edm::FUShmOutputModule::doOutputEvent().

{
  HeaderView v(buf_);
  return v.size();
}
uint8* EventMsgBuilder::startAddress ( ) const [inline]

Member Data Documentation

Definition at line 29 of file EventMsgBuilder.h.

Referenced by eventAddr(), EventMsgBuilder(), headerSize(), and setEventLength().

Definition at line 28 of file EventMsgBuilder.h.

Referenced by bufferSize().