/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 | Private Member Functions | Private Attributes | Friends
DybDaq::DaqFormatContext Class Reference

#include <DaqFormatContext.h>

Collaboration diagram for DybDaq::DaqFormatContext:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~DaqFormatContext ()
 Destroys the instance of this class.
virtual void * identifier () const
const DybDaq::EventReadoutevent () const
 Returns the current event.

Protected Member Functions

 DaqFormatContext (const std::vector< std::string > &inputFiles, IMessageSvc &msgSvc, IDaqReadoutSvc &daqSvc)
 Suppress default.
StatusCode jump (int distance)
 Changes this object to point to a new event.
StatusCode isGoodEvent () const
 Returns true if the current event is good.

Private Member Functions

 DaqFormatContext ()
 Suppress default.
 DaqFormatContext (const DaqFormatContext &rhs)
 Suppress default.
DaqFormatContextoperator= (const DaqFormatContext &rhs)
 Suppress default.
StatusCode moveToNextEvent ()
 Moves this object to point to the next event.
DybDaq::DaqFromStreamopenNextFile ()
 Opens the next file in the list for reading.

Private Attributes

IMessageSvc & m_messageSvc
 MessageSvc reference.
DaqReadoutSvcm_daqSvc
 The service managing DAQ formatted file data.
bool m_expiredEndRecord
 True if at least one event has been read after the file_end_record.
DybDaq::DaqFromStreamm_reader
 The DaqFromStream currently being used to read the DAQ data.
const DybDaq::EventReadoutm_event
 The current event this object is pointing to.
std::vector< std::string >
::const_iterator 
m_nextFile
 The iterator pointing to the next DAQ file name to be read.
std::vector< std::string >
::const_iterator 
m_endFile
 The iterator pointing to one-past-the-end of DAQ file name list.
bool m_warnedAboutSkip
 True when the skip warning has been logged.

Friends

class DaqFormatSelector

Detailed Description

Definition at line 30 of file DaqFormatContext.h.


Constructor & Destructor Documentation

DaqFormatContext::~DaqFormatContext ( ) [virtual]

Destroys the instance of this class.

Definition at line 52 of file DaqFormatContext.cc.

                                    {
    if ( m_reader != 0 ) delete m_reader;
}
DaqFormatContext::DaqFormatContext ( const std::vector< std::string > &  inputFiles,
IMessageSvc &  msgSvc,
IDaqReadoutSvc daqSvc 
) [protected]

Suppress default.

Definition at line 39 of file DaqFormatContext.cc.

                                                           :
m_messageSvc(msgSvc),
m_daqSvc(dynamic_cast<DaqReadoutSvc*>(&daqSvc)),
m_expiredEndRecord(true),
m_reader(0),
m_event(0),
m_nextFile(inputFiles.begin()),
m_endFile(inputFiles.end()),
m_warnedAboutSkip(false) {
}
DybDaq::DaqFormatContext::DaqFormatContext ( ) [private]

Suppress default.

DybDaq::DaqFormatContext::DaqFormatContext ( const DaqFormatContext rhs) [private]

Suppress default.


Member Function Documentation

void * DaqFormatContext::identifier ( ) const [virtual]

Definition at line 56 of file DaqFormatContext.cc.

                                         {
    return 0;
}
const EventReadout * DaqFormatContext::event ( ) const

Returns the current event.

Definition at line 60 of file DaqFormatContext.cc.

                                                  {
    return m_event;
}
StatusCode DaqFormatContext::jump ( int  distance) [protected]

Changes this object to point to a new event.

Definition at line 64 of file DaqFormatContext.cc.

                                                    {
    if (0 > distance) {
        MsgStream log(&m_messageSvc,
                       "DaqFormatContext");
        log << MSG::ERROR << "Can not move backward in a file" << endreq;
        return StatusCode::FAILURE;
    }
    for (int count = 0;
         distance != count;
         ++count) {
        StatusCode status = moveToNextEvent();
        if (status.isFailure()) {
            return status;
        }
    }

    const unsigned int actionOnInvalid = m_daqSvc->actionOnInvalid();
    if ((IDaqReadoutSvc::kProcessInvalid != actionOnInvalid) && (m_event->header().invalidData())) {
        MsgStream log(&m_messageSvc,
                      "DaqFormatContext");
        if (IDaqReadoutSvc::kExitOnInvalid == actionOnInvalid) {
            delete m_event;
            m_event = 0;
            log << MSG::ERROR << "Exiting as Invalid Event has been detected" << endreq;
            return StatusCode::FAILURE;
        }
        if (IDaqReadoutSvc::kSkipInvalid == actionOnInvalid) {
            if (!m_warnedAboutSkip) {
                log << MSG::WARNING << "One or more Invalid Event has been detected, they will be skipped" << endreq;
                m_warnedAboutSkip = true;
            }
            do {
                delete m_event;
                StatusCode status = moveToNextEvent();
                if (status.isFailure()) {
                    return status;
                }
            } while (m_event->header().invalidData());
        }
    }

    const unsigned int actionOnRawRpc = m_daqSvc->actionOnRawRpc();
    if ((IDaqReadoutSvc::kProcessRawRpc != actionOnRawRpc) && (m_event->containsRpcFragments())) {
        do {
            delete m_event;
            StatusCode status = moveToNextEvent();
            if (status.isFailure()) {
                return status;
            }
        } while (m_event->containsRpcFragments());
    }
    
    return StatusCode::SUCCESS;
}
StatusCode DaqFormatContext::isGoodEvent ( ) const [protected]

