/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
DybDaq::DaqFileWriter Class Reference

#include <DaqFileWriter.h>

Inheritance diagram for DybDaq::DaqFileWriter:
Inheritance graph
[legend]
Collaboration diagram for DybDaq::DaqFileWriter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DaqFileWriter (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~DaqFileWriter ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
DayaBay::ReadoutHeaderGetCurrentHeaderObject () const
virtual StatusCode sysInitialize ()
virtual StatusCode sysExecute ()
virtual StatusCode preExecute ()
virtual StatusCode postExecute ()
virtual StatusCode sysFinalize ()
IDataProviderSvc * arcSvc () const
void putTES (DataObject *obj, std::string location) const
TYPE * getTES (std::string location) const
TYPE * getAES (std::string location, int index) const
std::vector< DataObject * > getAEScollection (std::string location) const
int getExecNum ()
std::string Location () const

Protected Member Functions

virtual DaqToOStreamcreateDaqToOStream (const FileTraits &traits)
 Creates the DaqToOStream into which the DAQ bytes wiull be written.
virtual void wroteFileHead ()
 Called when the file header records have all been written.
virtual void wroteData ()
 Called when a file data record has all been written.
virtual void wroteFileFoot ()
 Called when the file footer records have all been written.
virtual StatusCode writeFileHead (const DayaBay::DaqCrate *daqCrate)
 Writes the file header records.
virtual StatusCode writeData (const DayaBay::DaqCrate *daqCrate)
 Writes the data block.
virtual StatusCode writeFileFoot ()
 Writes the file footer records.
DayaBay::ReadoutHeaderMakeHeaderObject ()
void InitializeHeader (DayaBay::HeaderObject *header)
TYPE * MakeHeader ()
TYPE * MakeHeader (std::vector< const DayaBay::IHeader * > &inputHeaders)
TYPE * MakeHeader (const DayaBay::IHeader *referenceHeader)
void AppendInputHeader (const DayaBay::HeaderObject *header) const

Protected Attributes

DayaBay::HeaderObjectm_headerObject
bool m_pullMode
std::string m_location

Private Attributes

std::string m_outputDir
 The directory into which to write the output files.

Detailed Description

Definition at line 22 of file DaqFileWriter.h.


Constructor & Destructor Documentation

DybDaq::DaqFileWriter::DaqFileWriter ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)
virtual DybDaq::DaqFileWriter::~DaqFileWriter ( ) [virtual]

Member Function Documentation

virtual DaqToOStream* DybDaq::DaqFileWriter::createDaqToOStream ( const FileTraits traits) [protected, virtual]

Creates the DaqToOStream into which the DAQ bytes wiull be written.

Implements DybDaq::DaqFormatWriter.

virtual void DybDaq::DaqFileWriter::wroteFileHead ( ) [protected, virtual]

Called when the file header records have all been written.

Implements DybDaq::DaqFormatWriter.

virtual void DybDaq::DaqFileWriter::wroteData ( ) [protected, virtual]

Called when a file data record has all been written.

Implements DybDaq::DaqFormatWriter.

virtual void DybDaq::DaqFileWriter::wroteFileFoot ( ) [protected, virtual]

Called when the file footer records have all been written.

Implements DybDaq::DaqFormatWriter.

StatusCode DaqFormatWriter::initialize ( ) [virtual, inherited]

Definition at line 71 of file DaqFormatWriter.cc.

                                       {
    m_traits = &(FileTraits::defaultTraits());
    StatusCode status = service("DaqReadoutSvc",
                                "DaqReadoutSvc",
                                m_daqSvc);
    if (status.isFailure() ) {
        return status;
    }
    if (0 != m_daqSvc) {
        m_daqSvc->setFirstDataBlockNumber(m_firstDataBlock);
    }
    return StatusCode::SUCCESS;
}
StatusCode DaqFormatWriter::execute ( ) [virtual, inherited]

Definition at line 85 of file DaqFormatWriter.cc.

                                    {
    const ReadoutHeader* readoutHeader = get<ReadoutHeader>("/Event/Readout/ReadoutHeader");
    if (0 == readoutHeader) {
        error() << "Failed to get readout header." << endreq;
        return StatusCode::FAILURE;
    }
    
    const DaqCrate* daqCrate = readoutHeader->daqCrate();
    if (0 == daqCrate) {
        error() << "Failed to get crate readout from header" << endreq;
        return StatusCode::FAILURE;
    }
    StatusCode status = writeFileHead(daqCrate);
    if (status.isFailure() ) {
      return status;
    }
    return writeData(daqCrate);
}
StatusCode DaqFormatWriter::finalize ( ) [virtual, inherited]

