CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StreamDQMDeserializer.cc
Go to the documentation of this file.
1 
13 #include <iostream>
14 
15 namespace edm
16 {
17  namespace {
18  const int init_size = 1024*1024;
19  }
20 
25  decompressBuffer_(init_size),
26  workTBuffer_(TBuffer::kRead, init_size)
27  { }
28 
34  std::auto_ptr<DQMEvent::TObjectTable>
36  {
37  if (dqmEventView.code() != Header::DQM_EVENT)
38  throw cms::Exception("StreamTranslation",
39  "DQM Event deserialization error")
40  << "received wrong message type: expected DQM_EVENT ("
41  << Header::DQM_EVENT << "), got " << dqmEventView.code() << "\n";
42  FDEBUG(9) << "Deserialing DQM event: "
43  << dqmEventView.eventNumberAtUpdate() << " "
44  << dqmEventView.runNumber() << " "
45  << dqmEventView.size() << " "
46  << dqmEventView.adler32_chksum() << " "
47  << dqmEventView.hostName() << " "
48  << dqmEventView.eventLength() << " "
49  << dqmEventView.eventAddress()
50  << std::endl;
51 
52 
53  // create the folder name to TObject map
54  std::auto_ptr<DQMEvent::TObjectTable> tablePtr(new DQMEvent::TObjectTable());
55 
56  // fetch the number of subfolders
57  uint32 subFolderCount = dqmEventView.subFolderCount();
58 
59  // handle compressed data, if needed
60  unsigned char *bufPtr = dqmEventView.eventAddress();
61  unsigned int bufLen = dqmEventView.eventLength();
62  unsigned int originalSize = dqmEventView.compressionFlag();
63 
64  uint32_t adler32_chksum = cms::Adler32((char*)dqmEventView.eventAddress(), dqmEventView.eventLength());
65  if((uint32)adler32_chksum != dqmEventView.adler32_chksum()) {
66  throw cms::Exception("StreamTranslation",
67  "DQM Event chksum error")
68  << "Error from StreamDQMSerializer: checksum of event data blob failed:" << std::endl
69  << "chksum from event = " << adler32_chksum << " from header = "
70  << dqmEventView.adler32_chksum() << " host name = "
71  << dqmEventView.hostName() << std::endl;
72  }
73 
74  if (originalSize != 0)
75  {
76  unsigned int actualSize =
79  originalSize);
80  bufPtr = &decompressBuffer_[0];
81  bufLen = actualSize;
82  }
83 
84  // wrap a TBuffer around the DQM event data so that we can read out the
85  // monitor elements
86  workTBuffer_.Reset();
87  workTBuffer_.SetBuffer(bufPtr, bufLen, kFALSE);
88 
89  // loop over the subfolders
90  for (uint32 fdx = 0; fdx < subFolderCount; fdx++)
91  {
92 
93  // create the list of monitor elements in the subfolder
94  std::vector<TObject *> meList;
95  int meCount = dqmEventView.meCount(fdx);
96  for (int mdx = 0; mdx < meCount; mdx++)
97  {
98  TObject *tmpPtr = workTBuffer_.ReadObject(TObject::Class());
99  meList.push_back(tmpPtr);
100  }
101 
102  // store the list of monitor elements in the table
103  std::string subFolderName = dqmEventView.subFolderName(fdx);
104  (*tablePtr)[subFolderName] = meList;
105  }
106 
107  return tablePtr;
108  }
109 }
uint8 * eventAddress() const
uint32 eventNumberAtUpdate() const
#define FDEBUG(lev)
Definition: DebugMacros.h:18
uint32 adler32_chksum() const
const int init_size
uint32 meCount(std::string const &subFolderName) const
std::vector< unsigned char > decompressBuffer_
uint32 subFolderCount() const
std::auto_ptr< DQMEvent::TObjectTable > deserializeDQMEvent(DQMEventMsgView const &dqmEventView)
uint32 eventLength() const
std::string subFolderName(uint32 const subFolderIndex) const
uint32 compressionFlag() const
unsigned int uint32
Definition: MsgTools.h:13
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
uint32 code() const
std::string hostName() const
std::map< std::string, std::vector< TObject * > > TObjectTable
uint32 size() const
uint32 runNumber() const
static unsigned int uncompressBuffer(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, unsigned int expectedFullSize)