Returns true if the current event is good.

Definition at line 119 of file DaqFormatContext.cc.

                                               {
    if (0 == m_event) {
        return StatusCode::FAILURE;
    }
    return StatusCode::SUCCESS;
}
DaqFormatContext& DybDaq::DaqFormatContext::operator= ( const DaqFormatContext rhs) [private]

Suppress default.

StatusCode DaqFormatContext::moveToNextEvent ( ) [private]

Moves this object to point to the next event.

Definition at line 126 of file DaqFormatContext.cc.

                                             {
    m_event = 0;
    while (0 == m_event) {
        if(0 == m_reader){
            m_reader = openNextFile();
            if(0 == m_reader){
                return StatusCode::FAILURE;
            }
        }
        
        const FileBuffer* record = m_reader->nextRecord();
        if(0 == record){
            if ( m_daqSvc->repackRpcEvent() || m_daqSvc->timeAlignment() ) {
                delete m_reader;
                m_reader = 0;
                continue;
            }
            MsgStream log(&m_messageSvc,
                          "DaqFormatContext");
            log << MSG::ERROR << "Failed to read next record from file: " << (*m_nextFile) << endreq;
            return StatusCode::FAILURE;
        }
        
        // Check the record type

        if (m_expiredEndRecord && (0 != m_daqSvc)) {
            m_daqSvc->setFileRecord((const FileEndRecord*)0);
        }
        if(record->isMarked(FileTraits::kDataSeparatorRecord)) {
            const DataSeparatorRecord* dataSeparator = dynamic_cast<const DataSeparatorRecord*>(record);
            if (0 != m_daqSvc) {
                m_daqSvc->setNextDataBlockNumber(dataSeparator->blockNumber());
            }
            m_event = dataSeparator->extractBlock();
            delete record;
            m_expiredEndRecord = true;
        } else {
            if (0 != m_daqSvc) {
                m_daqSvc->setFileRecord(record);
            }
            if(record->isMarked(FileTraits::kFileEndRecord)) {
                m_expiredEndRecord = false;
            }
            std::stringstream message;
            message << '\n';
            DaqXmlStream xmlStream(message,
                                   kTwoSpaces,
                                   true);
            xmlStream.dumpElement(*record);
            MsgStream log(&m_messageSvc,
                          "DaqFormatContext");
            log << MSG::INFO << message.str() << endreq;        
            if(record->isMarked(FileTraits::kFileEndRecord)) {
                if( !(m_daqSvc->repackRpcEvent() || m_daqSvc->timeAlignment()) ){
                    delete m_reader;
                    m_reader = 0;
                    ++m_nextFile;
                }
            }
        }
    }
    return StatusCode::SUCCESS;
}
DybDaq::DaqFromStream * DaqFormatContext::openNextFile ( ) [private]

Opens the next file in the list for reading.

Definition at line 190 of file DaqFormatContext.cc.

                                                    {
    DaqFromStream* result = 0;
    
    if (m_nextFile == m_endFile) {
        MsgStream log(&m_messageSvc,
                      "DaqFormatContext");
        log << MSG::INFO << "End of input file list" << endreq;
        return result;
    }

    if ( m_daqSvc->repackRpcEvent() || m_daqSvc->timeAlignment() ) {
        DaqFromRecordPool* pool = new DaqFromRecordPool(m_nextFile, m_endFile);
        result = pool;
        if ( 0 == result ) {
            MsgStream log(&m_messageSvc, "DaqFormatContext");
            log << MSG::ERROR << "Failed to create DaqFromRecordPool!" << endreq;
        }
        pool->setRepackRpc( m_daqSvc->repackRpcEvent() );
        pool->setTimeAlignment( m_daqSvc->timeAlignment() );
    }
    else {
        result = new DaqFromFStream();
        if(0 != result){
            const bool opened = (dynamic_cast<DaqFromFStream*>(result))->openFile((*m_nextFile).c_str());
            if (!opened) {
                MsgStream log(&m_messageSvc,
                        "DaqFormatContext");
                log << MSG::ERROR << "Failed to open input file: " << (*m_nextFile) << endreq;
                delete result;
                result = 0;
            }
        }
        else {
            MsgStream log(&m_messageSvc,
                  "DaqFormatContext");
            log << MSG::ERROR << "Failed to create new file reader" << endreq;
        }
    }

    return result;
}

Friends And Related Function Documentation

friend class DaqFormatSelector [friend]

Definition at line 34 of file DaqFormatContext.h.


Member Data Documentation

MessageSvc reference.

Definition at line 97 of file DaqFormatContext.h.

The service managing DAQ formatted file data.

Definition at line 102 of file DaqFormatContext.h.

True if at least one event has been read after the file_end_record.

Definition at line 107 of file DaqFormatContext.h.

The DaqFromStream currently being used to read the DAQ data.

Definition at line 112 of file DaqFormatContext.h.

The current event this object is pointing to.

Definition at line 117 of file DaqFormatContext.h.

std::vector<std::string>::const_iterator DybDaq::DaqFormatContext::m_nextFile [private]

The iterator pointing to the next DAQ file name to be read.

Definition at line 122 of file DaqFormatContext.h.

std::vector<std::string>::const_iterator DybDaq::DaqFormatContext::m_endFile [private]

The iterator pointing to one-past-the-end of DAQ file name list.

Definition at line 127 of file DaqFormatContext.h.

True when the skip warning has been logged.

Definition at line 132 of file DaqFormatContext.h.


The documentation for this class was generated from the following files:
| 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