CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

StreamerOutputFile Class Reference

#include <StreamerOutputFile.h>

List of all members.

Public Member Functions

uint32 adler32 () const
 StreamerOutputFile (const std::string &name)
void write (const InitMsgView &)
void write (const InitMsgBuilder &)
uint64 write (const EventMsgView &)
uint64 write (const EventMsgBuilder &)
uint32 writeEOF (uint32 statusCode, const std::vector< uint32 > &hltStats)
uint64 writeEventFragment (uint32 fragIndex, uint32 fragCount, const char *dataPtr, uint32 dataSize)
void writeInitFragment (uint32 fragIndex, uint32 fragCount, const char *dataPtr, uint32 dataSize)
 ~StreamerOutputFile ()

Private Member Functions

void writeEventHeader (const EventMsgView &ineview)
void writeStart (const InitMsgView &inview)

Private Attributes

boost::shared_ptr< OutputFilestreamerfile_

Detailed Description

StreamerOutputFile: Class for doing Streamer Write operations Class for doing Streamer Write operations

Definition at line 21 of file StreamerOutputFile.h.


Constructor & Destructor Documentation

StreamerOutputFile::StreamerOutputFile ( const std::string &  name) [explicit]

Definition at line 8 of file StreamerOutputFile.cc.

References streamerfile_.

                                                             :
  streamerfile_(new OutputFile(name))
  {
    streamerfile_->set_do_adler(1);
  }
StreamerOutputFile::~StreamerOutputFile ( )

CTOR, takes file path name as argument

Definition at line 5 of file StreamerOutputFile.cc.

                                          {
  }

Member Function Documentation

uint32 StreamerOutputFile::adler32 ( ) const [inline]

Definition at line 59 of file StreamerOutputFile.h.

References streamerfile_.

{ return streamerfile_->adler32(); }
void StreamerOutputFile::write ( const InitMsgBuilder inview)

Definition at line 81 of file StreamerOutputFile.cc.

References InitMsgBuilder::startAddress().

Referenced by write().

  {
    InitMsgView tmpView(inview.startAddress());
    return write(tmpView);
  }
void StreamerOutputFile::write ( const InitMsgView inview)

Performs write on InitMsgBuilder type, Header + Blob, both are written out.

Offset of first event to be written

Definition at line 87 of file StreamerOutputFile.cc.

References InitMsgView::descData(), Exception, InitMsgView::headerSize(), run_regression::ret, InitMsgView::size(), streamerfile_, and writeStart().

  {
    writeStart(inview);
    bool ret = streamerfile_->write((const char*) inview.descData(),
                                    inview.size() - inview.headerSize());
    if (ret) {
      throw cms::Exception("OutputFile", "write(InitMsgView)")
        << "Error writing streamer header data to "
        << streamerfile_->fileName() << ".  Possibly the output disk "
        << "is full?" << std::endl;
    }

    streamerfile_->set_first_event_offset(streamerfile_->current_offset());
  }
uint64 StreamerOutputFile::write ( const EventMsgBuilder ineview)

Definition at line 14 of file StreamerOutputFile.cc.

References EventMsgBuilder::startAddress(), and write().

  {
    EventMsgView tmpView(ineview.startAddress());
    return write(tmpView);
  }
uint64 StreamerOutputFile::write ( const EventMsgView ineview)

Performs write on EventMsgBuilder type, Header + Blob, both are written out. RETURNS the Offset in Stream while at which Event was written.

Offset where current event starts

Offset of last written event

Definition at line 20 of file StreamerOutputFile.cc.

References EventMsgView::eventData(), Exception, EventMsgView::headerSize(), run_regression::ret, EventMsgView::size(), streamerfile_, and writeEventHeader().

  {
    uint64 offset_to_return = streamerfile_->current_offset();

    streamerfile_->set_last_event_offset(streamerfile_->current_offset());

    writeEventHeader(ineview);
    bool ret = streamerfile_->write((const char*) ineview.eventData(),
                                    ineview.size() - ineview.headerSize());
    if (ret) {
      throw cms::Exception("OutputFile", "write(EventMsgView)")
        << "Error writing streamer event data to "
        << streamerfile_->fileName() << ".  Possibly the output disk "
        << "is full?" << std::endl;
    }

    streamerfile_->inc_events();

    return offset_to_return;
  }
