HepMC3 event record library
|
GenEvent I/O parsing for structured text files. More...
#include <ReaderAscii.h>
Public Member Functions | |
ReaderAscii (const std::string &filename) | |
Constructor. More... | |
ReaderAscii (std::istream &) | |
The ctor to read from stdin. More... | |
~ReaderAscii () | |
Destructor. More... | |
bool | skip (const int) override |
skip events More... | |
bool | read_event (GenEvent &evt) override |
Load event from file. More... | |
bool | failed () override |
Return status of the stream. More... | |
void | close () override |
Close file stream. More... | |
std::shared_ptr< GenRunInfo > | run_info () const |
Get the global GenRunInfo object. More... | |
void | set_options (const std::map< std::string, std::string > &options) |
Set options. More... | |
std::map< std::string, std::string > | get_options () const |
Set options. More... | |
Protected Member Functions | |
void | set_run_info (std::shared_ptr< GenRunInfo > run) |
Set the global GenRunInfo object. More... | |
Protected Attributes | |
std::map< std::string, std::string > | m_options |
options More... | |
Private Member Functions | |
std::string | unescape (const std::string &s) |
Unsecape '\' and ' ' characters in string. More... | |
Read helpers | |
std::pair< int, int > | parse_event_information (GenEvent &evt, const char *buf) |
Parse event. More... | |
bool | parse_weight_values (GenEvent &evt, const char *buf) |
Parse weight value lines. More... | |
bool | parse_units (GenEvent &evt, const char *buf) |
Parse units. More... | |
bool | parse_pdf_info (GenEvent &evt, const char *buf) |
Parse struct GenPdfInfo information. More... | |
bool | parse_heavy_ion (GenEvent &evt, const char *buf) |
Parse struct GenHeavyIon information. More... | |
bool | parse_cross_section (GenEvent &evt, const char *buf) |
Parse struct GenCrossSection information. More... | |
bool | parse_vertex_information (GenEvent &evt, const char *buf) |
Parse vertex. More... | |
bool | parse_particle_information (GenEvent &evt, const char *buf) |
Parse particle. More... | |
bool | parse_attribute (GenEvent &evt, const char *buf) |
Parse attribute. More... | |
bool | parse_run_attribute (const char *buf) |
Parse run-level attribute. More... | |
bool | parse_weight_names (const char *buf) |
Parse run-level weight names. More... | |
bool | parse_tool (const char *buf) |
Parse run-level tool information. More... | |
Private Attributes | |
std::ifstream | m_file |
Input file. More... | |
std::istream * | m_stream |
For ctor when reading from stdin. More... | |
bool | m_isstream |
toggles usage of m_file or m_stream More... | |
std::map< std::string, std::shared_ptr< Attribute > > | m_global_attributes |
Store attributes global to the run being written/read. More... | |
std::map< GenVertexPtr, std::set< int > > | m_forward_mothers |
Temp storage for outgoing particle ids. More... | |
std::map< GenParticlePtr, int > | m_forward_daughters |
Temp storage for prod vertex ids. More... | |
GenEvent I/O parsing for structured text files.
Definition at line 29 of file ReaderAscii.h.
ReaderAscii | ( | const std::string & | filename | ) |
Constructor.
Definition at line 22 of file ReaderAscii.cc.
References HEPMC3_ERROR, ReaderAscii::m_file, and Reader::set_run_info().
ReaderAscii | ( | std::istream & | stream | ) |
The ctor to read from stdin.
Definition at line 33 of file ReaderAscii.cc.
References HEPMC3_ERROR, ReaderAscii::m_stream, and Reader::set_run_info().
~ReaderAscii | ( | ) |
Destructor.
Definition at line 44 of file ReaderAscii.cc.
References ReaderAscii::close(), and ReaderAscii::m_isstream.
|
overridevirtual |
Close file stream.
Implements Reader.
Definition at line 555 of file ReaderAscii.cc.
References ReaderAscii::m_file.
|
overridevirtual |
Return status of the stream.
Implements Reader.
Definition at line 553 of file ReaderAscii.cc.
References ReaderAscii::m_file, ReaderAscii::m_isstream, and ReaderAscii::m_stream.
|
inlineinherited |
|
private |
Parse attribute.
Helper routine for parsing single attribute information
[out] | evt | Event that will contain parsed attribute |
[in] | buf | Line of text that needs to be parsed |
Definition at line 451 of file ReaderAscii.cc.
References GenEvent::add_attribute(), and ReaderAscii::unescape().
|
private |
Parse struct GenCrossSection information.
Helper routine for parsing cross-section information
[out] | evt | Event that will be filled with unit information |
[in] | buf | Line of text that needs to be parsed |
|
private |
Parse event.
Helper routine for parsing event information
[out] | evt | Event that will be filled with new data |
[in] | buf | Line of text that needs to be parsed |
Definition at line 206 of file ReaderAscii.cc.
References HEPMC3_DEBUG, GenEvent::set_event_number(), FourVector::setT(), FourVector::setX(), FourVector::setY(), FourVector::setZ(), and GenEvent::shift_position_to().
|
private |
Parse struct GenHeavyIon information.
Helper routine for parsing heavy ion information
[out] | evt | Event that will be filled with unit information |
[in] | buf | Line of text that needs to be parsed |
|
private |
Parse particle.
Helper routine for parsing single particle information
[out] | evt | Event that will contain parsed particle |
[in] | buf | Line of text that needs to be parsed |
Definition at line 363 of file ReaderAscii.cc.
References GenEvent::add_particle(), GenEvent::add_vertex(), HEPMC3_DEBUG, HEPMC3_ERROR, ReaderAscii::m_forward_daughters, GenEvent::particles(), and GenEvent::vertices().
|
private |
Parse struct GenPdfInfo information.
Helper routine for parsing PDF information
[out] | evt | Event that will be filled with unit information |
[in] | buf | Line of text that needs to be parsed |
|
private |
Parse run-level attribute.
Helper routine for parsing single attribute information
[in] | buf | Line of text that needs to be parsed |
Definition at line 476 of file ReaderAscii.cc.
References Reader::run_info(), and ReaderAscii::unescape().
|
private |
Parse run-level tool information.
Helper routine for parsing a line with information about tools being used.
[in] | buf | Line of text that needs to be parsed |
Definition at line 516 of file ReaderAscii.cc.
References GenRunInfo::ToolInfo::description, GenRunInfo::ToolInfo::name, Reader::run_info(), ReaderAscii::unescape(), and GenRunInfo::ToolInfo::version.
|
private |
Parse units.
Helper routine for parsing units information
[out] | evt | Event that will be filled with unit information |
[in] | buf | Line of text that needs to be parsed |
Definition at line 270 of file ReaderAscii.cc.
References HEPMC3_DEBUG, Units::length_unit(), GenEvent::length_unit(), Units::momentum_unit(), GenEvent::momentum_unit(), Units::name(), and GenEvent::set_units().
|
private |
Parse vertex.
Helper routine for parsing single event information
[out] | evt | Event that will contain parsed vertex |
[in] | buf | Line of text that needs to be parsed |
Definition at line 291 of file ReaderAscii.cc.
References GenEvent::add_vertex(), HEPMC3_DEBUG, ReaderAscii::m_forward_mothers, and GenEvent::particles().
|
private |
Parse run-level weight names.
Helper routine for parsing a line with information about weight names.
[in] | buf | Line of text that needs to be parsed |
Definition at line 499 of file ReaderAscii.cc.
References Reader::run_info(), and ReaderAscii::unescape().
|
private |
Parse weight value lines.
Helper routine for parsing weight value information
[out] | evt | Event whose GenWeights will be filled with weight values |
[in] | buf | Line of text that needs to be parsed |
Definition at line 253 of file ReaderAscii.cc.
References Reader::run_info(), and GenEvent::weights().
|
overridevirtual |
Load event from file.
[out] | evt | Event to be filled |
Implements Reader.
Definition at line 63 of file ReaderAscii.cc.
References GenEvent::clear(), ReaderAscii::failed(), HEPMC3_DEBUG, HEPMC3_ERROR, HEPMC3_WARNING, ReaderAscii::m_file, ReaderAscii::m_forward_daughters, ReaderAscii::m_forward_mothers, ReaderAscii::m_isstream, ReaderAscii::m_stream, ReaderAscii::parse_attribute(), ReaderAscii::parse_event_information(), ReaderAscii::parse_particle_information(), ReaderAscii::parse_run_attribute(), ReaderAscii::parse_tool(), ReaderAscii::parse_units(), ReaderAscii::parse_vertex_information(), ReaderAscii::parse_weight_names(), ReaderAscii::parse_weight_values(), GenEvent::particles(), Reader::run_info(), GenEvent::set_run_info(), and GenEvent::vertices().
|
inlineinherited |
Get the global GenRunInfo object.
Definition at line 44 of file Reader.h.
References Reader::m_run_info.
|
inlineinherited |
|
inlineprotectedinherited |
Set the global GenRunInfo object.
Definition at line 64 of file Reader.h.
References Reader::m_run_info.
|
overridevirtual |
skip events
Reimplemented from Reader.
Definition at line 46 of file ReaderAscii.cc.
References ReaderAscii::failed(), ReaderAscii::m_file, ReaderAscii::m_isstream, and ReaderAscii::m_stream.
|
private |
Unsecape '\' and '
' characters in string.
Definition at line 536 of file ReaderAscii.cc.
|
private |
Input file.
Definition at line 156 of file ReaderAscii.h.
|
private |
Temp storage for prod vertex ids.
Definition at line 167 of file ReaderAscii.h.
|
private |
Temp storage for outgoing particle ids.
Definition at line 165 of file ReaderAscii.h.
|
private |
Store attributes global to the run being written/read.
Definition at line 162 of file ReaderAscii.h.
|
private |
toggles usage of m_file or m_stream
Definition at line 158 of file ReaderAscii.h.
|
protectedinherited |
|
private |
For ctor when reading from stdin.
Definition at line 157 of file ReaderAscii.h.