/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 Types | Protected Attributes | Private Types | Private Member Functions | Private Attributes
DybBipolarEventLoopMgr Class Reference

An Event Processor that switches between two DybEventLoopMgrs. More...

#include <DybBipolarEventLoopMgr.h>

Collaboration diagram for DybBipolarEventLoopMgr:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DybBipolarEventLoopMgr (const std::string &nam, ISvcLocator *svcLoc)
 Standard Constructor.
virtual ~DybBipolarEventLoopMgr ()
 Standard Destructor.
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 implementation of IInterface: queryInterface
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode reinitialize ()
virtual StatusCode nextEvent (int maxevt)
virtual StatusCode executeEvent (void *par)
virtual StatusCode executeRun (int maxevt)
virtual StatusCode stopRun ()

Protected Types

enum  State { OFFLINE, CONFIGURED, FINALIZED, INITIALIZED }

Protected Attributes

State m_state
 State of the object.

Private Types

typedef std::list< IAlgorithm * > ListAlg

Private Member Functions

StatusCode initialize_elms ()
StatusCode initialize_algs ()

Private Attributes

std::string m_ELM1name
 Property: EventLoopMgr1 and EventLoopMgr2: the names of two EventLoopMgr objects.
std::string m_ELM2name
StringArrayProperty m_topAlgNames
 Property: TopAlg: a list of the union of algorithms in the two ELMs.
ListAlg m_topAlgList
std::string m_eventBuilderAlgName
 Property: EventBuilderAlg: name of the algorithm that builds events.
IEventProcessor * m_eventProcessor1
IEventProcessor * m_eventProcessor2
IEventProcessor * m_theEventProcessor
IIncidentSvc * m_incsvc
bool m_scheduledStop
int m_total_nevt
HEIHandlerm_heiHandler

Detailed Description

An Event Processor that switches between two DybEventLoopMgrs.

bv@bnl.gov Sat Aug 6 11:20:08 2011

Definition at line 25 of file DybBipolarEventLoopMgr.h.


Member Typedef Documentation

typedef std::list<IAlgorithm*> DybBipolarEventLoopMgr::ListAlg [private]

Definition at line 51 of file DybBipolarEventLoopMgr.h.


Member Enumeration Documentation

Enumerator:
OFFLINE 
CONFIGURED 
FINALIZED 
INITIALIZED 

Definition at line 80 of file DybBipolarEventLoopMgr.h.


Constructor & Destructor Documentation

DybBipolarEventLoopMgr::DybBipolarEventLoopMgr ( const std::string &  nam,
ISvcLocator *  svcLoc 
)

Standard Constructor.

Definition at line 20 of file DybBipolarEventLoopMgr.cpp.

  : Service(nam, svcLoc)
  , m_eventProcessor1(0)
  , m_eventProcessor2(0)
  , m_theEventProcessor(0)
  , m_scheduledStop(false)
  , m_total_nevt(0)
  , m_heiHandler(0)
{
    // My additional properties
    declareProperty("EventLoopMgr1",m_ELM1name="ScratchLoopMgr",
                    "Name of first DybEventLoopMgr");
    declareProperty("EventLoopMgr2",m_ELM2name="EventLoopMgr",
                    "Name of second DybEventLoopMgr");
    declareProperty("TopAlg",m_topAlgNames,
                    "Union list of algorithms for sub-EventLoopMgrs");
    declareProperty("EventBuilderAlg",m_eventBuilderAlgName = "EventBuilderAlg",
                    "Name of the algorithm responsible for building events (def: EventBuilderAlg)");

    m_state = OFFLINE;
}
DybBipolarEventLoopMgr::~DybBipolarEventLoopMgr ( ) [virtual]

Standard Destructor.

Definition at line 42 of file DybBipolarEventLoopMgr.cpp.


Member Function Documentation

StatusCode DybBipolarEventLoopMgr::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
) [virtual]

implementation of IInterface: queryInterface

Definition at line 47 of file DybBipolarEventLoopMgr.cpp.

{
    if ( riid == IID_IEventProcessor )  {
        *ppvInterface = (IEventProcessor*)this;
    }
    else  {
        return Service::queryInterface(riid, ppvInterface);
    }
    addRef();
    return StatusCode::SUCCESS;
}
StatusCode DybBipolarEventLoopMgr::initialize ( ) [virtual]

Definition at line 59 of file DybBipolarEventLoopMgr.cpp.