Definition at line 104 of file DaqFormatWriter.cc.

                                     {
    const StatusCode status = writeFileFoot();
    if (status.isFailure()) {
        return status;
    }
    return StatusCode::SUCCESS;
}
StatusCode DaqFormatWriter::writeFileHead ( const DayaBay::DaqCrate daqCrate) [protected, virtual, inherited]

Writes the file header records.

Definition at line 112 of file DaqFormatWriter.cc.

                                                                  {
    bool freshFile = false;
    if (0 == m_daqToOStream) {
        if (m_daqSvc->hasFileStartRecord()) {
            const FileStartRecord& record = m_daqSvc->fileStartRecord();
            m_daqToOStream = createDaqToOStream(record.fileTraits());
            if (!(m_daqToOStream->openSequence(m_outputBase,
                                               record))) {
                return StatusCode::FAILURE;
            }
        } else {
            m_daqToOStream = createDaqToOStream(*m_traits);
            const FileTraits::FileDateTime* dateTime = m_traits->makeDateTime(time(0));
            const FileStartRecord* record = m_daqToOStream->openSequence(m_outputBase,
                                                                         *dateTime,
                                                                         m_fileBlockLimit,
                                                                         (m_fileByteLimit / kBytesInMegabyte));
            delete dateTime;
            if (0 == record) {
                return StatusCode::FAILURE;
            }
            delete record;
        }
    } else {
        if (m_daqSvc->hasFileEndRecord()) {
            if (m_daqSvc->hasFileStartRecord()) {
                if (!m_daqToOStream->close(m_daqSvc->fileEndRecord())) {
                    return StatusCode::FAILURE;
                }
                wroteFileFoot();
                if (!m_daqToOStream->open(m_daqSvc->fileStartRecord())) {
                  return StatusCode::FAILURE;
                }
            } else {
                if (!(m_daqToOStream->close(m_daqSvc->fileEndRecord()))) {
                    return StatusCode::FAILURE;
                }
                wroteFileFoot();
                delete m_daqToOStream;
                m_daqToOStream = 0;
                return StatusCode::SUCCESS;
            }
        } else {
            const EventReadout& eventReadout = daqCrate->eventReadout();
            const EventHeader& eventHeader = eventReadout.header();
            ++m_fileBlockCount;
            m_fileByteCount += eventHeader.totalSize() * kBytesInInt;
            if (((0 != m_fileBlockLimit) && (0 == (m_fileBlockCount > m_fileBlockLimit))) ||
                ((0 != m_fileByteLimit) && (0 == (m_fileByteCount > m_fileByteLimit)))) {
                const FileTraits::FileDateTime* dateTime = m_traits->makeDateTime(time(0));
                const FileStartRecord* record = m_daqToOStream->openNext(*dateTime);
                delete dateTime;
                if (0 == record) {
                    return StatusCode::FAILURE;
                }
                delete record;
                m_fileBlockCount = 1;
                m_fileByteCount = eventHeader.totalSize() * kBytesInInt;
                freshFile = true;
            } else {
                return StatusCode::SUCCESS;
            }
        }
    }
    if (m_daqSvc->hasFileNameStrings()) {
        if (!(m_daqToOStream->saveFileNameStrings(m_daqSvc->fileNameStrings()))) {
            return StatusCode::FAILURE;
        }
    } else {
        const FileNameStrings* record = m_daqToOStream->saveFileNameStrings("DaqFormatWriter");
        if (0 == record) {
            return StatusCode::FAILURE;
        }
        delete record;
    }
    if (m_daqSvc->hasMetadataStrings()) {
        if (!(m_daqToOStream->saveMetadataStrings(m_daqSvc->metadataStrings()))) {
            return StatusCode::FAILURE;
        }
    } else {
        MetadataStrings::MetadataStringPtrList* metadataStrings = new MetadataStrings::MetadataStringPtrList();
        MetadataStrings::MetadataString metaString("type","MC");
        metadataStrings->push_back(&metaString);
        const MetadataStrings* record = m_daqToOStream->saveMetadataStrings(*metadataStrings);
        if (0 == record) {
            return StatusCode::FAILURE;
        }
        delete record;
    }
    if (m_daqSvc->hasRunParametersRecord()) {
        if (!(m_daqToOStream->saveRunParametersRecord(m_daqSvc->runParametersRecord()))) {
            return StatusCode::FAILURE;
        }
    } else {
        const RunParametersRecord* record = m_daqToOStream->saveRunParametersRecord(m_daqSvc->runNumber(daqCrate->detector()),
                                                                              true,
                                                                              0,
                                                                              0);
        if (0 == record) {
            return StatusCode::FAILURE;
        }
        delete record;
    }
    const int finished = m_daqSvc->calibrationParametersRecordCount();
    for (int count = 0;
         finished != count;
         ++count) {
        if (!(m_daqToOStream->saveCalibrationParametersRecord(m_daqSvc->calibrationParametersRecord(count)))) {
            return StatusCode::FAILURE;
        }
    }
    wroteFileHead();
    return StatusCode::SUCCESS;
}
StatusCode DaqFormatWriter::writeData ( const DayaBay::DaqCrate daqCrate) [protected, virtual, inherited]

