CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/IOPool/Streamer/src/StreamDQMDeserializer.cc

Go to the documentation of this file.
00001 
00008 #include "FWCore/Utilities/interface/DebugMacros.h"
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 #include "IOPool/Streamer/interface/StreamDQMDeserializer.h"
00011 #include "IOPool/Streamer/interface/StreamerInputSource.h"
00012 #include "FWCore/Utilities/interface/Adler32Calculator.h"
00013 #include <iostream>
00014 
00015 namespace edm
00016 {
00017   namespace {
00018     const int init_size = 1024*1024;
00019   }
00020 
00024   StreamDQMDeserializer::StreamDQMDeserializer():
00025     decompressBuffer_(init_size),
00026     workTBuffer_(TBuffer::kRead, init_size)
00027   { }
00028 
00034   std::auto_ptr<DQMEvent::TObjectTable>
00035   StreamDQMDeserializer::deserializeDQMEvent(DQMEventMsgView const& dqmEventView)
00036   {
00037     if (dqmEventView.code() != Header::DQM_EVENT)
00038       throw cms::Exception("StreamTranslation",
00039                            "DQM Event deserialization error")
00040         << "received wrong message type: expected DQM_EVENT ("
00041         << Header::DQM_EVENT << "), got " << dqmEventView.code() << "\n";
00042     FDEBUG(9) << "Deserialing DQM event: "
00043          << dqmEventView.eventNumberAtUpdate() << " "
00044          << dqmEventView.runNumber() << " "
00045          << dqmEventView.size() << " "
00046          << dqmEventView.adler32_chksum() << " "
00047          << dqmEventView.hostName() << " "
00048          << dqmEventView.eventLength() << " "
00049          << dqmEventView.eventAddress()
00050          << std::endl;
00051 
00052 
00053     // create the folder name to TObject map
00054     std::auto_ptr<DQMEvent::TObjectTable> tablePtr(new DQMEvent::TObjectTable());
00055 
00056     // fetch the number of subfolders
00057     uint32 subFolderCount = dqmEventView.subFolderCount();
00058 
00059     // handle compressed data, if needed
00060     unsigned char *bufPtr = dqmEventView.eventAddress();
00061     unsigned int bufLen = dqmEventView.eventLength();
00062     unsigned int originalSize = dqmEventView.compressionFlag();
00063 
00064     uint32_t adler32_chksum = cms::Adler32((char*)dqmEventView.eventAddress(), dqmEventView.eventLength());
00065     if((uint32)adler32_chksum != dqmEventView.adler32_chksum()) {
00066       throw cms::Exception("StreamTranslation",
00067                            "DQM Event chksum error")
00068           << "Error from StreamDQMSerializer: checksum of event data blob failed:" << std::endl
00069           << "chksum from event = " << adler32_chksum << " from header = "
00070           << dqmEventView.adler32_chksum() << " host name = "
00071           << dqmEventView.hostName() << std::endl;
00072     }
00073 
00074     if (originalSize != 0)
00075       {
00076         unsigned int actualSize =
00077           StreamerInputSource::uncompressBuffer(bufPtr, bufLen,
00078                                                decompressBuffer_,
00079                                                originalSize);
00080         bufPtr = &decompressBuffer_[0];
00081         bufLen = actualSize;
00082       }
00083 
00084     // wrap a TBuffer around the DQM event data so that we can read out the
00085     // monitor elements
00086     workTBuffer_.Reset();
00087     workTBuffer_.SetBuffer(bufPtr, bufLen, kFALSE);
00088 
00089     // loop over the subfolders
00090     for (uint32 fdx = 0; fdx < subFolderCount; fdx++)
00091       {
00092 
00093         // create the list of monitor elements in the subfolder
00094         std::vector<TObject *> meList;
00095         int meCount = dqmEventView.meCount(fdx);
00096         for (int mdx = 0; mdx < meCount; mdx++)
00097           {
00098             TObject *tmpPtr = workTBuffer_.ReadObject(TObject::Class());
00099             meList.push_back(tmpPtr);
00100           }
00101 
00102         // store the list of monitor elements in the table
00103         std::string subFolderName = dqmEventView.subFolderName(fdx);
00104         (*tablePtr)[subFolderName] = meList;
00105       }
00106 
00107     return tablePtr;
00108   }
00109 }