HepMC3 event record library: ReaderAsciiHepMC2 Class Reference

HepMC3 event record library

Public Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
ReaderAsciiHepMC2 Class Reference

## Detailed Description

Parser for HepMC2 I/O files.

Examples
  HepMC2_reader_example.cc.

Definition at line 30 of file ReaderAsciiHepMC2.h.

`#include <ReaderAsciiHepMC2.h>`

Inheritance diagram for ReaderAsciiHepMC2:
[legend]
Collaboration diagram for ReaderAsciiHepMC2:
[legend]

## Public Member Functions
| ReaderAsciiHepMC2 (const std::string &filename)
| Default constructor.
| ReaderAsciiHepMC2 (std::istream &)
| The ctor to read from stream.
| ReaderAsciiHepMC2 (std::shared_ptr< std::istream > s_stream)
| The ctor to read from temp stream.
| ~ReaderAsciiHepMC2 ()
| Destructor.
bool | skip (const int) override
| skip events
bool | read_event (GenEvent &evt) override
| Implementation of Reader::read_event.
bool | failed () override
| Return status of the stream.
void | close () override
| Close file stream.
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
| Get options.
virtual void | set_run_info (std::shared_ptr< GenRunInfo > run)
| Set the global GenRunInfo object.

## Protected Attributes
std::map< std::string, std::string > | m_options
| Options.

## Private Member Functions
int | parse_vertex_information (const char *buf)
| Parse vertex.
int | parse_particle_information (const char *buf)
| Parse particle.
bool | parse_weight_names (const char *buf)
| Parse weight names.
bool | parse_xs_info (GenEvent &evt, const char *buf)
| Parse pdf information.

## Static Private Member Functions
static int | parse_event_information (GenEvent &evt, const char *buf)
| Parse event.
static bool | parse_units (GenEvent &evt, const char *buf)
| Parse units.
static bool | parse_heavy_ion (GenEvent &evt, const char *buf)
| Parse heavy ion information.
static bool | parse_pdf_info (GenEvent &evt, const char *buf)
| Parse pdf information.

## Private Attributes
std::ifstream | m_file
| Input file.
std::shared_ptr< std::istream > | m_shared_stream = nullptr
| For ctor when reading from temp stream.
std::istream * | m_stream = nullptr
| For ctor when reading from stream.
bool | m_isstream
| toggles usage of m_file or m_stream
std::vector< GenVertexPtr > | m_vertex_cache
| Vertex cache.
std::vector< int > | m_vertex_barcodes
| Old vertex barcodes.
std::vector< GenParticlePtr > | m_particle_cache
| Particle cache.
std::vector< int > | m_end_vertex_barcodes
| Old end vertex barcodes.
GenEvent * | m_event_ghost = nullptr
| To save particle and verstex attributes.
std::vector< GenParticlePtr > | m_particle_cache_ghost
| Particle cache for attributes.
std::vector< GenVertexPtr > | m_vertex_cache_ghost
| Vertex cache for attributes.
std::shared_ptr< GenRunInfo > | m_run_info
| The global GenRunInfo object.

## Constructor & Destructor Documentation

## ◆ ReaderAsciiHepMC2() [1/3]

ReaderAsciiHepMC2 | ( | const std::string & | filename | ) |

Default constructor.

Definition at line 25 of file ReaderAsciiHepMC2.cc.

References m_event_ghost, m_file, m_isstream, and Reader::set_run_info().

## ◆ ReaderAsciiHepMC2() [2/3]

ReaderAsciiHepMC2 | ( | std::istream & | stream | ) |

The ctor to read from stream.

Definition at line 34 of file ReaderAsciiHepMC2.cc.

References m_event_ghost, m_isstream, m_stream, and Reader::set_run_info().

## ◆ ReaderAsciiHepMC2() [3/3]

ReaderAsciiHepMC2 | ( | std::shared_ptr< std::istream > | s_stream | ) |

The ctor to read from temp stream.

Definition at line 44 of file ReaderAsciiHepMC2.cc.

References m_event_ghost, m_isstream, m_shared_stream, m_stream, and Reader::set_run_info().

## ◆ ~ReaderAsciiHepMC2()

~ReaderAsciiHepMC2 | ( |  | ) |

Destructor.

Definition at line 55 of file ReaderAsciiHepMC2.cc.

References close(), m_event_ghost, and m_isstream.

## Member Function Documentation

## ◆ close()

void close | ( |  | ) |
| overridevirtual

Close file stream.

Implements Reader.

Examples
  HepMC2_reader_example.cc.

Definition at line 749 of file ReaderAsciiHepMC2.cc.

