/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 | Static Public Member Functions | Protected Member Functions | Private Attributes
Stage Class Reference

#include <Stage.h>

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

List of all members.

Public Member Functions

 Stage (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Constructor.
virtual FFTimeStamp currentTime () const
 IStage interface.
virtual StatusCode nextElement (IStageData *&pIStgData, bool erase=true)
 run Pop out the first element with smallest time from stage data.
virtual StatusCode pushElement (IStageData *pIStgData)
 push an element into stage data
virtual StatusCode initialize ()
 Overriding initialize and finalize.
virtual StatusCode finalize ()

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Protected Member Functions

virtual ~Stage ()
 Standard destructor.

Private Attributes

FFTimeStamp m_CurrentTime
 m_CurrentTime always keeps track of the eariliest time that each processor has reached.
std::string m_SeqName
 Property "Sequencer". Sequencer to use.
Algorithm * m_sequencer
IStageDataList m_DataList
 IStageData list.
bool m_read_erase
 a flag for the status of the first element in data list If the first element is read and erased then this true.
list __all__ = ['Configure','StageConf','Test']

Detailed Description

Author:
Zhe Wang, Mar. 16, 2008
Zhe Wang, Mar. 16, 2008

This code is one realization of IStage.

Definition at line 20 of file Stage.h.


Constructor & Destructor Documentation

Stage::Stage ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Standard Constructor.

Definition at line 15 of file Stage.cc.

  : GaudiTool( type, name, parent ) 
  , m_SeqName("")
{
    // declare my special interface
    declareInterface<IStage>(this);

    declareProperty( "Sequencer", m_SeqName, "Sequencer's Name");
}
Stage::~Stage ( ) [protected, virtual]

Standard destructor.

Definition at line 196 of file Stage.cc.

{ 
    MsgStream log(msgSvc(), name());
    log << MSG::DEBUG << "destructing ......" << endreq;
}

Member Function Documentation

FFTimeStamp Stage::currentTime ( ) const [virtual]

IStage interface.

Implements IStage.

Definition at line 28 of file Stage.cc.

{
    MsgStream log(msgSvc(), name());
    log << MSG::DEBUG << "currentTime() is: " << m_CurrentTime << endreq;
    return m_CurrentTime;
}
StatusCode Stage::nextElement ( IStageData *&  pIStgData,
bool  erase = true 
) [virtual]

run Pop out the first element with smallest time from stage data.

Multiple processors can share the same stage data by reading passing "erase=false". The last processor in the chain must call with erase="true" and delete the resulting IStageData when it is finished using it.

Some data needs to be generated

The first element is read out, but not marked for deletion that element will be provided again. So nothing to do here.

find the first event in time return the data erase the data if "erase==true" the last consumer MUST remember to erase the data

return that

update the flag

Implements IStage.

Definition at line 37 of file Stage.cc.

{
    debug() << " -- == nextElement() is called == -- " << endreq;

    std::vector<Algorithm*>::iterator pVec;

    if(m_read_erase==true) {
        m_sequencer->resetExecuted();
        StatusCode sc = m_sequencer->execute();
        if (sc.isFailure()) {
            error() << "Sequence failed" << endreq;
            return sc;
        }
        debug() << "every processor retured" << endreq;
    } else {
    }

    IStageDataList::iterator ppData;

    debug() << "current number of elements: "<< m_DataList.size() <<endreq;
    if(m_DataList.size()<=0) {
        fatal()<<"NO data available! Where is data? Check processors!"<<endreq;
        return StatusCode::FAILURE;
    }

    ppData=m_DataList.begin();
    m_CurrentTime=ppData->first;
    debug() << "Smallest time found T_min = "<< m_CurrentTime << endreq;

    pIStgData=ppData->second;
  
    if(erase) {
        m_DataList.erase(ppData);
    } 

    m_read_erase=erase;

    debug() << " -- == nextElement() call finished == --" << endreq;
    return StatusCode::SUCCESS;
}
StatusCode Stage::pushElement ( IStageData pIStgData) [virtual]

push an element into stage data

push a data into store

Implements IStage.

Definition at line 90 of file Stage.cc.

{
    MsgStream log(msgSvc(), name());
    StatusCode sc;
  
    m_DataList.insert(IStageDataList::value_type(pIStgData->time(),pIStgData));
  
    return sc;
}
StatusCode Stage::initialize ( ) [virtual]

Overriding initialize and finalize.

At beginning, no data is available. It looks like last event is erased.

Definition at line 102 of file Stage.cc.

{
    // Make use of svc<>
    IMessageSvc* msg = svc<IMessageSvc>("MessageSvc");
    MsgStream log(msg, name());
    log << MSG::DEBUG << "intializing ......" << endreq;

    if ("" == m_SeqName) {
        log << MSG::ERROR << "No seqencer given to stage " << name() << endreq;
        return StatusCode::FAILURE;
    }

    { // inspired by Algorithm::createSubAlgorithm and
      // GaudiSequencer::decodeNames()

        SmartIF<IAlgManager> am(IID_IAlgManager,serviceLocator());

        IAlgorithm *tmp = 0;

        StatusCode sc = am->getAlgorithm(m_SeqName, tmp);
        if (sc.isFailure()) {
            log << MSG::DEBUG
                << "Failed to get GaudiSequencer named " << m_SeqName 
                << ". Will try to create..." << endreq;

            sc = am->createAlgorithm ("GaudiSequencer", m_SeqName, tmp);
            if( sc.isFailure() ) {
                log << MSG::ERROR
                    << "Failed to create GaudiSequencer named "
                    << m_SeqName << endreq;
                return StatusCode::FAILURE;
            }
        }

        try{
            m_sequencer = dynamic_cast<Algorithm*>(tmp);
        } 
        catch(...) {
            log << MSG::ERROR
                << "GaudiSequencer named " << m_SeqName << " not an Algorithm?!?" 
                << endreq;
            return StatusCode::FAILURE;
        }
        if (!m_sequencer) {
            log << MSG::ERROR
                << "GaudiSequencer not an algorithm??"
                << endreq;
            return StatusCode::FAILURE;
        }

        log << MSG::INFO
            << "Got algorithm " << m_sequencer->name() 
            << " setting properties on it"
            << endreq;

        IJobOptionsSvc* jos = svc<IJobOptionsSvc>("JobOptionsSvc");
        jos->setMyProperties(m_SeqName,m_sequencer);
        jos->release();
    }

    // Let init flow down to subalgs
    StatusCode sc = m_sequencer->initialize();
    if (sc.isFailure()) {
        log << MSG::ERROR
            << "GaudiSequencer::initialize() failed" << endreq;
        return sc;
    }
    log << MSG::DEBUG
        << "Got GaudiSequencer/" << m_sequencer->name() << endreq;

    // Although initialized to 0, however, no special meaning
    m_CurrentTime=0;

    m_DataList.clear();

    m_read_erase=true;

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

Definition at line 185 of file Stage.cc.

{
    MsgStream log(msgSvc(), name());
    log << MSG::DEBUG << "finalizing ......" << endreq;

    // Let finalize flow down to subalgs
    return m_sequencer->finalize();
}
static const InterfaceID& IStage::interfaceID ( ) [inline, static, inherited]

Retrieve interface ID.

Definition at line 24 of file IStage.h.

{ return IID_IStage; }

Member Data Documentation

m_CurrentTime always keeps track of the eariliest time that each processor has reached.

Definition at line 48 of file Stage.h.

std::string Stage::m_SeqName [private]

Property "Sequencer". Sequencer to use.

Definition at line 51 of file Stage.h.

Algorithm* Stage::m_sequencer [private]

Definition at line 52 of file Stage.h.

IStageData list.

Definition at line 55 of file Stage.h.

bool Stage::m_read_erase [private]

a flag for the status of the first element in data list If the first element is read and erased then this true.

Definition at line 60 of file Stage.h.

list Stage::__all__ = ['Configure','StageConf','Test'] [private]

Definition at line 3 of file __init__.py.


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:07:33 for Stage by doxygen 1.7.4