CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleMsgBuf.cc
Go to the documentation of this file.
2 #include <cstring>
3 #include <iostream>
4 
5 using namespace evf;
6 
8  MsgBuf(), usedSize_(0) {
10 }
11 
12 SimpleMsgBuf::SimpleMsgBuf(unsigned int size, unsigned int type) :
13  MsgBuf(size, type), usedSize_(0) {
15 }
16 
18 
19 }
20 
21 //TODO ensure buffer is big enough for all these operations
22 
23 void SimpleMsgBuf::setRLE(unsigned int run, unsigned int lumi, unsigned int evt) {
24  // copy run number
25  memcpy(pRun_, &run, sizeof(unsigned int));
26  // copy lumi number
27  memcpy(pLumi_, &lumi, sizeof(unsigned int));
28  // copy event number
29  memcpy(pEvt_, &evt, sizeof(unsigned int));
30 }
31 
32 void SimpleMsgBuf::addFedSize(unsigned int fedSize) {
33  memcpy(pVarSize_, &fedSize, sizeof(unsigned int));
34  pVarSize_ += sizeof(unsigned int);
35 }
36 
37 void SimpleMsgBuf::addFedData(const unsigned char* fedRawData,
38  unsigned int segmentSize) {
39  memcpy(pVarData_, fedRawData, segmentSize);
40  pVarData_ += segmentSize;
41 
42  // increase used size by current fed data
43  usedSize_ += segmentSize;
44 
45 }
46 
47 void SimpleMsgBuf::getRun(unsigned int& run) const {
48  memcpy(&run, pRun_, sizeof(unsigned int));
49 }
50 
51 void SimpleMsgBuf::getLumi(unsigned int& lumi) const {
52  memcpy(&lumi, pLumi_, sizeof(unsigned int));
53 }
54 
55 void SimpleMsgBuf::getEvt(unsigned int& evt) const {
56  memcpy(&evt, pEvt_, sizeof(unsigned int));
57 }
58 
60  return pFedSizes_;
61 }
62 
64  return pFedRawData_;
65 }
66 
68  return pVarData_;
69 }
70 
72  pRun_ = ptr_->mtext;
73  pLumi_ = pRun_ + sizeof(unsigned int);
74  pEvt_ = pLumi_ + sizeof(unsigned int);
75  pFedSizes_ = pEvt_ + sizeof(unsigned int);
76  pFedRawData_ = pFedSizes_ + N_FEDS * sizeof(unsigned int);
77 
78  // used size is size of header (run, lumi, evt, N_FEDS * sizeof(unsigned int))
79  // increases as raw data is added
80  usedSize_ = pFedRawData_ - pRun_;
81 
84 }
type
Definition: HCALResponse.h:22
void getLumi(unsigned int &) const
Definition: SimpleMsgBuf.cc:51
struct msgbuf * ptr_
Definition: MsgBuf.h:24
tuple lumi
Definition: fjr2json.py:35
void getEvt(unsigned int &) const
Definition: SimpleMsgBuf.cc:55
void setBufferPointers()
Definition: SimpleMsgBuf.cc:71
char * getFedDataEnd()
Definition: SimpleMsgBuf.cc:67
#define N_FEDS
Definition: SimpleMsgBuf.h:21
void addFedData(const unsigned char *fedRawData, unsigned int segmentSize)
Definition: SimpleMsgBuf.cc:37
void setRLE(unsigned int run, unsigned int lumi, unsigned int evt)
Definition: SimpleMsgBuf.cc:23
void getRun(unsigned int &) const
Definition: SimpleMsgBuf.cc:47
void addFedSize(unsigned int fedSize)
Definition: SimpleMsgBuf.cc:32
virtual ~SimpleMsgBuf()
Definition: SimpleMsgBuf.cc:17
char * getFedDataStart()
Definition: SimpleMsgBuf.cc:63
char * getFedSizeStart()
Definition: SimpleMsgBuf.cc:59
tuple size
Write out results.