References m_event_ghost, and m_file.

## ◆ failed()

bool failed | ( |  | ) |
| overridevirtual

Return status of the stream.

Implements Reader.

Examples
  HepMC2_reader_example.cc.

Definition at line 747 of file ReaderAsciiHepMC2.cc.

References m_file, m_isstream, and m_stream.

## ◆ get_options()

virtual std::map< std::string, std::string > get_options | ( |  | ) | const
| inlinevirtualinherited

Get options.

Reimplemented in ReaderPlugin.

Definition at line 53 of file Reader.h.

References m_options.

## ◆ parse_event_information()

int parse_event_information | ( | GenEvent & | evt,
|  | const char * | buf )
| staticprivate

Parse event.

Helper routine for parsing event information

Parameters

  [out] | evt | Event that will be filled with new data
  [in] | buf | Line of text that needs to be parsed

Definition at line 343 of file ReaderAsciiHepMC2.cc.

References GenEvent::add_attribute(), GenEvent::event_number(), HEPMC3_DEBUG, GenEvent::set_event_number(), and GenEvent::weights().

## ◆ parse_heavy_ion()

bool parse_heavy_ion | ( | GenEvent & | evt,
|  | const char * | buf )
| staticprivate

Parse heavy ion information.

Helper routine for parsing heavy ion information

Parameters

  [out] | evt | Event that will be filled with new data
  [in] | buf | Line of text that needs to be parsed

Definition at line 657 of file ReaderAsciiHepMC2.cc.

References GenEvent::add_attribute().

## ◆ parse_particle_information()

int parse_particle_information | ( | const char * | buf | ) |
| private

Parse particle.

Helper routine for parsing single particle information

Parameters

  [in] | buf | Line of text that needs to be parsed

Note
  barcode is ignored

Definition at line 511 of file ReaderAsciiHepMC2.cc.

References HEPMC3_DEBUG, m_end_vertex_barcodes, m_event_ghost, m_particle_cache, m_particle_cache_ghost, m_vertex_barcodes, and m_vertex_cache.

## ◆ parse_pdf_info()

bool parse_pdf_info | ( | GenEvent & | evt,
|  | const char * | buf )
| staticprivate

Parse pdf information.

Helper routine for parsing pdf information

Parameters

  [out] | evt | Event that will be filled with new data
  [in] | buf | Line of text that needs to be parsed

Definition at line 708 of file ReaderAsciiHepMC2.cc.

References GenEvent::add_attribute().

## ◆ parse_units()

bool parse_units | ( | GenEvent & | evt,
|  | const char * | buf )
| staticprivate

Parse units.

Helper routine for parsing unit information

Parameters

  [out] | evt | Event that will be filled with unit information
  [in] | buf | Line of text that needs to be parsed

Definition at line 424 of file ReaderAsciiHepMC2.cc.

References HEPMC3_DEBUG, GenEvent::length_unit(), Units::length_unit(), GenEvent::momentum_unit(), Units::momentum_unit(), Units::name(), and GenEvent::set_units().

## ◆ parse_vertex_information()

int parse_vertex_information | ( | const char * | buf | ) |
| private

Parse vertex.

Helper routine for parsing single event information

Parameters

  [in] | buf | Line of text that needs to be parsed

Definition at line 444 of file ReaderAsciiHepMC2.cc.

References HEPMC3_DEBUG, m_event_ghost, m_vertex_barcodes, m_vertex_cache, and m_vertex_cache_ghost.

## ◆ parse_weight_names()

bool parse_weight_names | ( | const char * | buf | ) |
| private

Parse weight names.

Helper routine for parsing weight names

Parameters

  [in] | buf | Line of text that needs to be parsed

Definition at line 623 of file ReaderAsciiHepMC2.cc.

References Reader::run_info().

## ◆ parse_xs_info()

bool parse_xs_info | ( | GenEvent & | evt,
|  | const char * | buf )
| private

Parse pdf information.

Helper routine for parsing cross-section information

Parameters

  [out] | evt | Event that will be filled with new data
  [in] | buf | Line of text that needs to be parsed

Definition at line 603 of file ReaderAsciiHepMC2.cc.

References GenEvent::add_attribute(), Reader::m_options, and GenEvent::weights().

## ◆ read_event()

bool read_event | ( | GenEvent & | evt | ) |
| overridevirtual

Implementation of Reader::read_event.

HepMC2 files produced with Pythia8 are known to have wrong information about number of particles in vertex. Hence '<' sign

HepMC2 files produced with Pythia8 are known to have wrong information about number of particles in vertex. Hence '<' sign

Implements Reader.

