Go to the documentation of this file.00001
00008 #include "IOPool/Streamer/interface/ClassFiller.h"
00009 #include "IOPool/Streamer/interface/StreamDQMSerializer.h"
00010 #include "IOPool/Streamer/interface/StreamSerializer.h"
00011 #include "FWCore/Utilities/interface/Adler32Calculator.h"
00012
00013 #include <cstdlib>
00014
00015 namespace edm
00016 {
00017
00018 StreamDQMSerializer::Arr::Arr(int sz):ptr_((char*)malloc(sz)) { }
00019 StreamDQMSerializer::Arr::~Arr() { free(ptr_); }
00020
00021 const int init_size = 1024*1024;
00022
00026 StreamDQMSerializer::StreamDQMSerializer():
00027 comp_buf_(init_size),
00028 curr_event_size_(),
00029 curr_space_used_(),
00030 rootbuf_(TBuffer::kWrite,init_size),
00031 ptr_((unsigned char*)rootbuf_.Buffer()),
00032 adler32_chksum_(0)
00033 { }
00034
00038 int StreamDQMSerializer::serializeDQMEvent(DQMEvent::TObjectTable& toTable,
00039 bool use_compression,
00040 int compression_level)
00041 {
00042
00043 rootbuf_.Reset();
00044 RootDebug tracer(10,10);
00045
00046
00047 DQMEvent::TObjectTable::const_iterator sfIter;
00048 for (sfIter = toTable.begin(); sfIter != toTable.end(); sfIter++)
00049 {
00050 std::string folderName = sfIter->first;
00051 std::vector<TObject *> toList = sfIter->second;
00052
00053
00054 uint32 meCount = toList.size();
00055 for (int idx = 0; idx < (int) meCount; idx++) {
00056 TObject *toPtr = toList[idx];
00057 rootbuf_.WriteObject(toPtr);
00058 }
00059 }
00060
00061
00062 curr_event_size_ = rootbuf_.Length();
00063 curr_space_used_ = curr_event_size_;
00064 ptr_ = (unsigned char*) rootbuf_.Buffer();
00065
00066
00067 if (use_compression)
00068 {
00069 unsigned int dest_size =
00070 StreamSerializer::compressBuffer(ptr_, curr_event_size_,
00071 comp_buf_, compression_level);
00072
00073 if (dest_size != 0)
00074 {
00075 ptr_ = &comp_buf_[0];
00076 curr_space_used_ = dest_size;
00077 }
00078 }
00079
00080 adler32_chksum_ = cms::Adler32((char*)ptr_, curr_space_used_);
00081
00082
00083 return curr_space_used_;
00084 }
00085 }