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

In This Package:

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
NormCycler Class Reference

#include <NormCycler.h>

Inheritance diagram for NormCycler:
Inheritance graph
[legend]
Collaboration diagram for NormCycler:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::deque< Data * >
::iterator 
Iterator

Public Member Functions

 NormCycler (const std::string &name)
virtual ~NormCycler ()
virtual bool initialize ()
virtual bool finalize ()
virtual EvtObjectnext (int nth=1)
virtual PhyEventexpand ()
PhyEventBufdataBuffer ()
const std::string & name ()
template<typename Type >
bool setOption (const std::string &option, Type &var)
Iterator begin ()
Iterator current ()
Iterator end ()
Iterator find (const Data *data)
Iterator seek (int pos)
Data * curEvt ()
Data * seekEvt (int pos)
int totalSize ()
int forwardSize ()
int backwardSize ()
void clear ()
template<>
void clear ()
template<>
void clear ()

Protected Member Functions

virtual PhyEventtheNext ()
virtual void pushBack (PhyEvent *evt)
virtual void trimDated ()
virtual void fillFresh ()

Protected Attributes

ICyclerm_is
PhyEventm_cur
PhyEventm_theBeyond
UserBufMgrm_userBufMgr
std::vector< double > m_window
std::string m_name
unsigned int m_iCur
std::deque< Data * > m_dBuf

Detailed Description

Definition at line 11 of file NormCycler.h.


Member Typedef Documentation

template<typename Data >
typedef std::deque<Data*>::iterator DataBuffer< Data >::Iterator [inherited]

Definition at line 12 of file DataBuffer.h.


Constructor & Destructor Documentation

NormCycler::NormCycler ( const std::string &  name)

Definition at line 5 of file NormCycler.cc.

    : SvcBase(name),
      m_cur(0),
      m_theBeyond(0),
      m_userBufMgr(0)
{
    if ( m_name == "Cycler" ) {
        m_userBufMgr = UserBufMgr::instance();
    }

    m_name = "NormCycler";  //to avoid naming confusion
}
NormCycler::~NormCycler ( ) [virtual]

Definition at line 18 of file NormCycler.cc.


Member Function Documentation

bool NormCycler::initialize ( ) [virtual]

Implements SvcBase.

Definition at line 23 of file NormCycler.cc.

{
    setOption("TimeWindow", m_window);
    if ( m_window.size() != 2 ) {
        m_window.clear();
        m_window.push_back(-0.001);
        m_window.push_back(0.001);
    }
    LogDebug << "Window (" << m_window[0] << ", " << m_window[1] << ")" << std::endl;

    m_is = SvcMgr::get<ICycler>("InputSvc");
    if ( m_is == 0 ) {  // some tricks to make it work with [InputSvc = "NONE"]
        m_iCur = 0;
        m_window[0] = 0.0;
        m_window[1] = 0.0;
    }

    return true;
}
bool NormCycler::finalize ( ) [virtual]

Implements SvcBase.

Definition at line 43 of file NormCycler.cc.

{
    if ( m_theBeyond != 0 ) {
        m_theBeyond->ReleaseInstance();
        m_theBeyond = 0;
    }
    LogDebug << " @ finalize" << std::endl;
    return true;
}
EvtObject * NormCycler::next ( int  nth = 1) [virtual]

Implements ICycler.

Definition at line 53 of file NormCycler.cc.

{
    if ( m_is != 0 ) m_iCur += nth;
    while ( m_dBuf.size() <= m_iCur ) {
        pushBack( theNext() );
        if ( m_theBeyond == 0 ) break;
    }

    if ( m_iCur < m_dBuf.size() ) {
        m_cur = m_dBuf[m_iCur];
        trimDated();
        fillFresh();
    }
    else {
        m_cur = 0;
    }

    if ( m_userBufMgr != 0 && m_cur != 0 ) {
        m_userBufMgr->synchronize(this);
    }

    return m_cur;
}
PhyEvent * NormCycler::expand ( ) [virtual]

Definition at line 77 of file NormCycler.cc.

{
    PhyEvent* _last = m_theBeyond;
    pushBack( theNext() );
    return _last;
}
PhyEventBuf * NormCycler::dataBuffer ( )

Definition at line 84 of file NormCycler.cc.

{
    return dynamic_cast<PhyEventBuf*>(this);
}
PhyEvent * NormCycler::theNext ( ) [protected, virtual]

Definition at line 89 of file NormCycler.cc.

{
    if ( m_is != 0 ) {
        return (PhyEvent*)(m_is->next());
    }
    static PhyEvent* pevt = new PhyEvent;
    return pevt;
}
void NormCycler::pushBack ( PhyEvent evt) [protected, virtual]

Definition at line 98 of file NormCycler.cc.

{
    if ( m_theBeyond != 0 ) {
        m_dBuf.push_back(m_theBeyond);
        if ( m_userBufMgr != 0 ) {
            m_userBufMgr->tryPushBack(m_theBeyond);
        }
    }

    m_theBeyond = (evt!=0) ? evt->GrabInstance() : 0;
}
void NormCycler::trimDated ( ) [protected, virtual]