uint32 StreamerOutputFile::writeEOF ( uint32  statusCode,
const std::vector< uint32 > &  hltStats 
)

Definition at line 135 of file StreamerOutputFile.cc.

References Exception, run_regression::ret, and streamerfile_.

  {
    EOFRecordBuilder eof(streamerfile_->run(), 
                         streamerfile_->events(),
                         statusCode,
                         hltStats,
                         streamerfile_->first_event_offset(),
                         streamerfile_->last_event_offset());

    bool ret = streamerfile_->write((const char*) 
                                    eof.recAddress(), 
                                    eof.size());  
    if (ret) {
      throw cms::Exception("OutputFile", "writeEOF")
        << "Error writing streamer end-of-file to "
        << streamerfile_->fileName() << ".  Possibly the output disk "
        << "is full?" << std::endl;
    }
    return eof.size();  
  }
uint64 StreamerOutputFile::writeEventFragment ( uint32  fragIndex,
uint32  fragCount,
const char *  dataPtr,
uint32  dataSize 
)

Offset where current event starts

Offset of last written event

Definition at line 44 of file StreamerOutputFile.cc.

References Exception, run_regression::ret, and streamerfile_.

  {
    uint64 offset_to_return = streamerfile_->current_offset();

    if (fragIndex == 0) {
      streamerfile_->set_last_event_offset(streamerfile_->current_offset());
    }

    bool ret = streamerfile_->write(dataPtr, dataSize);
    if (ret) {
      throw cms::Exception("OutputFile", "writeEventFragment()")
        << "Error writing streamer event data to "
        << streamerfile_->fileName() << ".  Possibly the output disk "
        << "is full?" << std::endl;
    }

    if (fragIndex == fragCount-1) {streamerfile_->inc_events();}

    return offset_to_return;
  }
void StreamerOutputFile::writeEventHeader ( const EventMsgView ineview) [private]

Definition at line 68 of file StreamerOutputFile.cc.

References Exception, EventMsgView::headerSize(), run_regression::ret, EventMsgView::startAddress(), and streamerfile_.

Referenced by write().

  {
    bool ret = streamerfile_->write((const char*)
                                    ineview.startAddress(),
                                    ineview.headerSize()) ;
    if (ret) {
      throw cms::Exception("OutputFile", "writeEventHeader")
        << "Error writing streamer event data to "
        << streamerfile_->fileName() << ".  Possibly the output disk "
        << "is full?" << std::endl;
    }
  }
void StreamerOutputFile::writeInitFragment ( uint32  fragIndex,
uint32  fragCount,
const char *  dataPtr,
uint32  dataSize 
)

Offset of first event to be written

Definition at line 104 of file StreamerOutputFile.cc.

References Exception, run_regression::ret, and streamerfile_.

  {
    bool ret = streamerfile_->write((const char*) dataPtr, dataSize);
    if (ret) {
      throw cms::Exception("OutputFile", "writeInitFragment()")
        << "Error writing streamer header data to "
        << streamerfile_->fileName() << ".  Possibly the output disk "
        << "is full?" << std::endl;
    }

    if (fragIndex == fragCount-1) {
      streamerfile_->set_first_event_offset(streamerfile_->current_offset());
    }
  }
void StreamerOutputFile::writeStart ( const InitMsgView inview) [private]

Definition at line 121 of file StreamerOutputFile.cc.

References Exception, InitMsgView::headerSize(), run_regression::ret, InitMsgView::run(), InitMsgView::startAddress(), and streamerfile_.

Referenced by write().

  {
    bool ret = streamerfile_->write((const char*)
                                    inview.startAddress(),
                                    inview.headerSize()) ;
    if (ret) {
      throw cms::Exception("OutputFile", "writeStart")
        << "Error writing streamer header data to "
        << streamerfile_->fileName() << ".  Possibly the output disk "
        << "is full?" << std::endl;
    }
    streamerfile_->set_run(inview.run()); 
  }

Member Data Documentation

boost::shared_ptr<OutputFile> StreamerOutputFile::streamerfile_ [private]