CMS 3D CMS Logo

StreamerOutputIndexFile.cc

Go to the documentation of this file.
00001 #include "IOPool/Streamer/interface/StreamerOutputIndexFile.h"
00002 #include "IOPool/Streamer/interface/EOFRecordBuilder.h"
00003 
00004 #include <fstream>
00005 
00006  StreamerOutputIndexFile::StreamerOutputIndexFile(const std::string& name): 
00007  indexfile_(new OutputFile(name))
00008   {
00009     indexfile_->set_do_adler(1);
00010   }
00011 
00012   StreamerOutputIndexFile::~StreamerOutputIndexFile() 
00013   {
00014     delete indexfile_; 
00015   }
00016 
00017   void StreamerOutputIndexFile::write(const InitMsgBuilder& inview)
00018   {
00019     indexfile_->write((const char*)
00020                       inview.startAddress(),
00021                       inview.headerSize() ) ;
00022     indexfile_->set_run(inview.run());
00023   }
00024 
00025   void StreamerOutputIndexFile::write(const InitMsgView& inview)
00026   {
00027     indexfile_->write((const char*)
00028                       inview.startAddress(),
00029                       inview.headerSize() ) ;
00030     indexfile_->set_run(inview.run());
00031   }
00032 
00033   void StreamerOutputIndexFile::write(const EventMsgBuilder& ineview, 
00034                                       uint64 offset)
00035   {
00037     indexfile_->write((const char*)
00038                       ineview.startAddress(),
00039                       ineview.headerSize() ) ;
00040 
00042     uint64 offsetstr;
00043     convert(offset, (unsigned char*)&offsetstr);
00044     indexfile_->write((const char*) &offsetstr, sizeof(uint64) );
00045     if (indexfile_->events() == 0) 
00046       indexfile_->set_first_event_offset(offset);
00047     indexfile_->inc_events(); 
00049     indexfile_->set_last_event_offset(offset);
00050   }
00051 
00052   void StreamerOutputIndexFile::write(const EventMsgView& ineview,
00053                                       uint64 offset)
00054   {
00056     indexfile_->write((const char*)
00057                       ineview.startAddress(),
00058                       ineview.headerSize() ) ;
00059 
00061     uint64 offsetstr;
00062     convert(offset, (unsigned char*)&offsetstr);
00063     indexfile_->write((const char*) &offsetstr, sizeof(uint64) );
00064     if (indexfile_->events() == 0)
00065       indexfile_->set_first_event_offset(offset);
00066     indexfile_->inc_events();
00068     indexfile_->set_last_event_offset(offset);
00069   }
00070 
00071 
00072   void StreamerOutputIndexFile::writeIndexFileHeader(uint32 magicNumber, 
00073                                                      uint64 reserved) 
00074   {
00075     //04 Bytes Magic Number
00076     uint32 magicstr;
00077     convert(magicNumber, (unsigned char*)&magicstr);
00078     indexfile_->write((const char*) &magicstr, sizeof(uint32) );
00079 
00080     //08 Bytes Reserved Value
00081     uint64 reservedstr;
00082     convert(reserved, (unsigned char*)&reservedstr);
00083     indexfile_->write((const char*) &reservedstr, sizeof(uint64) );
00084   }
00085 
00086 
00087   uint32 StreamerOutputIndexFile::writeEOF(uint32 statusCode,
00088                                            const std::vector<uint32>& hltStats)
00089   {
00090 
00091     EOFRecordBuilder eof(indexfile_->run(),
00092                          indexfile_->events(),
00093                          statusCode,
00094                          hltStats,
00095                          indexfile_->first_event_offset(),
00096                          indexfile_->last_event_offset());
00097     indexfile_->write((const char*)
00098                       eof.recAddress(),
00099                       eof.size() );
00100     return eof.size();
00101   }
00102 

Generated on Tue Jun 9 17:39:18 2009 for CMSSW by  doxygen 1.5.4