Definition at line 110 of file NormCycler.cc.

{
    //remove events that out-of-date
    PhyEvent* firstEvt = m_dBuf[0];
    while ( firstEvt != m_cur ) {
        if ( (firstEvt->m_trigTime - m_cur->m_trigTime) > m_window[0] ) {
            break;
        }
        m_dBuf[0] = 0;
        m_dBuf.pop_front();
        firstEvt->ReleaseInstance();  //delete firstEvt;
        firstEvt = m_dBuf[0];
        --m_iCur;
    }
}
void NormCycler::fillFresh ( ) [protected, virtual]

Definition at line 126 of file NormCycler.cc.

{
    //fill fresh events to the buffer;
    while ( m_theBeyond != 0 && (m_theBeyond->m_trigTime - m_cur->m_trigTime) < m_window[1] ) {
        pushBack( theNext() );
    }
}
const std::string& SvcBase::name ( void  ) [inline, inherited]

Definition at line 15 of file SvcBase.h.

{ return m_name; }
template<typename Type >
bool SvcBase::setOption ( const std::string &  option,
Type &  var 
) [inherited]

Definition at line 34 of file SvcBase.h.

{
    return OptionParser::setOption(m_name, option, var);
}
template<typename Data >
DataBuffer< Data >::Iterator DataBuffer< Data >::begin ( ) [inline, inherited]

Definition at line 60 of file DataBuffer.h.

{
    return m_dBuf.begin();
}
template<typename Data >
DataBuffer< Data >::Iterator DataBuffer< Data >::current ( ) [inline, inherited]

Definition at line 66 of file DataBuffer.h.

{
    return (m_dBuf.begin()+m_iCur);
}
template<typename Data >
DataBuffer< Data >::Iterator DataBuffer< Data >::end ( ) [inline, inherited]

Definition at line 72 of file DataBuffer.h.

{
    return m_dBuf.end();
}
template<typename Data >
DataBuffer< Data >::Iterator DataBuffer< Data >::find ( const Data *  data) [inline, inherited]

Definition at line 78 of file DataBuffer.h.

{
    return std::find(m_dBuf.begin(), m_dBuf.end(), data);
}
template<typename Data >
DataBuffer< Data >::Iterator DataBuffer< Data >::seek ( int  pos) [inline, inherited]

Definition at line 84 of file DataBuffer.h.

{
    return (m_dBuf.begin()+(int(m_iCur)+pos));
}
template<typename Data >
Data * DataBuffer< Data >::curEvt ( ) [inline, inherited]

Definition at line 90 of file DataBuffer.h.

{
    if ( !m_dBuf.empty() ) {
        return m_dBuf[m_iCur];
    }
    return (Data*)0;
}
template<typename Data >
Data * DataBuffer< Data >::seekEvt ( int  pos) [inline, inherited]

Definition at line 99 of file DataBuffer.h.

{
    return m_dBuf.at(m_iCur+pos);
}
template<typename Data >
int DataBuffer< Data >::totalSize ( ) [inline, inherited]

Definition at line 105 of file DataBuffer.h.

{
    return m_dBuf.size();
}
template<typename Data >
int DataBuffer< Data >::forwardSize ( ) [inline, inherited]

Definition at line 111 of file DataBuffer.h.

{
    return (m_dBuf.size()-m_iCur-1);
}
template<typename Data >
int DataBuffer< Data >::backwardSize ( ) [inline, inherited]

Definition at line 117 of file DataBuffer.h.

{
    return m_iCur;
}
template<typename Data >
void DataBuffer< Data >::clear ( void  ) [inherited]

Definition at line 123 of file DataBuffer.h.

{
    for(typename std::deque<Data*>::iterator it=m_dBuf.begin(); it!=m_dBuf.end(); ++it) {
        delete (*it);
    }
    m_dBuf.clear();
}
template<>
void DataBuffer< PhyEvent >::clear ( void  ) [inherited]

Definition at line 8 of file PhyEventBuffer.cc.

{
    for(std::deque<PhyEvent*>::iterator it=m_dBuf.begin(); it!=m_dBuf.end(); ++it) {
        (*it)->ReleaseInstance();
    }
    m_dBuf.clear();
}
template<>
void DataBuffer< PhyEvent >::clear ( ) [inherited]

Member Data Documentation

ICycler* NormCycler::m_is [protected]

Definition at line 38 of file NormCycler.h.

Definition at line 39 of file NormCycler.h.

Definition at line 40 of file NormCycler.h.

Definition at line 42 of file NormCycler.h.

std::vector<double> NormCycler::m_window [protected]

Definition at line 44 of file NormCycler.h.

std::string SvcBase::m_name [protected, inherited]

Definition at line 25 of file SvcBase.h.

template<typename Data >
unsigned int DataBuffer< Data >::m_iCur [protected, inherited]

Definition at line 37 of file DataBuffer.h.

template<typename Data >
std::deque<Data*> DataBuffer< Data >::m_dBuf [protected, inherited]

Definition at line 38 of file DataBuffer.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:50:18 for LafKernel by doxygen 1.7.4