CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/EventFilter/Utilities/src/SimpleMsgBuf.cc

Go to the documentation of this file.
00001 #include "EventFilter/Utilities/interface/SimpleMsgBuf.h"
00002 #include <cstring>
00003 #include <iostream>
00004 
00005 using namespace evf;
00006 
00007 SimpleMsgBuf::SimpleMsgBuf() :
00008         MsgBuf(), usedSize_(0) {
00009         setBufferPointers();
00010 }
00011 
00012 SimpleMsgBuf::SimpleMsgBuf(unsigned int size, unsigned int type) :
00013         MsgBuf(size, type), usedSize_(0) {
00014         setBufferPointers();
00015 }
00016 
00017 SimpleMsgBuf::~SimpleMsgBuf() {
00018 
00019 }
00020 
00021 //TODO ensure buffer is big enough for all these operations
00022 
00023 void SimpleMsgBuf::setRLE(unsigned int run, unsigned int lumi, unsigned int evt) {
00024         // copy run number
00025         memcpy(pRun_, &run, sizeof(unsigned int));
00026         // copy lumi number
00027         memcpy(pLumi_, &lumi, sizeof(unsigned int));
00028         // copy event number
00029         memcpy(pEvt_, &evt, sizeof(unsigned int));
00030 }
00031 
00032 void SimpleMsgBuf::addFedSize(unsigned int fedSize) {
00033         memcpy(pVarSize_, &fedSize, sizeof(unsigned int));
00034         pVarSize_ += sizeof(unsigned int);
00035 }
00036 
00037 void SimpleMsgBuf::addFedData(const unsigned char* fedRawData,
00038                 unsigned int segmentSize) {
00039         memcpy(pVarData_, fedRawData, segmentSize);
00040         pVarData_ += segmentSize;
00041 
00042         // increase used size by current fed data
00043         usedSize_ += segmentSize;
00044 
00045 }
00046 
00047 void SimpleMsgBuf::getRun(unsigned int& run) const {
00048         memcpy(&run, pRun_, sizeof(unsigned int));
00049 }
00050 
00051 void SimpleMsgBuf::getLumi(unsigned int& lumi) const {
00052         memcpy(&lumi, pLumi_, sizeof(unsigned int));
00053 }
00054 
00055 void SimpleMsgBuf::getEvt(unsigned int& evt) const {
00056         memcpy(&evt, pEvt_, sizeof(unsigned int));
00057 }
00058 
00059 char* SimpleMsgBuf::getFedSizeStart() {
00060         return pFedSizes_;
00061 }
00062 
00063 char* SimpleMsgBuf::getFedDataStart() {
00064         return pFedRawData_;
00065 }
00066 
00067 char* SimpleMsgBuf::getFedDataEnd() {
00068         return pVarData_;
00069 }
00070 
00071 void SimpleMsgBuf::setBufferPointers() {
00072         pRun_ = ptr_->mtext;
00073         pLumi_ = pRun_ + sizeof(unsigned int);
00074         pEvt_ = pLumi_ + sizeof(unsigned int);
00075         pFedSizes_ = pEvt_ + sizeof(unsigned int);
00076         pFedRawData_ = pFedSizes_ + N_FEDS * sizeof(unsigned int);
00077 
00078         // used size is size of header (run, lumi, evt, N_FEDS * sizeof(unsigned int))
00079         // increases as raw data is added
00080         usedSize_ = pFedRawData_ - pRun_;
00081 
00082         pVarSize_ = pFedSizes_;
00083         pVarData_ = pFedRawData_;
00084 }