{
    MsgStream log(msgSvc(), name());

    StatusCode sc = Service::initialize();
    //StatusCode sc = setProperties();
    if (sc.isFailure()) {
        log << MSG::ERROR << "Failed to initialize Service base class" << endreq;
        //log << MSG::ERROR << "Failed to set properties" << endreq;
        return sc;
    }

    sc = this->initialize_elms();
    if (sc.isFailure()) {
        log << MSG::ERROR << "Failed to initialize sub event loop managers" << endreq;
        return sc;
    }

    m_state = INITIALIZED;

    sc = this->initialize_algs();
    if (sc.isFailure()) {
        log << MSG::ERROR << "Failed to initialize algorithms" << endreq;
        return sc;
    }

    return StatusCode::SUCCESS;
}
StatusCode DybBipolarEventLoopMgr::finalize ( ) [virtual]

Definition at line 180 of file DybBipolarEventLoopMgr.cpp.

{
    MsgStream log(msgSvc(), name());
    log << MSG::INFO << "A useless message about me finalizing" << endreq;

    m_incsvc->removeListener(m_heiHandler,"HybridExecutionIncident");
    delete m_heiHandler; m_heiHandler = 0;
    m_incsvc->release();
    m_incsvc = 0;

    m_state = FINALIZED;

    return Service::finalize();
}
StatusCode DybBipolarEventLoopMgr::reinitialize ( ) [virtual]

Definition at line 196 of file DybBipolarEventLoopMgr.cpp.

{
    MsgStream log(msgSvc(), name());
    log << MSG::WARNING << "Why am I being reinitialized?" << endreq;
    return StatusCode::SUCCESS;
}
StatusCode DybBipolarEventLoopMgr::nextEvent ( int  maxevt) [virtual]

Definition at line 204 of file DybBipolarEventLoopMgr.cpp.

{
    MsgStream log(msgSvc(), name());
    StatusCode sc = SUCCESS;
    for (int nevt = 0; (maxevt == -1 ? true : nevt < maxevt);  ++nevt, ++m_total_nevt) {
        // Check if there is a scheduled stop issued by some algorithm/sevice
        if (m_scheduledStop) {
            m_scheduledStop = false;
            log << MSG::ALWAYS
                << "Terminating event processing loop due to scheduled stop" << endreq;
            return StatusCode::SUCCESS;
        }

        // delegate everything else but only one event
        sc = m_theEventProcessor->nextEvent(1);
        if (sc.isFailure()) return sc;
    }

    return sc;
}
StatusCode DybBipolarEventLoopMgr::executeEvent ( void *  par) [virtual]

Definition at line 225 of file DybBipolarEventLoopMgr.cpp.

{
    return m_theEventProcessor->executeEvent(par);
}
StatusCode DybBipolarEventLoopMgr::executeRun ( int  maxevt) [virtual]

Definition at line 230 of file DybBipolarEventLoopMgr.cpp.

{
    StatusCode  sc = StatusCode::SUCCESS;
    MsgStream log( msgSvc(), name() );
    bool eventfailed = false;
    ListAlg::iterator ita = m_topAlgList.end();

    // Call the beginRun() method of all top algorithms
    for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
        sc = (*ita)->sysBeginRun();
        if (sc.isFailure()) {
            log << MSG::WARNING << "beginRun() of algorithm " << (*ita)->name() << " failed" << endreq;
            eventfailed = true;
        }
    }

    // Call now the nextEvent(...)
    sc = this->nextEvent(maxevt);
    if (sc.isFailure()) { eventfailed = true; }

    // Call the endRun() method of all top algorithms
    for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
        sc = (*ita)->sysEndRun();
        if (sc.isFailure()) {
            log << MSG::WARNING << "endRun() of algorithm " << (*ita)->name() << " failed" << endreq;
            eventfailed = true;
        }
    }

    return eventfailed ? StatusCode::FAILURE : StatusCode::SUCCESS;
}
StatusCode DybBipolarEventLoopMgr::stopRun ( ) [virtual]

Definition at line 262 of file DybBipolarEventLoopMgr.cpp.

{
    m_scheduledStop = true;
    m_eventProcessor1->stopRun();
    m_eventProcessor2->stopRun();
    return StatusCode::SUCCESS;
}
StatusCode DybBipolarEventLoopMgr::initialize_elms ( ) [private]

Definition at line 88 of file DybBipolarEventLoopMgr.cpp.

