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

Detailed Description

The Writer class is initialized with a stream to which to write a version 1.0 Les Houches Accord event file. In the constructor of the Writer object the main XML tag is written out, with the corresponding end tag is written in the destructor. After a Writer object has been created, it is possible to assign standard init information in the heprup member variable. In addition any XML formatted information can be added to the headerBlock member variable (directly or via the addHeader() function). Further comment line (beginning with a # character) can be added to the initComments variable (directly or with the addInitComment() function). After this information is set, it should be written out to the file with the init() function.

Before each event is written out with the writeEvent() function, the standard event information can then be assigned to the hepeup variable and optional comment lines (beginning with a # character) may be given to the eventComments variable (directly or with the addEventComment() function).

Examples:
LHEF_example_cat.cc.

Definition at line 3114 of file LHEF.h.

#include <LHEF.h>

+ Collaboration diagram for Writer:

Public Member Functions

 Writer (std::ostream &os)
 
 Writer (std::string filename)
 
 ~Writer ()
 
std::ostream & headerBlock ()
 
std::ostream & initComments ()
 
std::ostream & eventComments ()
 
void init ()
 
bool openeventfile (int ifile)
 
void writeinit ()
 
void writeEvent ()
 

Data Fields

std::ostringstream headerStream
 
HEPRUP heprup
 
std::ostringstream initStream
 
HEPEUP hepeup
 
std::ostringstream eventStream
 

Protected Attributes

std::ofstream intstream
 
std::ostream * file
 
std::ostream * initfile
 
std::ofstream efile
 
int lastevent
 
int curreventfile
 
int currfileevent
 
std::string dirpath
 

Private Member Functions

 Writer ()
 
 Writer (const Writer &)
 
Writeroperator= (const Writer &)
 

Constructor & Destructor Documentation

Writer ( std::ostream &  os)
inline

Create a Writer object giving a stream to write to.

Parameters
osthe stream where the event file is written.

Definition at line 3122 of file LHEF.h.

Writer ( std::string  filename)
inline

Create a Writer object giving a filename to write to.

Parameters
filenamethe name of the event file to be written.

Definition at line 3129 of file LHEF.h.

References Writer::dirpath.

~Writer ( )
inline

The destructor writes out the final XML end-tag.

Definition at line 3139 of file LHEF.h.

References Writer::curreventfile, Writer::currfileevent, HEPRUP::eventfiles, Writer::file, Writer::heprup, Writer::initfile, and Writer::writeinit().

Writer ( )
private

The default constructor should never be used.

Writer ( const Writer )
private

The copy constructor should never be used.

Member Function Documentation

std::ostream& eventComments ( )
inline

Add comment lines to the next event to be written out with this stream.

Examples:
LHEF_example_cat.cc.

Definition at line 3168 of file LHEF.h.

References Writer::eventStream.

std::ostream& headerBlock ( )
inline

Add header lines consisting of XML code with this stream.

Examples:
LHEF_example_cat.cc.

Definition at line 3154 of file LHEF.h.

References Writer::headerStream.

void init ( )
inline
std::ostream& initComments ( )
inline

Add comment lines to the init block with this stream.

Definition at line 3161 of file LHEF.h.

References Writer::initStream.

bool openeventfile ( int  ifile)
inline

Open a new event file, possibly closing a previous opened one.

Definition at line 3185 of file LHEF.h.

References Writer::curreventfile, Writer::currfileevent, Writer::dirpath, Writer::efile, HEPRUP::eventfiles, Writer::file, EventFile::filename, Writer::heprup, and EventFile::neve.

Writer& operator= ( const Writer )
private

The Writer cannot be assigned to.

void writeEvent ( )
inline
void writeinit ( )
inline

Write out an optional header block followed by the standard init block information together with any comment lines.

Definition at line 3214 of file LHEF.h.

References Writer::file, Writer::headerStream, Writer::heprup, HEPRUP::print(), and HEPRUP::version.

Field Documentation

int curreventfile
protected

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

Definition at line 3294 of file LHEF.h.

int currfileevent
protected

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

Definition at line 3299 of file LHEF.h.

std::string dirpath
protected

The directory from where we are reading files.

Definition at line 3304 of file LHEF.h.

std::ofstream efile
protected

A separate stream for reading multi-file runs.

Definition at line 3283 of file LHEF.h.

std::ostringstream eventStream

Stream to add additional comments to be written together the next event.

Definition at line 3331 of file LHEF.h.

std::ostream* file
protected

The stream we are writing to. This may be a reference to an external stream or the internal intstream.

Definition at line 3273 of file LHEF.h.

std::ostringstream headerStream

Stream to add all lines in the header block.

Definition at line 3311 of file LHEF.h.

HEPEUP hepeup

The standard information about the event we will write next.

Examples:
LHEF_example_cat.cc.

Definition at line 3326 of file LHEF.h.

HEPRUP heprup

The standard init information.

Examples:
LHEF_example_cat.cc.

Definition at line 3316 of file LHEF.h.

std::ostream* initfile
protected

The original stream from where we read the init block.

Definition at line 3278 of file LHEF.h.

std::ostringstream initStream

Stream to add additional comments to be put in the init block.

Definition at line 3321 of file LHEF.h.

std::ofstream intstream
protected

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

Definition at line 3267 of file LHEF.h.

int lastevent
protected

The number of the last event written (starting from 1).

Definition at line 3288 of file LHEF.h.


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