| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

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.

00011     : m_eventCount(0)
00012 {
00013 }

HepEvt2HepMC::~HepEvt2HepMC (  ) 

Definition at line 15 of file HepEvt2HepMC.cc.

00016 {
00017     // Drain any still cached
00018     HepMC::GenEvent* event=0;
00019     while (this->cacheSize()) {
00020         this->generate(event).ignore();
00021         delete event;
00022         event = 0;
00023     }
00024 }


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.

00028 {
00029     if (!this->cacheSize()) {
00030         event=0;
00031         STATUSCODE(StatusCode::FAILURE, IssueSeverity::FATAL,
00032                    "No cached events to return, call fill()");
00033     }
00034 
00035     event = m_events.front();
00036     m_events.pop_front();
00037     return StatusCode::SUCCESS;
00038 }

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.

00143 {
00144     FILE* fp = open_file(source_desc);
00145     if (!fp) {
00146         std::string msg = "Failed to open HEPEvt data source: \"";
00147         msg += source_desc;
00148         msg += "\"";
00149         return STATUSCODE(StatusCode::FAILURE,IssueSeverity::FATAL,msg);
00150     }
00151 
00152     std::string line;
00153     int nlines = 0;
00154     while (get_line(fp,line)) {
00155         std::istringstream is; 
00156         is.str(line);
00157         is >> nlines;
00158         HepMC::GenEvent* event = new HepMC::GenEvent(0,m_eventCount);
00159         for(; nlines; --nlines) {
00160             get_line(fp,line);
00161             if (!unpack(line,*event)) return StatusCode::FAILURE;
00162         }
00163         m_events.push_back(event);
00164         ++m_eventCount;
00165     }
00166 
00167     close_file(fp,source_desc);
00168     return STATUSCODE(StatusCode::SUCCESS,IssueSeverity::INFO,
00169                       "Filled HepMC event cache");
00170 }

size_t HepEvt2HepMC::cacheSize (  )  [inline]

Number of primary vertices left in the cache.

Definition at line 29 of file HepEvt2HepMC.h.

00029 { return m_events.size(); }


Member Data Documentation

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

Definition at line 32 of file HepEvt2HepMC.h.

int HepEvt2HepMC::m_eventCount [private]

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 Mon Apr 11 20:55:38 2011 for GenTools by doxygen 1.4.7