CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/EventFilter/ShmBuffer/src/FUShmDqmCell.cc

Go to the documentation of this file.
00001 
00002 //
00003 // FUShmDqmCell
00004 // ------------
00005 //
00006 //            17/03/2007 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
00008 
00009 
00010 #include "EventFilter/ShmBuffer/interface/FUShmDqmCell.h"
00011 
00012 #include <iostream>
00013 #include <iomanip>
00014 #include <cstring>
00015 
00016 using namespace std;
00017 using namespace evf;
00018 
00019 
00021 // construction/destruction
00023 
00024 //______________________________________________________________________________
00025 FUShmDqmCell::FUShmDqmCell(unsigned int payloadSize)
00026   : payloadSize_(payloadSize)
00027 {
00028   payloadOffset_=sizeof(FUShmDqmCell);
00029   void* payloadAddr=(void*)((unsigned long)this+payloadOffset_);
00030   new (payloadAddr) unsigned char[payloadSize_];
00031 }
00032 
00033 
00034 //______________________________________________________________________________
00035 FUShmDqmCell::~FUShmDqmCell()
00036 {
00037 
00038 }
00039 
00040 
00042 // implementation of member functions
00044 
00045 //______________________________________________________________________________
00046 void FUShmDqmCell::initialize(unsigned int index)
00047 {
00048   index_=index;
00049   clear();
00050 }
00051 
00052 
00053 //______________________________________________________________________________
00054 unsigned char* FUShmDqmCell::payloadAddr() const
00055 {
00056   unsigned char* result=(unsigned char*)((unsigned long)this+payloadOffset_);
00057   return result;
00058 }
00059 
00060 
00061 //______________________________________________________________________________
00062 void FUShmDqmCell::clear()
00063 {
00064   eventSize_=0;
00065 }
00066 
00067 
00068 //______________________________________________________________________________
00069 void FUShmDqmCell::writeData(unsigned int   runNumber,
00070                              unsigned int   evtAtUpdate,
00071                              unsigned int   folderId,
00072                              unsigned int   fuProcessId,
00073                              unsigned int   fuGuid,
00074                              unsigned char *data,
00075                              unsigned int   dataSize)
00076 {
00077   if (eventSize_!=0)
00078     cout<<"FUShmDqmCell::writeData WARNING: overwriting data!"<<endl;
00079   
00080   if (dataSize>payloadSize_) {
00081     cout<<"FUShmDqmCell::writeData ERROR: data does not fit!"<<endl;
00082     return;
00083   }
00084   
00085   runNumber_  =runNumber;
00086   evtAtUpdate_=evtAtUpdate;
00087   folderId_   =folderId;
00088   fuProcessId_=fuProcessId;
00089   fuGuid_     =fuGuid;
00090   unsigned char* targetAddr=payloadAddr();
00091   memcpy(targetAddr,data,dataSize);
00092   eventSize_=dataSize;
00093 }
00094 
00095 
00096 //______________________________________________________________________________
00097 unsigned int FUShmDqmCell::size(unsigned int payloadSize)
00098 {
00099   return sizeof(FUShmDqmCell)+sizeof(unsigned char)*payloadSize;
00100 }