CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

stor::EventFileHandler Class Reference

#include <EventFileHandler.h>

Inheritance diagram for stor::EventFileHandler:
stor::FileHandler

List of all members.

Public Member Functions

virtual void closeFile (const FilesMonitorCollection::FileRecord::ClosingReason &)
 EventFileHandler (InitMsgSharedPtr, FilesMonitorCollection::FileRecordPtr, const DbFileHandlerPtr, const uint64_t &maxFileSize)

Private Member Functions

virtual void do_writeEvent (const I2OChain &)
void writeHeader (InitMsgSharedPtr)

Private Attributes

boost::scoped_ptr
< edm::StreamerFileWriter
writer_

Detailed Description

Represents a file holding event data

Author:
mommsen
Revision:
1.15
Date:
2012/04/04 12:16:56

Definition at line 29 of file EventFileHandler.h.


Constructor & Destructor Documentation

stor::EventFileHandler::EventFileHandler ( InitMsgSharedPtr  view,
FilesMonitorCollection::FileRecordPtr  fileRecord,
const DbFileHandlerPtr  dbFileHandler,
const uint64_t &  maxFileSize 
)

Definition at line 15 of file EventFileHandler.cc.

References xuti::writeHeader().

    :
  FileHandler(fileRecord, dbFileHandler, maxFileSize),
  writer_(new edm::StreamerFileWriter(fileRecord->completeFileName()))
  {
    writeHeader(view);
  }

Member Function Documentation

void stor::EventFileHandler::closeFile ( const FilesMonitorCollection::FileRecord::ClosingReason reason) [virtual]

Close the file

Implements stor::FileHandler.

Definition at line 59 of file EventFileHandler.cc.

References stor::FileHandler::fileRecord_, stor::FileHandler::moveFileToClosed(), stor::FileHandler::updateDatabase(), and writer_.

  {
    if ( ! fileRecord_->isOpen ) return;
    
    if (writer_)
    {
      // if writer was reset, we already closed the stream but failed to move the file to the closed position
      writer_->stop();
      fileRecord_->fileSize += writer_->getStreamEOFSize();
      fileRecord_->adler32 = writer_->get_adler32();
      writer_.reset(); // Destruct the writer to flush the file stream
    }
    moveFileToClosed(reason);
    updateDatabase();
  }
void stor::EventFileHandler::do_writeEvent ( const I2OChain event) [private, virtual]

Write the I2OChain to the file

Implements stor::FileHandler.

Definition at line 37 of file EventFileHandler.cc.

References stor::I2OChain::dataLocation(), edm::StreamerFileWriterEventParams::dataPtr, edm::StreamerFileWriterEventParams::dataSize, edm::StreamerFileWriterEventParams::fragmentCount, edm::StreamerFileWriterEventParams::fragmentIndex, stor::I2OChain::headerLocation(), edm::StreamerFileWriterEventParams::headerPtr, edm::StreamerFileWriterEventParams::headerSize, edm::StreamerFileWriterEventParams::hltBits, and writer_.

  {
    edm::StreamerFileWriterEventParams evtParams;
    
    event.hltTriggerBits(evtParams.hltBits);
    evtParams.headerPtr = (char*) event.headerLocation();
    evtParams.headerSize = event.headerSize();
    
    unsigned int fragCount = event.fragmentCount();
    evtParams.fragmentCount = fragCount;
    
    for (unsigned int idx = 0; idx < fragCount; ++idx)
    {
      evtParams.fragmentIndex = idx;
      evtParams.dataPtr = (char*) event.dataLocation(idx);
      evtParams.dataSize = event.dataSize(idx);
      
      writer_->doOutputEventFragment(evtParams);
    }
  }
void stor::EventFileHandler::writeHeader ( InitMsgSharedPtr  view) [private]

Write the init message to the head of the file

Definition at line 28 of file EventFileHandler.cc.

References stor::FileHandler::fileRecord_, stor::utils::getCurrentTime(), stor::FileHandler::lastEntry_, and writer_.

  {
    InitMsgView initView(&(*view)[0]);
    writer_->doOutputHeader(initView);
    fileRecord_->fileSize += view->size();
    lastEntry_ = utils::getCurrentTime();
  }

Member Data Documentation

Definition at line 58 of file EventFileHandler.h.

Referenced by closeFile(), do_writeEvent(), and writeHeader().