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

In This Package:

Classes | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
DybDaq::RpcEventBuilder Class Reference

#include <RpcEventBuilder.h>

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

List of all members.

Classes

class  ElementList

Public Member Functions

 RpcEventBuilder (RecordParser *parser)
virtual ~RpcEventBuilder ()
int size ()
bool empty ()
int add (RecordBuffer *record)
RecordBufferfront ()
RecordBufferpop_front ()
void purge ()

Protected Attributes

int m_size
std::list< RecordBuffer * > m_records

Private Member Functions

void tryPack (bool forced=false)
 RpcEventBuilder ()

Private Attributes

ElementList ** m_rtm
ElementList *** m_fec
int m_totRtm
int m_totFec
bool m_fresh
RecordParserm_parser
PackedRpcEventm_target

Detailed Description

Definition at line 34 of file RpcEventBuilder.h.


Constructor & Destructor Documentation

RpcEventBuilder::RpcEventBuilder ( RecordParser parser)

Definition at line 144 of file RpcEventBuilder.cc.

    : m_totRtm(0),
      m_totFec(0),
      m_fresh(true),
      m_parser(parser)
{
    int nRtmCF = parser->farSite() ? 3 : 2;
    int nFecCF = 2*nRtmCF;

    m_rtm = new ElementList*[nRtmCF];
    for ( int i = 0; i < nRtmCF; ++i ) {
        m_rtm[i] = new ElementList(RTM_DATA_SIZE);
    }

    m_fec = new ElementList**[nFecCF];
    for ( int i = 0; i < nFecCF; ++i ) {
        int nFec = 15;  //for the telescope ((i%2) == 0 ) ? 15 : 12;
        m_fec[i] = new ElementList*[nFec];
        for ( int j = 0; j < nFec; ++j ) {
            m_fec[i][j] = new ElementList(FEC_DATA_SIZE);
        }
    }

    m_target = new PackedRpcEvent(m_parser->farSite());
}
RpcEventBuilder::~RpcEventBuilder ( ) [virtual]

Definition at line 170 of file RpcEventBuilder.cc.

{
    int nRtmCF = m_parser->farSite() ? 3 : 2;
    int nFecCF = 2*nRtmCF;

    for ( int i = 0; i < nRtmCF; ++i ) {
        delete m_rtm[i];
    }
    delete [] m_rtm;

    for ( int i = 0; i < nFecCF; ++i ) {
        int nFec = 15;  //for the telescope ((i%2) == 0 ) ? 15 : 12;
        for ( int j = 0; j < nFec; ++j ) {
            delete m_fec[i][j];
        }
        delete [] m_fec[i];
    }
    delete [] m_fec;

    if ( m_target != 0 ) delete m_target;
}
DybDaq::RpcEventBuilder::RpcEventBuilder ( ) [private]

Member Function Documentation

int RpcEventBuilder::size ( ) [virtual]

Reimplemented from DybDaq::EventBuilder.

Definition at line 192 of file RpcEventBuilder.cc.

{
    return m_size;
}
bool RpcEventBuilder::empty ( ) [virtual]

Reimplemented from DybDaq::EventBuilder.

Definition at line 197 of file RpcEventBuilder.cc.

{
    return (m_size == 0);
}
int RpcEventBuilder::add ( RecordBuffer record) [virtual]

Reimplemented from DybDaq::EventBuilder.

Definition at line 202 of file RpcEventBuilder.cc.

{
    const uint32_t* pevt = (const uint32_t*)(record->data()+16);

    m_target->initHeader(pevt);

    DaqRawEvent event(pevt);
    DaqRomData* rom = event.next_rom();
    while ( rom != 0 ) {
        if ( rom->is_fec() ) {  //FEC data
            const uint32_t* fec = rom->next_fec();
            while ( fec != 0 ) {
                int _CfId  = (fec[0]>>12)&0xF;
                int _FecId = (fec[0]>>8)&0xF;
                m_fec[_CfId][_FecId]->push_back(fec);
                ++m_totFec;
                fec = rom->next_fec();
            }
        }
        else if ( rom->is_rtm() ) {  //RTM data
            const uint32_t* rtm = rom->next_rtm();
            while ( rtm != 0 ) {
                int _CfId  = (rtm[0]>>12)&0xF;
                m_rtm[_CfId]->push_back(rtm);
                ++m_totRtm;
                m_target->updateAccumulation(rtm);
                rtm = rom->next_rtm();
            }
        }
        else {
            std::cerr << "RpcEventBuilder: bad RPC block!" << std::endl;
        }
        delete rom;
        rom = event.next_rom();
    }

    m_fresh = true;
    delete [] record->data();
    delete record;

    //std::cout << "zdebug: Rtm " << m_totRtm << "   Fec " << m_totFec << std::endl;

    bool forced = ( m_totFec < 10000 ) ? false : true;
    tryPack(forced);

    return m_size;
}
RecordBuffer * RpcEventBuilder::front ( ) [virtual]

