HepMC3 event record library
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 3099 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 headerBlock (const std::string &a)
 
void initComments (const std::string &a)
 
void eventComments (const std::string &a)
 
void init ()
 
bool openeventfile (int ifile)
 
void writeinit ()
 
void writeEvent ()
 

Data Fields

HEPRUP heprup
 
HEPEUP hepeup
 

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 &)
 

Private Attributes

std::ostringstream headerStream
 
std::ostringstream initStream
 
std::ostringstream eventStream
 

Constructor & Destructor Documentation

◆ Writer() [1/4]

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 3107 of file LHEF.h.

References curreventfile, currfileevent, dirpath, file, initfile, and lastevent.

◆ Writer() [2/4]

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 3115 of file LHEF.h.

References curreventfile, currfileevent, dirpath, file, initfile, intstream, and lastevent.

◆ ~Writer()

~Writer ( )
inline

The destructor writes out the final XML end-tag.

Definition at line 3125 of file LHEF.h.

References curreventfile, currfileevent, file, heprup, initfile, and writeinit().

◆ Writer() [3/4]

Writer ( )
private

The default constructor should never be used.

◆ Writer() [4/4]

Writer ( const Writer & )
private

The copy constructor should never be used.

References Writer().

Member Function Documentation

◆ eventComments() [1/2]

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 3153 of file LHEF.h.

References eventStream.

◆ eventComments() [2/2]

void eventComments ( const std::string & a)
inline

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

Definition at line 3173 of file LHEF.h.

References eventStream.

◆ headerBlock() [1/2]

std::ostream & headerBlock ( )
inline

Add header lines consisting of XML code with this stream.

Examples
LHEF_example_cat.cc.

Definition at line 3139 of file LHEF.h.

References headerStream.

◆ headerBlock() [2/2]

void headerBlock ( const std::string & a)
inline

Add header lines consisting of XML code with this stream.

Definition at line 3159 of file LHEF.h.

References headerStream.

◆ init()

void init ( )
inline

Initialize the writer.

Examples
LHEF_example_cat.cc.

Definition at line 3180 of file LHEF.h.

References curreventfile, currfileevent, heprup, lastevent, openeventfile(), and writeinit().

◆ initComments() [1/2]

std::ostream & initComments ( )
inline

Add comment lines to the init block with this stream.

Definition at line 3146 of file LHEF.h.

References initStream.

◆ initComments() [2/2]

void initComments ( const std::string & a)
inline

Add comment lines to the init block with this stream.

Definition at line 3166 of file LHEF.h.

References initStream.

◆ openeventfile()

bool openeventfile ( int ifile)
inline

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

Definition at line 3190 of file LHEF.h.

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

◆ operator=()

Writer & operator= ( const Writer & )
private

The Writer cannot be assigned to.

References Writer().

◆ writeEvent()

void writeEvent ( )
inline

Write the current HEPEUP object to the stream;

Examples
LHEF_example_cat.cc.

Definition at line 3250 of file LHEF.h.

References curreventfile, currfileevent, file, hepeup, heprup, lastevent, and openeventfile().

◆ writeinit()

void writeinit ( )
inline

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

Definition at line 3219 of file LHEF.h.

References file, headerStream, and heprup.

Field Documentation

◆ curreventfile

int curreventfile
protected

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

Definition at line 3297 of file LHEF.h.

◆ currfileevent

int currfileevent
protected

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

Definition at line 3302 of file LHEF.h.

◆ dirpath

std::string dirpath
protected

The directory from where we are reading files.

Definition at line 3307 of file LHEF.h.

◆ efile

std::ofstream efile
protected

A separate stream for reading multi-file runs.

Definition at line 3286 of file LHEF.h.

◆ eventStream

std::ostringstream eventStream
private

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

Definition at line 3338 of file LHEF.h.

◆ file

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 3276 of file LHEF.h.

◆ headerStream

std::ostringstream headerStream
private

Stream to add all lines in the header block.

Definition at line 3328 of file LHEF.h.

◆ hepeup

HEPEUP hepeup

The standard information about the event we will write next.

Examples
LHEF_example_cat.cc.

Definition at line 3319 of file LHEF.h.

◆ heprup

HEPRUP heprup

The standard init information.

Examples
LHEF_example_cat.cc.

Definition at line 3313 of file LHEF.h.

◆ initfile

std::ostream* initfile
protected

The original stream from where we read the init block.

Definition at line 3281 of file LHEF.h.

◆ initStream

std::ostringstream initStream
private

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

Definition at line 3333 of file LHEF.h.

◆ intstream

std::ofstream intstream
protected

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

Definition at line 3270 of file LHEF.h.

◆ lastevent

int lastevent
protected

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

Definition at line 3291 of file LHEF.h.


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