Writes the data block.

Definition at line 227 of file DaqFormatWriter.cc.

                                                              {
    if (0 == m_daqToOStream) {
      return StatusCode::FAILURE;
    }
    const DataSeparatorRecord* record = m_daqToOStream->saveEvent(daqCrate->eventReadout(),
                                                                  m_daqSvc->nextDataBlockNumber());
    if (0 == record) {
        return StatusCode::FAILURE;
    }
    delete record;
    wroteData();
    return StatusCode::SUCCESS;
}
StatusCode DaqFormatWriter::writeFileFoot ( ) [protected, virtual, inherited]

Writes the file footer records.

Definition at line 241 of file DaqFormatWriter.cc.

                                          {
    if (0 == m_daqToOStream) {
        return StatusCode::SUCCESS;
    }
    if (m_daqSvc->hasFileEndRecord()) {
        if (!(m_daqToOStream->close(m_daqSvc->fileEndRecord()))) {
            return StatusCode::FAILURE;
        }
    } else {
        const FileTraits::FileDateTime* dateTime = m_traits->makeDateTime(time(0));
        const FileEndRecord* record = m_daqToOStream->close(*dateTime);
        delete dateTime;
        if (0 == record) {
            return StatusCode::FAILURE;
        }
        delete const_cast<FileEndRecord*>(record);
    }
    wroteFileFoot();
    delete m_daqToOStream;
    m_daqToOStream = 0;
    return StatusCode::SUCCESS;
}
DayaBay::ReadoutHeader * DybAlgorithm< DayaBay::ReadoutHeader >::GetCurrentHeaderObject ( ) const [inherited]
virtual StatusCode DybAlgorithm< DayaBay::ReadoutHeader >::sysInitialize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ReadoutHeader >::sysExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ReadoutHeader >::preExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ReadoutHeader >::postExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::ReadoutHeader >::sysFinalize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

IDataProviderSvc * DybAlgorithm< DayaBay::ReadoutHeader >::arcSvc ( ) const [inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::ReadoutHeader >::putTES ( DataObject *  obj,
std::string  location 
) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ReadoutHeader >::getTES ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ReadoutHeader >::getAES ( std::string  location,
int  index 
) const [inherited]

Reimplemented from DybBaseAlg.

std::vector< DataObject * > DybAlgorithm< DayaBay::ReadoutHeader >::getAEScollection ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

int DybAlgorithm< DayaBay::ReadoutHeader >::getExecNum ( ) [inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::ReadoutHeader >::Location ( ) const [inherited]

Reimplemented from DybBaseAlg.

DayaBay::ReadoutHeader * DybAlgorithm< DayaBay::ReadoutHeader >::MakeHeaderObject ( ) [protected, inherited]
void DybAlgorithm< DayaBay::ReadoutHeader >::InitializeHeader ( DayaBay::HeaderObject header) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ReadoutHeader >::MakeHeader ( ) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ReadoutHeader >::MakeHeader ( std::vector< const DayaBay::IHeader * > &  inputHeaders) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::ReadoutHeader >::MakeHeader ( const DayaBay::IHeader referenceHeader) [protected, inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::ReadoutHeader >::AppendInputHeader ( const DayaBay::HeaderObject header) const [protected, inherited]

Reimplemented from DybBaseAlg.


Member Data Documentation

std::string DybDaq::DaqFileWriter::m_outputDir [private]

The directory into which to write the output files.

Definition at line 58 of file DaqFileWriter.h.

Reimplemented from DybBaseAlg.

bool DybAlgorithm< DayaBay::ReadoutHeader >::m_pullMode [protected, inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::ReadoutHeader >::m_location [protected, inherited]

Reimplemented from DybBaseAlg.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:15:32 for DaqFormatModules by doxygen 1.7.4