CMS 3D CMS Logo

FUShmRecoCell.cc

Go to the documentation of this file.
00001 
00002 //
00003 // FUShmRecoCell
00004 // -------------
00005 //
00006 //            17/03/2007 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
00008 
00009 
00010 #include "EventFilter/ShmBuffer/interface/FUShmRecoCell.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 FUShmRecoCell::FUShmRecoCell(unsigned int payloadSize)
00026   : payloadSize_(payloadSize)
00027 {
00028   payloadOffset_=sizeof(FUShmRecoCell);
00029   void* payloadAddr=(void*)((unsigned int)this+payloadOffset_);
00030   new (payloadAddr) unsigned char[payloadSize_];
00031 }
00032 
00033 
00034 //______________________________________________________________________________
00035 FUShmRecoCell::~FUShmRecoCell()
00036 {
00037 
00038 }
00039 
00040 
00042 // implementation of member functions
00044 
00045 //______________________________________________________________________________
00046 void FUShmRecoCell::initialize(unsigned int index)
00047 {
00048   index_=index;
00049   clear();
00050 }
00051 
00052 
00053 //______________________________________________________________________________
00054 unsigned char* FUShmRecoCell::payloadAddr() const
00055 {
00056   unsigned char* result=(unsigned char*)((unsigned int)this+payloadOffset_);
00057   return result;
00058 }
00059 
00060 
00061 //______________________________________________________________________________
00062 void FUShmRecoCell::clear()
00063 {
00064   eventSize_=0;
00065   rawCellIndex_=0xffffffff;
00066 }
00067 
00068 
00069 //______________________________________________________________________________
00070 void FUShmRecoCell::writeInitMsg(unsigned int   outModId,
00071                                  unsigned int   fuProcessId,
00072                                  unsigned int   fuGuid,
00073                                  unsigned char *data,
00074                                  unsigned int   dataSize)
00075 {
00076   if (eventSize_!=0)
00077     cout<<"FUShmRecoCell::writeInitMsg() WARNING: overwriting data!"<<endl;
00078   
00079   if (dataSize>payloadSize_) {
00080     cout<<"FUShmRecoCell::writeInitMsg() ERROR: data does not fit!"<<endl;
00081     return;
00082   }
00083   
00084   rawCellIndex_=0xffffffff;
00085   runNumber_   =0xffffffff;
00086   evtNumber_   =0xffffffff;
00087   outModId_    =outModId;
00088   fuProcessId_ =fuProcessId;
00089   fuGuid_      =fuGuid;
00090   type_        =0;
00091   unsigned char* targetAddr=payloadAddr();
00092   memcpy(targetAddr,data,dataSize);
00093   eventSize_=dataSize;
00094 }
00095                                   
00096 
00097 //______________________________________________________________________________
00098 void FUShmRecoCell::writeEventData(unsigned int   rawCellIndex,
00099                                    unsigned int   runNumber,
00100                                    unsigned int   evtNumber,
00101                                    unsigned int   outModId,
00102                                    unsigned int   fuProcessId,
00103                                    unsigned int   fuGuid,
00104                                    unsigned char *data,
00105                                    unsigned int   dataSize)
00106 {
00107   if (eventSize_!=0)
00108     cout<<"FUShmRecoCell::writeEventData() WARNING: overwriting data!"<<endl;
00109   
00110   if (dataSize>payloadSize_) {
00111     cout<<"FUShmRecoCell::writeEventData() ERROR: data does not fit!"<<endl;
00112     return;
00113   }
00114   
00115   rawCellIndex_=rawCellIndex;
00116   runNumber_   =runNumber;
00117   evtNumber_   =evtNumber;
00118   outModId_    =outModId;
00119   fuProcessId_ =fuProcessId;
00120   fuGuid_      =fuGuid;
00121   type_        =1;
00122   unsigned char* targetAddr=payloadAddr();
00123   memcpy(targetAddr,data,dataSize);
00124   eventSize_=dataSize;
00125 }
00126                                   
00127 
00128 //______________________________________________________________________________
00129 void FUShmRecoCell::writeErrorEvent(unsigned int   rawCellIndex,
00130                                     unsigned int   runNumber,
00131                                     unsigned int   evtNumber,
00132                                     unsigned int   fuProcessId,
00133                                     unsigned char *data,
00134                                     unsigned int   dataSize)
00135 {
00136   if (eventSize_!=0)
00137     cout<<"FUShmRecoCell::writeEventData() WARNING: overwriting data!"<<endl;
00138   
00139   if (dataSize>payloadSize_) {
00140     cout<<"FUShmRecoCell::writeEventData() ERROR: data does not fit!"<<endl;
00141     return;
00142   }
00143   
00144   rawCellIndex_=rawCellIndex;
00145   runNumber_   =runNumber;
00146   evtNumber_   =evtNumber;
00147   outModId_    =0xffffffff;
00148   fuProcessId_ =fuProcessId;
00149   fuGuid_      =0;
00150   type_        =2;
00151   unsigned char* targetAddr=payloadAddr();
00152   memcpy(targetAddr,data,dataSize);
00153   eventSize_=dataSize;
00154 }
00155                                   
00156 
00157 //______________________________________________________________________________
00158 unsigned int FUShmRecoCell::size(unsigned int payloadSize)
00159 {
00160   return sizeof(FUShmRecoCell)+sizeof(unsigned char)*payloadSize;
00161 }

Generated on Tue Jun 9 17:34:48 2009 for CMSSW by  doxygen 1.5.4