CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/IOPool/Streamer/src/StreamerFileWriter.h

Go to the documentation of this file.
00001 #ifndef IOPool_Streamer_StreamerFileWriter_h
00002 #define IOPool_Streamer_StreamerFileWriter_h 
00003 
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 
00006 #include "IOPool/Streamer/interface/StreamerOutputFile.h"
00007 #include "IOPool/Streamer/interface/InitMsgBuilder.h"
00008 #include "IOPool/Streamer/interface/EventMsgBuilder.h"
00009 #include "IOPool/Streamer/interface/InitMessage.h"
00010 #include "IOPool/Streamer/interface/EventMessage.h"
00011 #include "IOPool/Streamer/interface/MsgTools.h"
00012 
00013 #include <iostream>
00014 #include <vector>
00015 #include <memory>
00016 #include <string>
00017 
00018 namespace edm
00019 {
00020   struct StreamerFileWriterHeaderParams
00021   {
00022     uint32 runNumber;
00023     uint32 hltCount;
00024     const char* headerPtr;
00025     uint32 headerSize;
00026 
00027     uint32 fragmentIndex;
00028     uint32 fragmentCount;
00029     const char* dataPtr;
00030     uint32 dataSize;
00031   };
00032 
00033   struct StreamerFileWriterEventParams
00034   {
00035     std::vector<unsigned char> hltBits;
00036     const char* headerPtr;
00037     uint32 headerSize;
00038 
00039     uint32 fragmentIndex;
00040     uint32 fragmentCount;
00041     const char* dataPtr;
00042     uint32 dataSize;
00043   };
00044 
00045   class ParameterSetDescription;
00046   class StreamerFileWriter 
00047   {
00048   public:
00049 
00050     explicit StreamerFileWriter(edm::ParameterSet const& ps);
00051     explicit StreamerFileWriter(std::string const& fileName);
00052     ~StreamerFileWriter();
00053 
00054     static void fillDescription(ParameterSetDescription& desc);
00055 
00056     void doOutputHeader(InitMsgBuilder const& init_message);    
00057     void doOutputHeader(InitMsgView const& init_message);    
00058     void doOutputHeaderFragment(StreamerFileWriterHeaderParams const&);
00059 
00060     void doOutputEvent(EventMsgBuilder const& msg);
00061     void doOutputEvent(EventMsgView const& msg);
00062     void doOutputEventFragment(StreamerFileWriterEventParams const&);
00063 
00064     void start(){}
00065     void stop();
00066     // Returns the sizes of EOF records, call them after 
00067     // u called stop, just before destruction
00068     uint32 getStreamEOFSize() const {return stream_eof_size_;}
00069 
00070     uint32 get_adler32() const { return stream_writer_->adler32();}
00071 
00072   private:
00073     void updateHLTStats(std::vector<uint8> const& packedHlt);
00074 
00075     std::auto_ptr<StreamerOutputFile> stream_writer_;
00076     uint32 hltCount_;
00077     std::vector<uint32> hltStats_;
00078     uint32 stream_eof_size_;
00079 
00080   };
00081 }
00082 #endif