HepMC3 event record library
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Private Member Functions
Reader Class Reference

#include <LHEF.h>

+ Collaboration diagram for Reader:

Public Member Functions

 Reader (std::istream &is)
 
 Reader (std::string filename)
 
bool readEvent ()
 
void openeventfile (int ifile)
 

Data Fields

int version
 
std::string outsideBlock
 
std::string headerBlock
 
HEPRUP heprup
 
std::string initComments
 
HEPEUP hepeup
 
std::string eventComments
 
int currevent
 
int curreventfile
 
int currfileevent
 
std::string dirpath
 

Protected Member Functions

bool getline ()
 
bool currentFind (std::string str) const
 

Protected Attributes

std::ifstream intstream
 
std::istream * file
 
std::istream * initfile
 
std::ifstream efile
 
std::string currentLine
 

Private Member Functions

void init ()
 
 Reader ()
 
 Reader (const Reader &)
 
Readeroperator= (const Reader &)
 

Detailed Description

The Reader class is initialized with a stream from which to read a version 1/2 Les Houches Accord event file. In the constructor of the Reader object the optional header information is read and then the mandatory init is read. After this the whole header block including the enclosing lines with tags are available in the public headerBlock member variable. Also the information from the init block is available in the heprup member variable and any additional comment lines are available in initComments. After each successful call to the readEvent() function the standard Les Houches Accord information about the event is available in the hepeup member variable and any additional comments in the eventComments variable. A typical reading sequence would look as follows:

Examples:
LHEF_example_cat.cc.

Definition at line 2742 of file LHEF.h.

Constructor & Destructor Documentation

Reader ( std::istream &  is)
inline

Initialize the Reader with a stream from which to read an event file. After the constructor is called the whole header block including the enclosing lines with tags are available in the public headerBlock member variable. Also the information from the init block is available in the heprup member variable and any additional comment lines are available in initComments.

Parameters
isthe stream to read from.

Definition at line 2756 of file LHEF.h.

References Reader::init().

Reader ( std::string  filename)
inline

Initialize the Reader with a filename from which to read an event file. After the constructor is called the whole header block including the enclosing lines with tags are available in the public headerBlock member variable. Also the information from the init block is available in the heprup member variable and any additional comment lines are available in initComments.

Parameters
filenamethe name of the file to read from.

Definition at line 2772 of file LHEF.h.

References Reader::dirpath, and Reader::init().

Reader ( )
private

The default constructor should never be used.

Reader ( const Reader )
private

The copy constructor should never be used.

Member Function Documentation

bool currentFind ( std::string  str) const
inlineprotected
Returns
true if the current line contains the given string.

Definition at line 2957 of file LHEF.h.

References Reader::currentLine.

bool getline ( )
inlineprotected

Used internally to read a single line from the stream.

Definition at line 2950 of file LHEF.h.

References Reader::currentLine, and Reader::file.

void init ( )
inlineprivate
void openeventfile ( int  ifile)
inline

Open the efentfile with index ifile. If another eventfile is being read, its remaining contents is discarded. This is a noop if current read session is not a multi-file run.

Definition at line 2932 of file LHEF.h.

References Reader::curreventfile, Reader::currfileevent, Reader::dirpath, Reader::efile, HEPRUP::eventfiles, Reader::file, and Reader::heprup.

Reader& operator= ( const Reader )
private

The Reader cannot be assigned to.

bool readEvent ( )
inline

Read an event from the file and store it in the hepeup object. Optional comment lines are stored i the eventComments member variable.

Returns
true if the read sas successful.
Examples:
LHEF_example_cat.cc.

Definition at line 2868 of file LHEF.h.

References Reader::currentFind(), Reader::currentLine, Reader::currevent, Reader::curreventfile, Reader::currfileevent, XMLTag::deleteAll(), HEPRUP::eventfiles, XMLTag::findXMLTags(), Reader::getline(), Reader::hepeup, Reader::heprup, HEPRUP::NPRUP, Reader::openeventfile(), and Reader::outsideBlock.

Field Documentation

std::string currentLine
protected

The last line read in from the stream in getline().

Definition at line 2989 of file LHEF.h.

int currevent

The number of the current event (starting from 1).

Definition at line 3032 of file LHEF.h.

int curreventfile

The current event file being read from (-1 means there are no separate event files).

Definition at line 3038 of file LHEF.h.

int currfileevent

The number of the current event in the current event file.

Definition at line 3043 of file LHEF.h.

std::string dirpath

The directory from where we are reading files.

Definition at line 3048 of file LHEF.h.

std::ifstream efile
protected

A separate stream for reading multi-file runs.

Definition at line 2984 of file LHEF.h.

std::string eventComments

Additional comments found with the last read event.

Definition at line 3027 of file LHEF.h.

std::istream* file
protected

The stream we are reading from. This may be a pointer to an external stream or the internal intstream, or a separate event file from a multi-file run

Definition at line 2974 of file LHEF.h.

std::string headerBlock

All lines from the header block.

Examples:
LHEF_example_cat.cc.

Definition at line 3007 of file LHEF.h.

HEPEUP hepeup

The standard information about the last read event.

Examples:
LHEF_example_cat.cc.

Definition at line 3022 of file LHEF.h.

HEPRUP heprup

The standard init information.

Examples:
LHEF_example_cat.cc.

Definition at line 3012 of file LHEF.h.

std::string initComments

Additional comments found in the init block.

Examples:
LHEF_example_cat.cc.

Definition at line 3017 of file LHEF.h.

std::istream* initfile
protected

The original stream from where we read the init block.

Definition at line 2979 of file LHEF.h.

std::ifstream intstream
protected

A local stream which is unused if a stream is supplied from the outside.

Definition at line 2967 of file LHEF.h.

std::string outsideBlock

All lines (since the last readEvent()) outside the header, init and event tags.

Examples:
LHEF_example_cat.cc.

Definition at line 3002 of file LHEF.h.

int version

XML file version

Definition at line 2996 of file LHEF.h.


The documentation for this class was generated from the following file: