/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 Attributes | Private Attributes
TimeAlignedInputSvc Class Reference

#include <TimeAlignedInputSvc.h>

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

List of all members.

Public Member Functions

 TimeAlignedInputSvc (const std::string &name)
virtual ~TimeAlignedInputSvc ()
virtual bool initialize ()
virtual bool finalize ()
virtual EvtObjectnext (int nth=1)
const std::string & name ()
bool setOption (const std::string &option, Type &var)

Protected Attributes

std::string m_name

Private Attributes

ICyclerm_is
int m_dt [7]
double m_window
std::list< PhyEvent * > m_evts

Detailed Description

Definition at line 10 of file TimeAlignedInputSvc.h.


Constructor & Destructor Documentation

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

Definition at line 12 of file TimeAlignedInputSvc.cc.

    : SvcBase(name),
      m_is(0),
      m_window(0)
{
    m_name = "TimeAlignedInputSvc";
}
TimeAlignedInputSvc::~TimeAlignedInputSvc ( ) [virtual]

Definition at line 20 of file TimeAlignedInputSvc.cc.

{
}

Member Function Documentation

bool TimeAlignedInputSvc::initialize ( ) [virtual]

Implements SvcBase.

Definition at line 24 of file TimeAlignedInputSvc.cc.

{
    m_is = SvcMgr::get<ICycler>("ReconInputSvc");

    int run = 0, _run = -1;
    setOption("RunNumber", run);

    if ( run != 0 ) {
        std::string tfile;
        setOption("TimeShiftFromFile", tfile);

        std::ifstream ifs(tfile.c_str());
        ifs.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        while ( ifs.good() ) {
            ifs >> _run;
            if ( _run == run ) {
                for ( int i = 0; i < 7; ++i ) {
                    ifs >> m_dt[i];
                    LogDebug << "Det[" << i+1 << "] time shift: " << m_dt[i] << std::endl;
                    if ( abs(m_dt[i])*2 > m_window ) m_window = abs(m_dt[i])*2;
                }
                m_window *= 1.e-9;
                LogDebug << "TimeWindow " << m_window << std::endl;
                break;
            }
            ifs.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        }
    }

    if ( _run != run ) {
        LogFatal << "Invalid RunNumber: " << run << std::endl;
        return false;
    }

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

Implements SvcBase.

Definition at line 61 of file TimeAlignedInputSvc.cc.

{
    return true;
}
EvtObject * TimeAlignedInputSvc::next ( int  nth = 1) [virtual]

Implements ICycler.

Definition at line 66 of file TimeAlignedInputSvc.cc.

{
    while ( m_evts.size() < 2 || (m_evts.back()->m_trigTime-m_evts.front()->m_trigTime) < m_window ) {
        PhyEvent* newEvt = static_cast<PhyEvent*>(m_is->next());
        if ( newEvt == 0 ) break;
        newEvt->m_trigTime.Add(TTimeStamp(0, -m_dt[newEvt->m_det-1]));
        //insert newEvt to the list
        std::list<PhyEvent*>::reverse_iterator it = m_evts.rbegin();
        for ( ; it != m_evts.rend(); ++it ) {
            if ( (*it)->m_trigTime <= newEvt->m_trigTime ) {
                break;
            }
        }
        m_evts.insert(it.base(), newEvt);
    }

    if ( m_evts.empty() ) return 0;

    PhyEvent* first = m_evts.front();
    m_evts.pop_front();
    //std::cout << first->m_entry << " : " << first->m_trigTime << std::endl;
    return first;
}

Member Data Documentation

Definition at line 26 of file TimeAlignedInputSvc.h.

int TimeAlignedInputSvc::m_dt[7] [private]

Definition at line 27 of file TimeAlignedInputSvc.h.

Definition at line 29 of file TimeAlignedInputSvc.h.

std::list<PhyEvent*> TimeAlignedInputSvc::m_evts [private]

Definition at line 30 of file TimeAlignedInputSvc.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:51:11 for TimeAlignedInputSvc by doxygen 1.7.4