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

#include <RawRecordPool.h>

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

List of all members.

Public Member Functions

 RawRecordPool (std::vector< std::string >::const_iterator &begin, std::vector< std::string >::const_iterator &end)
virtual ~RawRecordPool ()
RecordBuffernext ()
void setRepackRpc (bool repackRpc)
void setTimeAlignment (bool timeAlignment)

Private Member Functions

RecordBuffernextRecord ()
RecordBuffernextOnlyRpc ()
RecordBuffernextPmtRpc ()
 RawRecordPool ()

Private Attributes

RecordBuffer *(RawRecordPool::* selector )()
std::vector< std::string >
::const_iterator & 
m_nextFile
std::vector< std::string >
::const_iterator & 
m_endFile
bool m_repackRpc
bool m_timeAlignment
RecordFromFStreamm_rfs
bool m_fsEnd
RecordParserm_parser
EventBuilder ** m_evtPools

Detailed Description

Definition at line 17 of file RawRecordPool.h.


Constructor & Destructor Documentation

RawRecordPool::RawRecordPool ( std::vector< std::string >::const_iterator &  begin,
std::vector< std::string >::const_iterator &  end 
)

Definition at line 16 of file RawRecordPool.cc.

    : m_nextFile(begin),
      m_endFile(end),
      m_repackRpc(true),
      m_timeAlignment(true),
      m_rfs(0),
      m_fsEnd(false),
      m_parser(0),
      m_evtPools(0)
{
    m_rfs = new RecordFromFStream();
    m_parser = new RecordParser();

    m_rfs->open(*m_nextFile);
}
RawRecordPool::~RawRecordPool ( ) [virtual]

Definition at line 33 of file RawRecordPool.cc.

{
    delete m_rfs;
    delete m_parser;

    for ( int i = 0; i < 7; ++i ) {
        if ( m_evtPools[i] != 0 ) delete m_evtPools[i];
    }
    delete [] m_evtPools;
}
DybDaq::RawRecordPool::RawRecordPool ( ) [private]

Member Function Documentation

RecordBuffer * RawRecordPool::next ( )

Definition at line 44 of file RawRecordPool.cc.

{
    RecordBuffer* result = 0;

    if ( m_parser->ready() ) {
        result = (this->*selector)();
    }
    else {
        result = nextRecord();
        if ( m_parser->getRunParams( result, m_timeAlignment ) ) {
            if ( m_parser->mask() == 0 ) {
                selector = &RawRecordPool::nextRecord;
            }
            else if ( m_parser->onlyRpc() ) {
                selector = &RawRecordPool::nextOnlyRpc;
            }
            else if ( m_parser->nPmtDet() < 2 ) {
                selector = &RawRecordPool::nextRecord;
            }
            else {
                selector = &RawRecordPool::nextPmtRpc;
            }

            m_evtPools = new EventBuilder*[7];
            uint32_t mask = m_parser->mask();
            for ( int i = 1; i < 7; ++i ) {
                m_evtPools[i-1] = ((mask&(1<<i)) != 0) ? (new EventBuilder()) : 0;
            }
            if ( m_parser->hasRpc() ) {
                if ( m_repackRpc ) {
                    m_evtPools[6] = new RpcEventBuilder(m_parser);
                }
                else {
                    m_evtPools[6] = new EventBuilder();
                }
            }
            else {
                m_evtPools[6] = 0;
            }
        }
    }

    return result;
}
void DybDaq::RawRecordPool::setRepackRpc ( bool  repackRpc) [inline]

Definition at line 28 of file RawRecordPool.h.

{ m_repackRpc = repackRpc; }
void DybDaq::RawRecordPool::setTimeAlignment ( bool  timeAlignment) [inline]

Definition at line 29 of file RawRecordPool.h.

{ m_timeAlignment = timeAlignment; }
RecordBuffer * RawRecordPool::nextRecord ( ) [private]

Definition at line 89 of file RawRecordPool.cc.

{
    RecordBuffer* result = m_rfs->next();
    while ( result == 0 && !m_fsEnd ) {
        if ( ++m_nextFile == m_endFile ) {
            m_fsEnd = true;
            if ( m_evtPools[6] != 0 ) {
                RpcEventBuilder* pool = dynamic_cast<RpcEventBuilder*>(m_evtPools[6]);
                if ( pool != 0 ) pool->purge();
            }
            break;
        }
        if ( m_rfs->open(*m_nextFile) ) {
            result = m_rfs->next();
        }
    }

    return result;
}
RecordBuffer * RawRecordPool::nextOnlyRpc ( ) [private]

Definition at line 109 of file RawRecordPool.cc.

{
    while ( m_evtPools[6]->empty() ) {
        RecordBuffer* record = nextRecord();
        if ( record == 0 ) break;
        if ( m_parser->isRpcEvent( record ) ) {
            m_evtPools[6]->add( record );
        }
        else {
            return record;
        }
    }
    return m_evtPools[6]->pop_front();
}
RecordBuffer * RawRecordPool::nextPmtRpc ( ) [private]

Definition at line 124 of file RawRecordPool.cc.

{
    int earliest = -1;
    for ( int i = 0; i < 7; ++i ) {
        if ( m_evtPools[i] != 0 ) {
            while ( m_evtPools[i]->empty() ) {
                RecordBuffer* result = nextRecord();
                if ( result == 0 ) break;
                int type = m_parser->recordType( result );
                if ( type != 0 ) {
                    m_evtPools[type-1]->add( result );
                    if ( m_evtPools[type-1]->size() > 10000 ) break;
                }
                else {  //not a DAQ event
                    return result;
                }
            }
            RecordBuffer* old = (earliest >= 0) ? m_evtPools[earliest]->front() : 0;
            if ( m_parser->earlier(m_evtPools[i]->front(), old) ) {
                earliest = i;
            }
        }
    }

    return m_evtPools[earliest]->pop_front();
}

Member Data Documentation

RecordBuffer*(RawRecordPool::* DybDaq::RawRecordPool::selector)() [private]

Definition at line 41 of file RawRecordPool.h.

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

Definition at line 46 of file RawRecordPool.h.

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

Definition at line 47 of file RawRecordPool.h.

Definition at line 49 of file RawRecordPool.h.

Definition at line 50 of file RawRecordPool.h.

Definition at line 53 of file RawRecordPool.h.

Definition at line 55 of file RawRecordPool.h.

Definition at line 58 of file RawRecordPool.h.

Definition at line 61 of file RawRecordPool.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 09:52:46 for RawRecordPool by doxygen 1.7.4