Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-22 04:08:30

0001 #include "IOPool/Streamer/interface/StreamerOutputFile.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 
0004 StreamerOutputFile::~StreamerOutputFile() {}
0005 
0006 StreamerOutputFile::StreamerOutputFile(const std::string& name)
0007     : streamerfile_(std::make_shared<edm::streamer::OutputFile>(name)) {
0008   streamerfile_->set_do_adler(true);
0009 }
0010 
0011 uint64 StreamerOutputFile::write(const EventMsgBuilder& ineview) {
0012   EventMsgView tmpView(ineview.startAddress());
0013   return write(tmpView);
0014 }
0015 
0016 uint64 StreamerOutputFile::write(const EventMsgView& ineview) {
0017   /** Offset where current event starts */
0018   uint64 offset_to_return = streamerfile_->current_offset();
0019 
0020   writeEventHeader(ineview);
0021   bool ret = streamerfile_->write((const char*)ineview.eventData(), ineview.size() - ineview.headerSize());
0022   if (ret) {
0023     throw cms::Exception("OutputFile", "write(EventMsgView)")
0024         << "Error writing streamer event data to " << streamerfile_->fileName() << ".  Possibly the output disk "
0025         << "is full?" << std::endl;
0026   }
0027   return offset_to_return;
0028 }
0029 
0030 uint64 StreamerOutputFile::writeEventFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize) {
0031   /** Offset where current event starts */
0032   uint64 offset_to_return = streamerfile_->current_offset();
0033 
0034   bool ret = streamerfile_->write(dataPtr, dataSize);
0035   if (ret) {
0036     throw cms::Exception("OutputFile", "writeEventFragment()")
0037         << "Error writing streamer event data to " << streamerfile_->fileName() << ".  Possibly the output disk "
0038         << "is full?" << std::endl;
0039   }
0040   return offset_to_return;
0041 }
0042 
0043 void StreamerOutputFile::writeEventHeader(const EventMsgView& ineview) {
0044   bool ret = streamerfile_->write((const char*)ineview.startAddress(), ineview.headerSize());
0045   if (ret) {
0046     throw cms::Exception("OutputFile", "writeEventHeader")
0047         << "Error writing streamer event data to " << streamerfile_->fileName() << ".  Possibly the output disk "
0048         << "is full?" << std::endl;
0049   }
0050 }
0051 
0052 void StreamerOutputFile::write(const InitMsgBuilder& inview) {
0053   InitMsgView tmpView(inview.startAddress());
0054   return write(tmpView);
0055 }
0056 
0057 void StreamerOutputFile::write(const InitMsgView& inview) {
0058   writeStart(inview);
0059   bool ret = streamerfile_->write((const char*)inview.descData(), inview.size() - inview.headerSize());
0060   if (ret) {
0061     throw cms::Exception("OutputFile", "write(InitMsgView)")
0062         << "Error writing streamer header data to " << streamerfile_->fileName() << ".  Possibly the output disk "
0063         << "is full?" << std::endl;
0064   }
0065 }
0066 
0067 void StreamerOutputFile::writeInitFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize) {
0068   bool ret = streamerfile_->write((const char*)dataPtr, dataSize);
0069   if (ret) {
0070     throw cms::Exception("OutputFile", "writeInitFragment()")
0071         << "Error writing streamer header data to " << streamerfile_->fileName() << ".  Possibly the output disk "
0072         << "is full?" << std::endl;
0073   }
0074 }
0075 
0076 void StreamerOutputFile::writeStart(const InitMsgView& inview) {
0077   bool ret = streamerfile_->write((const char*)inview.startAddress(), inview.headerSize());
0078   if (ret) {
0079     throw cms::Exception("OutputFile", "writeStart")
0080         << "Error writing streamer header data to " << streamerfile_->fileName() << ".  Possibly the output disk "
0081         << "is full?" << std::endl;
0082   }
0083 }