Examples
  HepMC2_reader_example.cc.

Definition at line 72 of file ReaderAsciiHepMC2.cc.

References GenEvent::add_attribute(), GenEvent::add_tree(), GenEvent::attribute(), GenEvent::clear(), failed(), HEPMC3_DEBUG, HEPMC3_ERROR_LEVEL, HEPMC3_WARNING_LEVEL, m_end_vertex_barcodes, m_event_ghost, m_file, m_isstream, Reader::m_options, m_particle_cache, m_particle_cache_ghost, m_stream, m_vertex_barcodes, m_vertex_cache, m_vertex_cache_ghost, parse_event_information(), parse_heavy_ion(), parse_particle_information(), parse_pdf_info(), parse_units(), parse_vertex_information(), parse_weight_names(), parse_xs_info(), GenEvent::remove_attribute(), GenEvent::reserve(), Reader::run_info(), GenEvent::set_run_info(), and GenEvent::weights().

## ◆ run_info()

virtual std::shared_ptr< GenRunInfo > run_info | ( |  | ) | const
| inlinevirtualinherited

Get the global GenRunInfo object.

Reimplemented in ReaderGZ< T >, and ReaderPlugin.

Examples
  LHEF_example_cat.cc.

Definition at line 44 of file Reader.h.

References m_run_info.

## ◆ set_options()

virtual void set_options | ( | const std::map< std::string, std::string > & | options | ) |
| inlinevirtualinherited

Set options.

Reimplemented in ReaderPlugin.

Definition at line 51 of file Reader.h.

References m_options.

## ◆ set_run_info()

virtual void set_run_info | ( | std::shared_ptr< GenRunInfo > | run | ) |
| inlinevirtualinherited

Set the global GenRunInfo object.

Reimplemented in ReaderGZ< T >, and ReaderPlugin.

Definition at line 56 of file Reader.h.

References m_run_info.

## ◆ skip()

bool skip | ( | const int | n | ) |
| overridevirtual

skip events

Reimplemented from Reader.

Definition at line 57 of file ReaderAsciiHepMC2.cc.

References failed(), m_file, m_isstream, and m_stream.

## Field Documentation

## ◆ m_end_vertex_barcodes

std::vector<int> m_end_vertex_barcodes
| private

Old end vertex barcodes.

Definition at line 140 of file ReaderAsciiHepMC2.h.

## ◆ m_event_ghost

GenEvent* m_event_ghost = nullptr
| private

To save particle and verstex attributes.

Definition at line 142 of file ReaderAsciiHepMC2.h.

## ◆ m_file

std::ifstream m_file
| private

Input file.

Definition at line 131 of file ReaderAsciiHepMC2.h.

## ◆ m_isstream

bool m_isstream
| private

toggles usage of m_file or m_stream

Definition at line 134 of file ReaderAsciiHepMC2.h.

## ◆ m_options

std::map<std::string, std::string> m_options
| protectedinherited

Options.

Definition at line 60 of file Reader.h.

## ◆ m_particle_cache

std::vector<GenParticlePtr> m_particle_cache
| private

Particle cache.

Definition at line 139 of file ReaderAsciiHepMC2.h.

## ◆ m_particle_cache_ghost

std::vector<GenParticlePtr> m_particle_cache_ghost
| private

Particle cache for attributes.

Definition at line 143 of file ReaderAsciiHepMC2.h.

## ◆ m_run_info

std::shared_ptr<GenRunInfo> m_run_info
| privateinherited

The global GenRunInfo object.

Definition at line 63 of file Reader.h.

## ◆ m_shared_stream

std::shared_ptr<std::istream> m_shared_stream = nullptr
| private

For ctor when reading from temp stream.

Definition at line 132 of file ReaderAsciiHepMC2.h.

## ◆ m_stream

std::istream* m_stream = nullptr
| private

For ctor when reading from stream.

Definition at line 133 of file ReaderAsciiHepMC2.h.

## ◆ m_vertex_barcodes

std::vector<int> m_vertex_barcodes
| private

Old vertex barcodes.

Definition at line 137 of file ReaderAsciiHepMC2.h.

## ◆ m_vertex_cache

std::vector<GenVertexPtr> m_vertex_cache
| private

Vertex cache.

Definition at line 136 of file ReaderAsciiHepMC2.h.

## ◆ m_vertex_cache_ghost

std::vector<GenVertexPtr> m_vertex_cache_ghost
| private

Vertex cache for attributes.

Definition at line 144 of file ReaderAsciiHepMC2.h.

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

- ReaderAsciiHepMC2.h
- ReaderAsciiHepMC2.cc