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