{
    MsgStream log(msgSvc(), name());

    // Get my sub-ELMs
    log << MSG::INFO << "Bipolar using event processors: "
        << "\"" << m_ELM1name << "\" "
        << "\"" << m_ELM2name << "\" "
        << endreq;

    StatusCode sc1, sc2;
    sc1 = serviceLocator()->service(m_ELM1name, m_eventProcessor1, true);
    sc2 = serviceLocator()->service(m_ELM2name, m_eventProcessor2, true);
    if (sc1.isFailure() || sc2.isFailure()) {
        log << MSG::ERROR 
            << "Failed to get sub event loop managers as IEventProcessors: "
            << m_ELM1name << " (" << sc1 << ") "
            << m_ELM2name << " (" << sc2 << ")" 
            << endreq;
        return StatusCode::FAILURE;
    }
   
    // starting point
    m_theEventProcessor = m_eventProcessor1;

    // log << MSG::DEBUG 
    //     << "Explicitly setting my state to CONFIGURED."
    //     << endreq;
    // m_state = Gaudi::StateMachine::CONFIGURED;

    // Connect to "HybridExecutionIncident"
    StatusCode sc = this->service("IncidentSvc",m_incsvc,true);
    if (sc.isFailure()) {
        log << MSG::ERROR
            << "Failed to get IncidentSvc" << endreq;
        return sc;
    }
    m_heiHandler = new HEIHandler(m_theEventProcessor, m_eventProcessor1, m_eventProcessor2, log);
    m_incsvc->addListener(m_heiHandler,"HybridExecutionIncident");
    return sc;
}
StatusCode DybBipolarEventLoopMgr::initialize_algs ( ) [private]

Definition at line 130 of file DybBipolarEventLoopMgr.cpp.

{
    MsgStream log(msgSvc(), name());
    StatusCode sc = StatusCode::SUCCESS;
    if (!( CONFIGURED == m_state || INITIALIZED == m_state )) {
        return sc;
    }

    // fixme: this name is also specified to the DybEventLoopMgrs,
    // setting this name on the algorithms is better done there....
    std::string dataServiceName = "ReadoutDataSvc";

    // Get my algs
    SmartIF<IAlgManager> algMan(IID_IAlgManager, serviceLocator());
    m_topAlgList.clear();
    const std::vector<std::string>& algnames = m_topAlgNames.value();
    for (size_t ind=0; ind < algnames.size(); ++ind) {
        ListItem item(algnames[ind]);
        // Got the type and name. Now creating the algorithm, avoiding duplicate creation.
        IAlgorithm* ialg = 0;
        std::string item_name = item.name() + getGaudiThreadIDfromName(name()) ;
        sc = algMan->getAlgorithm(item_name, ialg);
        if (sc.isSuccess( )) {
            log << MSG::DEBUG << "Top Algorithm " << item_name << " already exists" << endreq;
            ialg->addRef();  // increment reference count
        } 
        else {
            log << MSG::DEBUG << "Creating Top Algorithm " << item.type() 
                << " with name " << item_name << endreq;
            sc = algMan->createAlgorithm(item.type(), item_name, ialg);
            if(sc.isFailure()) {
                log << MSG::ERROR << "Unable to create Top Algorithm " << item.type() 
                    << " with name " << item_name << endreq;
                return sc;
            }
        }

        if (item.name() == m_eventBuilderAlgName) {
            dataServiceName = "EventDataSvc";
        }            

        SmartIF<IProperty> algProp(IID_IProperty, ialg);
        sc = algProp->setProperty("EventDataService",dataServiceName);
        if (sc.isFailure()) return sc;

        m_topAlgList.push_back(ialg);
    }
    return sc;
}

Member Data Documentation

std::string DybBipolarEventLoopMgr::m_ELM1name [private]

Property: EventLoopMgr1 and EventLoopMgr2: the names of two EventLoopMgr objects.

Definition at line 55 of file DybBipolarEventLoopMgr.h.

std::string DybBipolarEventLoopMgr::m_ELM2name [private]

Definition at line 55 of file DybBipolarEventLoopMgr.h.

StringArrayProperty DybBipolarEventLoopMgr::m_topAlgNames [private]

Property: TopAlg: a list of the union of algorithms in the two ELMs.

Definition at line 58 of file DybBipolarEventLoopMgr.h.

Definition at line 59 of file DybBipolarEventLoopMgr.h.

Property: EventBuilderAlg: name of the algorithm that builds events.

Definition at line 62 of file DybBipolarEventLoopMgr.h.

IEventProcessor* DybBipolarEventLoopMgr::m_eventProcessor1 [private]

Definition at line 65 of file DybBipolarEventLoopMgr.h.

IEventProcessor* DybBipolarEventLoopMgr::m_eventProcessor2 [private]

Definition at line 66 of file DybBipolarEventLoopMgr.h.

IEventProcessor* DybBipolarEventLoopMgr::m_theEventProcessor [private]

Definition at line 67 of file DybBipolarEventLoopMgr.h.

IIncidentSvc* DybBipolarEventLoopMgr::m_incsvc [private]

Definition at line 69 of file DybBipolarEventLoopMgr.h.

Definition at line 71 of file DybBipolarEventLoopMgr.h.

Definition at line 72 of file DybBipolarEventLoopMgr.h.

Definition at line 74 of file DybBipolarEventLoopMgr.h.

State of the object.

Definition at line 82 of file DybBipolarEventLoopMgr.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:09:08 for DybEventMgr by doxygen 1.7.4