HepMC3 event record library
|
GenEvent I/O serialization for protobuf-based binary files.
If HepMC was compiled with protobuf available, this class can be used for writing in the same manner as with HepMC::WriterAscii class.
Definition at line 32 of file Writerprotobuf.h.
#include <Writerprotobuf.h>
Public Member Functions | |
Writerprotobuf (const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >()) | |
New file constructor. | |
Writerprotobuf (std::ostream &out_stream, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >()) | |
ostream constructor | |
Writerprotobuf (std::shared_ptr< std::ostream > out_stream, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >()) | |
ostream constructor | |
void | write_event (const GenEvent &evt) override |
Write event to file. | |
void | close () override |
Close file stream. | |
bool | failed () override |
Get stream error state flag. | |
virtual | ~Writerprotobuf () |
Standard destructor. | |
void | write_run_info () |
Write the GenRunInfo object to file. | |
virtual void | set_run_info (std::shared_ptr< GenRunInfo > run) |
Set the global GenRunInfo object. | |
virtual std::shared_ptr< GenRunInfo > | run_info () const |
Get the global GenRunInfo object. | |
virtual void | set_options (const std::map< std::string, std::string > &options) |
Set options. | |
virtual std::map< std::string, std::string > | get_options () const |
Set options. | |
Protected Attributes | |
std::map< std::string, std::string > | m_options |
options | |
Private Member Functions | |
void | start_file () |
Write non-event front matter to the output stream. | |
Private Attributes | |
std::unique_ptr< std::ofstream > | m_out_file |
The output file stream. | |
std::ostream * | m_out_stream |
The stream object that is written to. | |
size_t | m_events_written |
The number of events written to the stream. | |
size_t | m_event_bytes_written |
The number of event bytes written to the stream. | |
std::shared_ptr< GenRunInfo > | m_run_info |
The global GenRunInfo object. | |
Writerprotobuf | ( | const std::string & | filename, |
std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() ) |
New file constructor.
Definition at line 59 of file Writerprotobuf.cc.
References HEPMC3_ERROR, m_event_bytes_written, m_events_written, m_out_file, m_out_stream, Writer::set_run_info(), and start_file().
Writerprotobuf | ( | std::ostream & | out_stream, |
std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() ) |
ostream constructor
Attempts to write a binary HepMC3 protobuf event stream to the passed ostream object
Definition at line 82 of file Writerprotobuf.cc.
References m_event_bytes_written, m_events_written, m_out_file, m_out_stream, Writer::set_run_info(), and start_file().
Writerprotobuf | ( | std::shared_ptr< std::ostream > | out_stream, |
std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() ) |
ostream constructor
Attempts to write a binary HepMC3 protobuf event stream to the passed ostream object
Definition at line 101 of file Writerprotobuf.cc.
References Writerprotobuf().
|
inlinevirtual |
|
overridevirtual |
Close file stream.
Implements Writer.
Definition at line 248 of file Writerprotobuf.cc.
References failed(), HEPMC3_ERROR, m_event_bytes_written, m_events_written, m_out_file, m_out_stream, and HepMC3::write_message().
|
overridevirtual |
Get stream error state flag.
Implements Writer.
Definition at line 270 of file Writerprotobuf.cc.
References m_out_file, and m_out_stream.
|
inlinevirtualinherited |
Set options.
Reimplemented in WriterPlugin.
Definition at line 54 of file Writer.h.
References m_options.
|
inlinevirtualinherited |
Get the global GenRunInfo object.
Reimplemented in WriterPlugin.
Definition at line 45 of file Writer.h.
References m_run_info.
|
inlinevirtualinherited |
Set options.
Reimplemented in WriterPlugin.
Definition at line 52 of file Writer.h.
References m_options.
|
inlinevirtualinherited |
Set the global GenRunInfo object.
Reimplemented in WriterPlugin.
Definition at line 42 of file Writer.h.
References m_run_info.
|
private |
Write non-event front matter to the output stream.
Definition at line 105 of file Writerprotobuf.cc.
References m_out_stream, HepMC3::ProtobufMagicHeader, HepMC3::version(), HepMC3::write_message(), and write_run_info().
|
overridevirtual |
Write event to file.
[in] | evt | Event to be serialized |
Implements Writer.
Definition at line 125 of file Writerprotobuf.cc.
References GenEventData::attribute_id, GenEventData::attribute_name, GenEventData::attribute_string, GenEventData::event_number, GenEventData::event_pos, HEPMC3_ERROR, GenEventData::length_unit, GenEventData::links1, GenEventData::links2, m_event_bytes_written, m_events_written, m_out_stream, GenEventData::momentum_unit, GenEventData::particles, FourVector::t(), GenEventData::vertices, GenEventData::weights, GenEvent::write_data(), HepMC3::write_message(), FourVector::x(), FourVector::y(), and FourVector::z().
void write_run_info | ( | ) |
Write the GenRunInfo object to file.
Definition at line 217 of file Writerprotobuf.cc.
References GenRunInfoData::attribute_name, GenRunInfoData::attribute_string, m_out_stream, Writer::run_info(), GenRunInfoData::tool_description, GenRunInfoData::tool_name, GenRunInfoData::tool_version, GenRunInfoData::weight_names, and HepMC3::write_message().
|
private |
The number of event bytes written to the stream.
Definition at line 105 of file Writerprotobuf.h.
|
private |
The number of events written to the stream.
Definition at line 103 of file Writerprotobuf.h.
|
protectedinherited |
|
private |
The output file stream.
This is non-null and owned by this class if the instance was constructed with the string constructor, it is null otherwise.
Definition at line 94 of file Writerprotobuf.h.
|
private |
The stream object that is written to.
If constructed with the string constructor, this just points to m_out_file.get())
Definition at line 100 of file Writerprotobuf.h.
|
privateinherited |
The global GenRunInfo object.