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

#include <GtGenerator.h>

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

List of all members.

Public Member Functions

 GtGenerator (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~GtGenerator ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
DayaBay::GenHeaderGetCurrentHeaderObject () const
virtual StatusCode sysInitialize ()
virtual StatusCode sysExecute ()
virtual StatusCode preExecute ()
virtual StatusCode postExecute ()
virtual StatusCode sysFinalize ()
IDataProviderSvc * arcSvc () const
void putTES (DataObject *obj, std::string location) const
TYPE * getTES (std::string location) const
TYPE * getAES (std::string location, int index) const
std::vector< DataObject * > getAEScollection (std::string location) const
int getExecNum ()
std::string Location () const

Protected Member Functions

DayaBay::GenHeaderMakeHeaderObject ()
void InitializeHeader (DayaBay::HeaderObject *header)
TYPE * MakeHeader ()
TYPE * MakeHeader (std::vector< const DayaBay::IHeader * > &inputHeaders)
TYPE * MakeHeader (const DayaBay::IHeader *referenceHeader)
void AppendInputHeader (const DayaBay::HeaderObject *header) const

Protected Attributes

DayaBay::HeaderObjectm_headerObject
bool m_pullMode
std::string m_location

Private Attributes

std::vector< std::string > m_genToolNames
 Tool to do initial generation.
std::vector< IHepMCEventMutator * > m_genTools
std::string m_genName
 Name for this generator to be put in the HepMCEvent.
time_t m_tsseconds
 TimeStamp: a starting time stamp in seconds from the Unix Epoch.
TimeStamp m_now

Detailed Description

Definition at line 27 of file GtGenerator.h.


Constructor & Destructor Documentation

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

Definition at line 21 of file GtGenerator.cc.

    : DybAlgorithm<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("GenTools",m_genToolNames,
                    "Tools to generate HepMC::GenEvents");
    declareProperty("GenName", m_genName = "GtGenerator",
                    "Name of this generator for book keeping purposes.");
}
GtGenerator::~GtGenerator ( ) [virtual]

Definition at line 33 of file GtGenerator.cc.

{
}

Member Function Documentation

StatusCode GtGenerator::initialize ( ) [virtual]

Definition at line 37 of file GtGenerator.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;
    }

    // Set the generator start time
    m_now = TimeStamp(m_tsseconds);

    return StatusCode::SUCCESS;
}
StatusCode GtGenerator::execute ( ) [virtual]

Definition at line 57 of file GtGenerator.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();
            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);

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

Definition at line 137 of file GtGenerator.cc.

{
    // Do NOT release the tools.  This is handled implicitly
    m_genTools.clear();

    return this->GaudiAlgorithm::finalize();
}
DayaBay::GenHeader * DybAlgorithm< DayaBay::GenHeader >::GetCurrentHeaderObject ( ) const [inherited]
virtual StatusCode DybAlgorithm< DayaBay::GenHeader >::sysInitialize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::GenHeader >::sysExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::GenHeader >::preExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::GenHeader >::postExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::GenHeader >::sysFinalize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

IDataProviderSvc * DybAlgorithm< DayaBay::GenHeader >::arcSvc ( ) const [inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::GenHeader >::putTES ( DataObject *  obj,
std::string  location 
) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::GenHeader >::getTES ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::GenHeader >::getAES ( std::string  location,
int  index 
) const [inherited]

Reimplemented from DybBaseAlg.

std::vector< DataObject * > DybAlgorithm< DayaBay::GenHeader >::getAEScollection ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

int DybAlgorithm< DayaBay::GenHeader >::getExecNum ( ) [inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::GenHeader >::Location ( ) const [inherited]

Reimplemented from DybBaseAlg.

DayaBay::GenHeader * DybAlgorithm< DayaBay::GenHeader >::MakeHeaderObject ( ) [protected, inherited]
void DybAlgorithm< DayaBay::GenHeader >::InitializeHeader ( DayaBay::HeaderObject header) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::GenHeader >::MakeHeader ( ) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::GenHeader >::MakeHeader ( std::vector< const DayaBay::IHeader * > &  inputHeaders) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::GenHeader >::MakeHeader ( const DayaBay::IHeader referenceHeader) [protected, inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::GenHeader >::AppendInputHeader ( const DayaBay::HeaderObject header) const [protected, inherited]

Reimplemented from DybBaseAlg.


Member Data Documentation

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

Tool to do initial generation.

Definition at line 39 of file GtGenerator.h.

Definition at line 40 of file GtGenerator.h.

std::string GtGenerator::m_genName [private]

Name for this generator to be put in the HepMCEvent.

Definition at line 43 of file GtGenerator.h.

time_t GtGenerator::m_tsseconds [private]

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

Definition at line 46 of file GtGenerator.h.

Definition at line 49 of file GtGenerator.h.

Reimplemented from DybBaseAlg.

bool DybAlgorithm< DayaBay::GenHeader >::m_pullMode [protected, inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::GenHeader >::m_location [protected, inherited]

Reimplemented from DybBaseAlg.


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:18:51 for GenTools by doxygen 1.7.4