HepMC3 event record library
Public Member Functions | Data Fields | Protected Attributes | Private Member Functions | Private Attributes
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 3090 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 3098 of file LHEF.h.

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

References Writer::dirpath.

◆ ~Writer()

~Writer ( )
inline

The destructor writes out the final XML end-tag.

Definition at line 3116 of file LHEF.h.

References Writer::curreventfile, Writer::currfileevent, HEPRUP::eventfiles, Writer::file, Writer::heprup, Writer::initfile, and Writer::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.

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

References Writer::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 3164 of file LHEF.h.

References Writer::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 3130 of file LHEF.h.

References Writer::headerStream.

◆ headerBlock() [2/2]

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

Add header lines consisting of XML code with this stream.

Definition at line 3150 of file LHEF.h.

References Writer::headerStream.

◆ init()

void init ( )
inline

◆ initComments() [1/2]

std::ostream & initComments ( )
inline

Add comment lines to the init block with this stream.

Definition at line 3137 of file LHEF.h.

References Writer::initStream.

◆ initComments() [2/2]

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

Add comment lines to the init block with this stream.

Definition at line 3157 of file LHEF.h.

References Writer::initStream.

◆ openeventfile()

bool openeventfile ( int  ifile)
inline

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

Definition at line 3181 of file LHEF.h.

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

◆ operator=()

Writer & operator= ( const Writer )
private

The Writer cannot be assigned to.

◆ writeEvent()

void writeEvent ( )
inline

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

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

Field Documentation

◆ curreventfile

int curreventfile
protected

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

Definition at line 3288 of file LHEF.h.

◆ currfileevent

int currfileevent
protected

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

Definition at line 3293 of file LHEF.h.

◆ dirpath

std::string dirpath
protected

The directory from where we are reading files.

Definition at line 3298 of file LHEF.h.

◆ efile

std::ofstream efile
protected

A separate stream for reading multi-file runs.

Definition at line 3277 of file LHEF.h.

◆ eventStream

std::ostringstream eventStream
private

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

Definition at line 3329 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 3267 of file LHEF.h.

◆ headerStream

std::ostringstream headerStream
private

Stream to add all lines in the header block.

Definition at line 3319 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 3310 of file LHEF.h.

◆ heprup

HEPRUP heprup

The standard init information.

Examples
LHEF_example_cat.cc.

Definition at line 3304 of file LHEF.h.

◆ initfile

std::ostream* initfile
protected

The original stream from where we read the init block.

Definition at line 3272 of file LHEF.h.

◆ initStream

std::ostringstream initStream
private

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

Definition at line 3324 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 3261 of file LHEF.h.

◆ lastevent

int lastevent
protected

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

Definition at line 3282 of file LHEF.h.


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