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

#include <Gnrtr.h>

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

List of all members.

Public Member Functions

 Gnrtr (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~Gnrtr ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
StatusCode registerData (IStageData &data)
IStagethisStage ()
IStagelowerStage ()

Private Types

typedef HeaderStageData
< DayaBay::GenHeader
GnrtrData

Private Member Functions

void GT_constructor ()
 GtGenerator ---------------------------.
void GT_destructor ()
virtual StatusCode GT_initialize ()
virtual StatusCode GT_execute (GnrtrData *&p_output)
virtual StatusCode GT_finalize ()

Private Attributes

std::vector< std::string > m_genToolNames
 GtGenerator --------------------------- Tool to do initial generation.
std::vector< IHepMCEventMutator * > m_genTools
std::string m_genName
 Name for this generator to be put in the HepMCEvent.
FFTimeStamp m_CurrentTime
 The earliest (smallest) time which this has provided.
bool m_Start
time_t m_tsseconds
 TimeStamp: a starting time stamp in seconds from the Unix Epoch.
int m_tsnanoseconds
TimeStamp m_now

Detailed Description

Definition at line 25 of file Gnrtr.h.


Member Typedef Documentation

Definition at line 36 of file Gnrtr.h.


Constructor & Destructor Documentation

Gnrtr::Gnrtr ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 21 of file Gnrtr.cc.

    : StageProcessor<DayaBay::GenHeader>(name,pSvcLocator)
{
    declareProperty("TimeStamp",m_tsseconds = 0,
                    "Absolute start time in seconds from the unix epoch. "
                    "Caution: this is a bare integer, do not multiply by CLHEP seconds.");

    declareProperty("TimeStampNano",m_tsnanoseconds = 0,
                    "Time offset in nanoseconds to add to the absolute start time");

    m_pullMode=true;
    
    GT_constructor();
}
Gnrtr::~Gnrtr ( ) [virtual]

Definition at line 36 of file Gnrtr.cc.


Member Function Documentation

StatusCode Gnrtr::initialize ( ) [virtual]

Reimplemented from StageProcessor< DayaBay::GenHeader >.

Definition at line 41 of file Gnrtr.cc.

{
    StatusCode sc = this->StageProcessor<DayaBay::GenHeader>::initialize();
    if (sc.isFailure()) return sc;

    m_Start=true;

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

    m_now = TimeStamp(m_tsseconds,m_tsnanoseconds);

    return GT_initialize();
}
StatusCode Gnrtr::execute ( ) [virtual]

Fifteen Stuff

Definition at line 56 of file Gnrtr.cc.

{
    if(m_Start || m_CurrentTime <= thisStage()->currentTime()) {
        m_Start=false;
        GnrtrData* pGD=0;
        //
        // Because this execute() is not triggered by sysExecute()
        // preExecute() and postExecute() are called here explicitly.
        preExecute();
        StatusCode sc = GT_execute(pGD);
        if(sc.isFailure()) {
            return sc;
        }
        postExecute();
        //
        thisStage()->pushElement(pGD);
        this->registerData(*pGD);
        m_CurrentTime=pGD->time();
        debug()<<"to grep: new data pushed out at time "<<pGD->time()<<endreq;
    }

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

Definition at line 81 of file Gnrtr.cc.

{
    return GT_finalize();
}
void Gnrtr::GT_constructor ( ) [private]

GtGenerator ---------------------------.

----------------- GtGenerator --------------------- following are copies from GtGenerator

Definition at line 91 of file Gnrtr.cc.

{
    declareProperty("GenTools",m_genToolNames,
                    "Tools to generate HepMC::GenEvents");
    declareProperty("GenName", m_genName = "GtGenerator",
                    "Name of this generator for book keeping purposes.");
}
void Gnrtr::GT_destructor ( ) [private]

Definition at line 100 of file Gnrtr.cc.

{
}
StatusCode Gnrtr::GT_initialize ( ) [private, virtual]

Definition at line 104 of file Gnrtr.cc.

{
    for (size_t ind=0; ind < m_genToolNames.size(); ++ind) {
        std::string gtn = m_genToolNames[ind];
        try {
            m_genTools.push_back(tool<IHepMCEventMutator>(gtn));
        }
        catch(const GaudiException& exg) {
            fatal() << "Failed to get generator: \"" << gtn << "\"" << endreq;
            return StatusCode::FAILURE;
        }
        info () << "Added gen tool " << gtn << endreq;
    }

    return StatusCode::SUCCESS;
}
StatusCode Gnrtr::GT_execute ( GnrtrData *&  p_output) [private, virtual]

This line is for Fifteen This pointer is passed to next stage and next processcor. It is will be deleted when the data is consumed.

Definition at line 121 of file Gnrtr.cc.

{
    // Look for pre-existing header object or make new one
    DayaBay::GenHeader* gen_header = MakeHeaderObject();


    HepMC::GenEvent* event = new HepMC::GenEvent;
    event->set_event_number(this->getExecNum());

    // Let each tool do its thing on the event
    for (size_t ind = 0; ind< m_genTools.size(); ++ind) {
        debug () << "Running gen tool #" << ind << " " << m_genToolNames[ind]
                 << endreq;
        if (m_genTools[ind]->mutate(*event).isFailure()) {
            fatal() << "Generator Tool " << m_genToolNames[ind]
                    << " failed" << endreq;
            return StatusCode::FAILURE;
        }
    }

    // Find the smallest time
    double dt = std::numeric_limits<double>::max();
    {
        HepMC::GenEvent::vertex_const_iterator it, done = event->vertices_end();
        for (it = event->vertices_begin(); it != done; ++it) {
            double t = (*it)->position().t();
            debug()<<"time of this vertex: "<<t<<endreq;
            if (t < dt) dt = t;
        }
    }
    debug () << "Smallest time of " 
             << event->vertices_size() << " vertices = " << dt << endreq;

    // Slurp away seconds and ns and leave the rest
    dt = dt/CLHEP::second;      // bring into explicit units of seconds
    time_t seconds = (time_t)dt;
    double fractional = dt - seconds;
    int ns = (int)(1e9*fractional);
    double rest = fractional - (1e-9*ns);

    // how much we steal away from each vertex time
    double toffset = (dt - rest)*CLHEP::second; // put back into system of units

    // Increment our notion of now
    m_now.Add(TimeStamp(seconds,ns));
    gen_header->setTimeStamp(m_now);

    debug() << "Offset time is " << toffset 
            << ", now is " << m_now << endreq;


    // Loop over vertices to set reduce time we stole and set time extent
    {
        double earliest = -1, latest = -1;
        HepMC::GenEvent::vertex_iterator it, done = event->vertices_end();
        for (it = event->vertices_begin(); it != done; ++it) {
            HepMC::FourVector vtx = (*it)->position();
            double t = vtx.t() - toffset;
            vtx.setT(t);
            (*it)->set_position(vtx);

            if (earliest < 0 || earliest > t) earliest = t;
            if (latest   < 0 || latest   < t)   latest = t;
        }
        
        TimeStamp ts_earliest(m_now);
        if (earliest > 0)
            ts_earliest.Add(earliest/CLHEP::second);
        gen_header->setEarliest(ts_earliest);

        TimeStamp ts_latest(m_now);
        if (latest > 0)
            ts_latest.Add(latest/CLHEP::second);
        gen_header->setLatest(ts_latest);
    }

    // GenHeader subclass
    gen_header->setEvent(event);
    gen_header->setGeneratorName(m_genName);

    // >> Fifteen
    p_output=new GnrtrData(*gen_header);
    // << Fifteen

    return StatusCode::SUCCESS;

}
StatusCode Gnrtr::GT_finalize ( ) [private, virtual]

Definition at line 212 of file Gnrtr.cc.

{
    for (size_t ind=0; ind < m_genTools.size(); ++ind)
        m_genTools[ind]->release();
    m_genTools.clear();

    return this->StageProcessor<DayaBay::GenHeader>::finalize();
}
StatusCode StageProcessor< class >::registerData ( IStageData data) [inherited]
IStage * StageProcessor< class >::thisStage ( ) [inherited]
IStage * StageProcessor< class >::lowerStage ( ) [inherited]

Member Data Documentation

std::vector<std::string> Gnrtr::m_genToolNames [private]

GtGenerator --------------------------- Tool to do initial generation.

Definition at line 49 of file Gnrtr.h.

std::vector<IHepMCEventMutator*> Gnrtr::m_genTools [private]

Definition at line 50 of file Gnrtr.h.

std::string Gnrtr::m_genName [private]

Name for this generator to be put in the HepMCEvent.

Definition at line 53 of file Gnrtr.h.

The earliest (smallest) time which this has provided.

Definition at line 56 of file Gnrtr.h.

bool Gnrtr::m_Start [private]

Definition at line 59 of file Gnrtr.h.

time_t Gnrtr::m_tsseconds [private]

TimeStamp: a starting time stamp in seconds from the Unix Epoch.

Definition at line 62 of file Gnrtr.h.

int Gnrtr::m_tsnanoseconds [private]

Definition at line 63 of file Gnrtr.h.

Definition at line 64 of file Gnrtr.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:20:44 for Gnrtr by doxygen 1.7.4