HepMC event record
|
GenEvent I/O serialization for structured text files.
Definition at line 25 of file build/outputs/include/HepMC/WriterAscii.h.
#include <WriterAscii.h>
Public Member Functions | |
WriterAscii (const std::string &filename, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >()) | |
Constructor. More... | |
WriterAscii (std::ostream &stream, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >()) | |
Constructor from ostream. More... | |
~WriterAscii () | |
Destructor. More... | |
void | write_event (const GenEvent &evt) |
Write event to file. More... | |
void | write_run_info () |
Write the GenRunInfo object to file. More... | |
bool | failed () |
Return status of the stream. More... | |
void | close () |
Close file stream. More... | |
void | set_precision (size_t prec) |
Set output precision. More... | |
WriterAscii (const std::string &filename, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >()) | |
Constructor. More... | |
WriterAscii (std::ostream &stream, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >()) | |
Constructor from ostream. More... | |
~WriterAscii () | |
Destructor. More... | |
void | write_event (const GenEvent &evt) |
Write event to file. More... | |
void | write_run_info () |
Write the GenRunInfo object to file. More... | |
bool | failed () |
Return status of the stream. More... | |
void | close () |
Close file stream. More... | |
void | set_precision (size_t prec) |
Set output precision. More... | |
void | set_run_info (shared_ptr< GenRunInfo > run) |
Set the global GenRunInfo object. More... | |
void | set_run_info (shared_ptr< GenRunInfo > run) |
Set the global GenRunInfo object. More... | |
shared_ptr< GenRunInfo > | run_info () const |
Get the global GenRunInfo object. More... | |
shared_ptr< GenRunInfo > | run_info () const |
Get the global GenRunInfo object. More... | |
Private Member Functions | |
Buffer management | |
void | allocate_buffer () |
Attempts to allocate buffer of the chosen size. More... | |
void | set_buffer_size (size_t size) |
Set buffer size (in bytes) More... | |
std::string | escape (const std::string s) |
Escape '\' and ' ' characters in string. More... | |
void | flush () |
Inline function flushing buffer to output stream when close to buffer capacity. More... | |
void | forced_flush () |
Inline function forcing flush to the output stream. More... | |
void | allocate_buffer () |
Attempts to allocate buffer of the chosen size. More... | |
void | set_buffer_size (size_t size) |
Set buffer size (in bytes) More... | |
std::string | escape (const std::string s) |
Escape '\' and ' ' characters in string. More... | |
void | flush () |
Inline function flushing buffer to output stream when close to buffer capacity. More... | |
void | forced_flush () |
Inline function forcing flush to the output stream. More... | |
Write helpers | |
void | write_string (const std::string &str) |
Inline function for writing strings. More... | |
void | write_vertex (const GenVertexPtr &v) |
Write vertex. More... | |
void | write_particle (const GenParticlePtr &p, int second_field) |
Write particle. More... | |
void | write_string (const std::string &str) |
Inline function for writing strings. More... | |
void | write_vertex (const GenVertexPtr &v) |
Write vertex. More... | |
void | write_particle (const GenParticlePtr &p, int second_field) |
Write particle. More... | |
Private Attributes | |
std::ofstream | m_file |
Output file. More... | |
std::ostream * | m_stream |
Output stream. More... | |
int | m_precision |
Output precision. More... | |
char * | m_buffer |
Stream buffer. More... | |
char * | m_cursor |
Cursor inside stream buffer. More... | |
unsigned long | m_buffer_size |
Buffer size. More... | |
WriterAscii | ( | const std::string & | filename, |
shared_ptr< GenRunInfo > | run = shared_ptr<GenRunInfo>() |
||
) |
Constructor.
Definition at line 22 of file WriterAscii.cc.
References WriterAscii::m_file, Writer::run_info(), Writer::set_run_info(), HepMC::version(), and WriterAscii::write_run_info().
WriterAscii | ( | std::ostream & | stream, |
shared_ptr< GenRunInfo > | run = shared_ptr<GenRunInfo>() |
||
) |
Constructor from ostream.
Definition at line 41 of file WriterAscii.cc.
References Writer::run_info(), Writer::set_run_info(), HepMC::version(), and WriterAscii::write_run_info().
~WriterAscii | ( | ) |
Destructor.
Definition at line 62 of file WriterAscii.cc.
References WriterAscii::close(), and WriterAscii::m_buffer.
WriterAscii | ( | const std::string & | filename, |
shared_ptr< GenRunInfo > | run = shared_ptr< GenRunInfo >() |
||
) |
Constructor.
WriterAscii | ( | std::ostream & | stream, |
shared_ptr< GenRunInfo > | run = shared_ptr< GenRunInfo >() |
||
) |
Constructor from ostream.
~WriterAscii | ( | ) |
Destructor.
|
private |
Attempts to allocate buffer of the chosen size.
This function can be called manually by the user or will be called before first read/write operation
Definition at line 177 of file WriterAscii.cc.
References WriterAscii::m_buffer, WriterAscii::m_buffer_size, and WriterAscii::m_cursor.
|
private |
Attempts to allocate buffer of the chosen size.
This function can be called manually by the user or will be called before first read/write operation
|
virtual |
Close file stream.
Implements Writer.
|
virtual |
Close file stream.
Implements Writer.
Definition at line 352 of file WriterAscii.cc.
References WriterAscii::forced_flush(), and WriterAscii::m_stream.
|
private |
Escape '\' and '
' characters in string.
Definition at line 196 of file WriterAscii.cc.
|
private |
Escape '\' and '
' characters in string.
|
inlinevirtual |
Return status of the stream.
Implements Writer.
Definition at line 49 of file build/outputs/include/HepMC/WriterAscii.h.
References WriterAscii::m_file.
|
inlinevirtual |
Return status of the stream.
Implements Writer.
Definition at line 49 of file include/HepMC/WriterAscii.h.
References WriterAscii::m_file.
|
inlineprivate |
Inline function flushing buffer to output stream when close to buffer capacity.
Definition at line 245 of file WriterAscii.cc.
References WriterAscii::m_buffer, WriterAscii::m_buffer_size, WriterAscii::m_cursor, and WriterAscii::m_stream.
|
private |
Inline function flushing buffer to output stream when close to buffer capacity.
|
inlineprivate |
Inline function forcing flush to the output stream.
Definition at line 258 of file WriterAscii.cc.
References WriterAscii::m_buffer, WriterAscii::m_cursor, and WriterAscii::m_stream.
|
private |
Inline function forcing flush to the output stream.
|
inlineinherited |
Get the global GenRunInfo object.
Definition at line 42 of file build/outputs/include/HepMC/Writer.h.
References Writer::m_run_info.
|
inlineinherited |
Get the global GenRunInfo object.
Definition at line 42 of file include/HepMC/Writer.h.
References Writer::m_run_info.
|
inlineprivate |
Set buffer size (in bytes)
Default is 256kb. Minimum is 256b. Size can only be changed before first read/write operation.
Definition at line 80 of file include/HepMC/WriterAscii.h.
References WriterAscii::m_buffer, and WriterAscii::m_buffer_size.
|
inlineprivate |
Set buffer size (in bytes)
Default is 256kb. Minimum is 256b. Size can only be changed before first read/write operation.
Definition at line 80 of file build/outputs/include/HepMC/WriterAscii.h.
References WriterAscii::m_buffer, and WriterAscii::m_buffer_size.
|
inline |
Set output precision.
Available range is [2,24]. Default is 16.
Definition at line 57 of file include/HepMC/WriterAscii.h.
References WriterAscii::m_precision.
|
inline |
Set output precision.
Available range is [2,24]. Default is 16.
Definition at line 57 of file build/outputs/include/HepMC/WriterAscii.h.
References WriterAscii::m_precision.
|
inlineinherited |
Set the global GenRunInfo object.
Definition at line 37 of file include/HepMC/Writer.h.
References Writer::m_run_info.
|
inlineinherited |
Set the global GenRunInfo object.
Definition at line 37 of file build/outputs/include/HepMC/Writer.h.
References Writer::m_run_info.
|
virtual |
Write event to file.
[in] | evt | Event to be serialized |
Implements Writer.
Definition at line 68 of file WriterAscii.cc.
References WriterAscii::allocate_buffer(), GenEvent::attributes(), WriterAscii::escape(), GenEvent::event_number(), GenEvent::event_pos(), WriterAscii::flush(), WriterAscii::forced_flush(), FourVector::is_zero(), GenEvent::length_unit(), WriterAscii::m_buffer, WriterAscii::m_cursor, WriterAscii::m_precision, GenEvent::momentum_unit(), Units::name(), GenEvent::particles(), Writer::run_info(), GenEvent::run_info(), Writer::set_run_info(), FourVector::t(), GenEvent::vertices(), GenEvent::weights(), WriterAscii::write_particle(), WriterAscii::write_run_info(), WriterAscii::write_string(), WriterAscii::write_vertex(), FourVector::x(), FourVector::y(), and FourVector::z().
|
virtual |
|
private |
Write particle.
Helper routine for writing single particle to file
|
private |
Write particle.
Helper routine for writing single particle to file
Definition at line 309 of file WriterAscii.cc.
References WriterAscii::flush(), WriterAscii::m_cursor, and WriterAscii::m_precision.
void write_run_info | ( | ) |
Write the GenRunInfo object to file.
Definition at line 265 of file WriterAscii.cc.
References WriterAscii::allocate_buffer(), WriterAscii::escape(), WriterAscii::flush(), WriterAscii::m_cursor, Writer::run_info(), Writer::set_run_info(), and WriterAscii::write_string().
void write_run_info | ( | ) |
Write the GenRunInfo object to file.
|
inlineprivate |
Inline function for writing strings.
Since strings can be long (maybe even longer than buffer) they have to be dealt with separately.
Definition at line 333 of file WriterAscii.cc.
References WriterAscii::flush(), WriterAscii::forced_flush(), WriterAscii::m_buffer, WriterAscii::m_buffer_size, WriterAscii::m_cursor, and WriterAscii::m_stream.
|
private |
Inline function for writing strings.
Since strings can be long (maybe even longer than buffer) they have to be dealt with separately.
|
private |
Write vertex.
Helper routine for writing single vertex to file
Definition at line 209 of file WriterAscii.cc.
References WriterAscii::flush(), FourVector::is_zero(), WriterAscii::m_cursor, WriterAscii::m_precision, FourVector::t(), FourVector::x(), FourVector::y(), and FourVector::z().
|
private |
Write vertex.
Helper routine for writing single vertex to file
|
private |
Stream buffer.
Definition at line 124 of file build/outputs/include/HepMC/WriterAscii.h.
|
private |
Buffer size.
Definition at line 126 of file build/outputs/include/HepMC/WriterAscii.h.
|
private |
Cursor inside stream buffer.
Definition at line 125 of file build/outputs/include/HepMC/WriterAscii.h.
|
private |
Output file.
Definition at line 121 of file build/outputs/include/HepMC/WriterAscii.h.
|
private |
Output precision.
Definition at line 123 of file build/outputs/include/HepMC/WriterAscii.h.
|
private |
Output stream.
Definition at line 122 of file build/outputs/include/HepMC/WriterAscii.h.