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

#include <HepEvt2HepMC.h>

List of all members.

Public Member Functions

 HepEvt2HepMC ()
 ~HepEvt2HepMC ()
StatusCode generate (HepMC::GenEvent *&event)
 Remove next event from the cache and return it.
StatusCode fill (const char *source_desc)
 Fill up the cache using the source description.
size_t cacheSize ()
 Number of primary vertices left in the cache.

Private Attributes

std::list< HepMC::GenEvent * > m_events
int m_eventCount

Detailed Description

Definition at line 16 of file HepEvt2HepMC.h.


Constructor & Destructor Documentation

HepEvt2HepMC::HepEvt2HepMC ( )

Definition at line 10 of file HepEvt2HepMC.cc.

    : m_eventCount(0)
{
}
HepEvt2HepMC::~HepEvt2HepMC ( )

Definition at line 15 of file HepEvt2HepMC.cc.

{
    // Drain any still cached
    HepMC::GenEvent* event=0;
    while (this->cacheSize()) {
        this->generate(event).ignore();
        delete event;
        event = 0;
    }
}

Member Function Documentation

StatusCode HepEvt2HepMC::generate ( HepMC::GenEvent *&  event)

Remove next event from the cache and return it.

Definition at line 27 of file HepEvt2HepMC.cc.

{
    if (!this->cacheSize()) {
        event=0;
        STATUSCODE(StatusCode::FAILURE, IssueSeverity::FATAL,
                   "No cached events to return, call fill()");
    }

    event = m_events.front();
    m_events.pop_front();
    return StatusCode::SUCCESS;
}
StatusCode HepEvt2HepMC::fill ( const char *  source_desc)

Fill up the cache using the source description.

This can be a file name or an executable command followed by a "|" symbol.

Definition at line 142 of file HepEvt2HepMC.cc.

{
    FILE* fp = open_file(source_desc);
    if (!fp) {
        std::string msg = "Failed to open HEPEvt data source: \"";
        msg += source_desc;
        msg += "\"";
        return STATUSCODE(StatusCode::FAILURE,IssueSeverity::FATAL,msg);
    }

    std::string line;
    int nlines = 0;
    while (get_line(fp,line)) {
        std::istringstream is; 
        is.str(line);
        is >> nlines;
        HepMC::GenEvent* event = new HepMC::GenEvent(0,m_eventCount);
        for(; nlines; --nlines) {
            get_line(fp,line);
            if (!unpack(line,*event)) return StatusCode::FAILURE;
        }
        m_events.push_back(event);
        ++m_eventCount;
    }

    close_file(fp,source_desc);
    return STATUSCODE(StatusCode::SUCCESS,IssueSeverity::INFO,
                      "Filled HepMC event cache");
}
size_t HepEvt2HepMC::cacheSize ( ) [inline]

Number of primary vertices left in the cache.

Definition at line 29 of file HepEvt2HepMC.h.

{ return m_events.size(); }

Member Data Documentation

std::list<HepMC::GenEvent*> HepEvt2HepMC::m_events [private]

Definition at line 32 of file HepEvt2HepMC.h.

Definition at line 33 of file HepEvt2HepMC.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:18:51 for GenTools by doxygen 1.7.4