CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/IOPool/Streamer/src/FRDEventMessage.cc

Go to the documentation of this file.
00001 
00021 #include "IOPool/Streamer/interface/FRDEventMessage.h"
00022 
00026 FRDEventMsgView::FRDEventMsgView(void* buf): buf_((uint8*)buf)
00027 {
00028   uint32* bufPtr = static_cast<uint32*>(buf);
00029   uint32 versionNumber = *bufPtr;
00030   // if the version number is rather large, then we assume that the true
00031   // version number is one.  (In version one of the format, there was
00032   // no version number in the data, and the run number appeared first.)
00033   if (versionNumber >= 32) {
00034       versionNumber = 1;
00035   }
00036 
00037   // for now, all we need to do here is calculate the full event size
00038   event_len_ = 0;
00039   if (versionNumber >= 2) {
00040       event_len_ += sizeof(uint32);  // version number
00041       ++bufPtr;
00042   }
00043   event_len_ += sizeof(uint32);  // run number
00044   ++bufPtr;
00045   if (versionNumber >= 2) {
00046       event_len_ += sizeof(uint32);  // lumi number
00047       ++bufPtr;
00048   }
00049   event_len_ += sizeof(uint32);  // event number
00050   ++bufPtr;
00051   for (int idx = 0; idx < 1024; idx++) {
00052     event_len_ += sizeof(uint32);  // FED N size
00053     event_len_ += *bufPtr;         // FED N data
00054     ++bufPtr;
00055   }
00056 }
00057 
00058 uint32 FRDEventMsgView::version() const
00059 {
00060   FRDEventHeader_V2* hdr = (FRDEventHeader_V2*) buf_;
00061   uint32 version = hdr->version_;
00062   if (version >= 32) {  // value looks like run number, so assume version 1
00063       return 1;
00064   }
00065   else {  // version 2 and above
00066       return hdr->version_;
00067   }
00068 }
00069 
00070 uint32 FRDEventMsgView::run() const
00071 {
00072   FRDEventHeader_V2* hdr = (FRDEventHeader_V2*) buf_;
00073   uint32 version = hdr->version_;
00074   if (version >= 32) {  // value looks like run number, so assume version 1
00075       FRDEventHeader_V1* hdrV1 = (FRDEventHeader_V1*) buf_;
00076       return hdrV1->run_;
00077   }
00078   else {  // version 2 and above
00079       return hdr->run_;
00080   }
00081 }
00082 
00083 uint32 FRDEventMsgView::lumi() const
00084 {
00085   FRDEventHeader_V2* hdr = (FRDEventHeader_V2*) buf_;
00086   uint32 version = hdr->version_;
00087   if (version >= 32) {  // value looks like run number, so assume version 1
00088       return 1;
00089   }
00090   else {  // version 2 and above
00091       return hdr->lumi_;
00092   }
00093 }
00094 
00095 uint32 FRDEventMsgView::event() const
00096 {
00097   FRDEventHeader_V2* hdr = (FRDEventHeader_V2*) buf_;
00098   uint32 version = hdr->version_;
00099   if (version >= 32) {  // value looks like run number, so assume version 1
00100       FRDEventHeader_V1* hdrV1 = (FRDEventHeader_V1*) buf_;
00101       return hdrV1->event_;
00102   }
00103   else {  // version 2 and above
00104       return hdr->event_;
00105   }
00106 }