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 <iostream> 00013 00014 namespace edm 00015 { 00016 namespace { 00017 const int init_size = 1024*1024; 00018 } 00019 00023 StreamDQMDeserializer::StreamDQMDeserializer(): 00024 decompressBuffer_(init_size), 00025 workTBuffer_(TBuffer::kRead, init_size) 00026 { } 00027 00033 std::auto_ptr<DQMEvent::TObjectTable> 00034 StreamDQMDeserializer::deserializeDQMEvent(DQMEventMsgView const& dqmEventView) 00035 { 00036 if (dqmEventView.code() != Header::DQM_EVENT) 00037 throw cms::Exception("StreamTranslation", 00038 "DQM Event deserialization error") 00039 << "received wrong message type: expected DQM_EVENT (" 00040 << Header::DQM_EVENT << "), got " << dqmEventView.code() << "\n"; 00041 FDEBUG(9) << "Deserialing DQM event: " 00042 << dqmEventView.eventNumberAtUpdate() << " " 00043 << dqmEventView.runNumber() << " " 00044 << dqmEventView.size() << " " 00045 << dqmEventView.eventLength() << " " 00046 << dqmEventView.eventAddress() 00047 << std::endl; 00048 00049 00050 // create the folder name to TObject map 00051 std::auto_ptr<DQMEvent::TObjectTable> tablePtr(new DQMEvent::TObjectTable()); 00052 00053 // fetch the number of subfolders 00054 uint32 subFolderCount = dqmEventView.subFolderCount(); 00055 00056 // handle compressed data, if needed 00057 unsigned char *bufPtr = dqmEventView.eventAddress(); 00058 unsigned int bufLen = dqmEventView.eventLength(); 00059 unsigned int originalSize = dqmEventView.compressionFlag(); 00060 if (originalSize != 0) 00061 { 00062 unsigned int actualSize = 00063 StreamerInputSource::uncompressBuffer(bufPtr, bufLen, 00064 decompressBuffer_, 00065 originalSize); 00066 bufPtr = &decompressBuffer_[0]; 00067 bufLen = actualSize; 00068 } 00069 00070 // wrap a TBuffer around the DQM event data so that we can read out the 00071 // monitor elements 00072 workTBuffer_.Reset(); 00073 workTBuffer_.SetBuffer(bufPtr, bufLen, kFALSE); 00074 00075 // loop over the subfolders 00076 for (uint32 fdx = 0; fdx < subFolderCount; fdx++) 00077 { 00078 00079 // create the list of monitor elements in the subfolder 00080 std::vector<TObject *> meList; 00081 int meCount = dqmEventView.meCount(fdx); 00082 for (int mdx = 0; mdx < meCount; mdx++) 00083 { 00084 TObject *tmpPtr = workTBuffer_.ReadObject(TObject::Class()); 00085 meList.push_back(tmpPtr); 00086 } 00087 00088 // store the list of monitor elements in the table 00089 std::string subFolderName = dqmEventView.subFolderName(fdx); 00090 (*tablePtr)[subFolderName] = meList; 00091 } 00092 00093 return tablePtr; 00094 } 00095 }