Reimplemented from DybDaq::EventBuilder.

Definition at line 250 of file RpcEventBuilder.cc.

{
    RecordBuffer* result = 0;
    if ( m_size > 0 ) {
        result = m_records.front();
    }
    return result;
}
RecordBuffer * RpcEventBuilder::pop_front ( ) [virtual]

Reimplemented from DybDaq::EventBuilder.

Definition at line 259 of file RpcEventBuilder.cc.

{
    RecordBuffer* result = 0;
    if ( m_size > 0 ) {
        result = m_records.front();
        m_records.pop_front();
        --m_size;
    }
    return result;
}
void RpcEventBuilder::purge ( )

Definition at line 336 of file RpcEventBuilder.cc.

{
    m_fresh = true;
    tryPack(true);
    m_fresh = false;
}
void RpcEventBuilder::tryPack ( bool  forced = false) [private]

Definition at line 270 of file RpcEventBuilder.cc.

{
    while ( m_fresh && m_totRtm > 0 ) {

        // packing a event
        int _RtmCfId = m_target->rtmNeeded();
        while ( _RtmCfId >= 0 ) {
            if ( ! m_rtm[_RtmCfId]->empty() ) {
                if ( m_target->addRtmData(m_rtm[_RtmCfId]->front()) <= 0 ) {
                    m_rtm[_RtmCfId]->pop_front();
                    --m_totRtm;
                }
            }
            else if ( !forced ) {
                m_fresh = false;
                return;
            }
            else {
                m_target->setNextRtm();
            }
            _RtmCfId = m_target->rtmNeeded();
            if ( _RtmCfId < 0 ) m_target->makeFecList();
        }

        int _FecId = m_target->fecNeeded();
        while ( _FecId >= 0 ) {
            int _iRtm = (_FecId >> 8);
            int _FecCfId = (_FecId >> 4) & 0xF;
            _FecId &= 0xF;
            if ( ! m_fec[_FecCfId][_FecId]->empty() ) {
                int status = m_target->addFecData(m_fec[_FecCfId][_FecId]->front(), _iRtm, forced);
                if ( m_target->accumulationValid() || forced ) {
                    if ( status <= 0 ) {
                        m_fec[_FecCfId][_FecId]->pop_front();
                        --m_totFec;
                    }
                    else {  //try to share FecData with the previous event
                        m_target->tryPreFecData(m_fec[_FecCfId][_FecId]->pre_front(), _iRtm);
                    }
                }
                else {
                    m_fresh = false;
                    return;
                }
            }
            else if ( !forced ) {
                m_fresh = false;
                return;
            }
            else {
                m_target->setNextFec();
                m_target->tryPreFecData(m_fec[_FecCfId][_FecId]->pre_front(), _iRtm);
            }
            _FecId = m_target->fecNeeded();
        }

        m_target->pack();
        int   recordSize = m_target->recordSize();
        char* recordData = new char[recordSize];
        memcpy(recordData, m_target->recordData(), recordSize);
        m_records.push_back(new RecordBuffer(recordData, recordSize));
        ++m_size;
        m_target->reset();
    }
}

Member Data Documentation

Definition at line 79 of file RpcEventBuilder.h.

Definition at line 80 of file RpcEventBuilder.h.

Definition at line 82 of file RpcEventBuilder.h.

Definition at line 83 of file RpcEventBuilder.h.

Definition at line 85 of file RpcEventBuilder.h.

Definition at line 86 of file RpcEventBuilder.h.

Definition at line 87 of file RpcEventBuilder.h.

int DybDaq::EventBuilder::m_size [protected, inherited]

Definition at line 30 of file RpcEventBuilder.h.

std::list<RecordBuffer*> DybDaq::EventBuilder::m_records [protected, inherited]

Definition at line 31 of file RpcEventBuilder.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