pythiaplotter.parsers package

Submodules

pythiaplotter.parsers.cmssw_particle_list_parser module

Handle parsing of ParticleListDrawer as output by CMSSW.

Default is NODE representation for particles.

See example/example_cmssw.txt for example input file.

TODO: perhaps this needs a name change...

class pythiaplotter.parsers.cmssw_particle_list_parser.CMSSWParticleListParser(filename)[source]

Bases: object

Main class to parse ParticleListDrawer as output by CMSSW

parse()[source]

Parse contents of the input file, extract particles, and assign to a NetworkX graph.

Returns:
  • Event – Event object containing info about the event.
  • list[NodeParticle] – Collection of NodeParticles to be assigned to a graph.
parse_particle_line(line)[source]

Parse line representing a particle, return a NodeParticle.

pythiaplotter.parsers.event_classes module

Classes to describe event & physical particles.

class pythiaplotter.parsers.event_classes.EdgeParticle(particle, vtx_in_barcode, vtx_out_barcode)[source]

Bases: object

Class to hold info when particle is represented by an edge.

This contains the physical Particle object, and associated info that is edge-specific, such as incoming/outgoing vertex barcodes.

Vertex barcodes are ints.

barcode
class pythiaplotter.parsers.event_classes.Event(event_num=0, source=None, title=None, **kwargs)[source]

Bases: object

Hold event info

__str__()[source]

Print event info in format suitable for use on graph or printout

print_stats()[source]

Print some basic statistics about the event

class pythiaplotter.parsers.event_classes.NodeParticle(particle, parent_barcodes)[source]

Bases: object

barcode
class pythiaplotter.parsers.event_classes.Particle(barcode, pdgid=0, status=0, initial_state=False, final_state=False, **kwargs)[source]

Bases: object

__ge__(other)

x.__ge__(y) <==> x>=y

__gt__(other)

x.__gt__(y) <==> x>y

__le__(other)

x.__le__(y) <==> x<=y

pythiaplotter.parsers.event_classes.convert_px_py_pz(px, py, pz)[source]

Convert cartesian momentum components \(p_x, p_y, p_z\) into \(p_T, \eta, \phi\)

Notes

  • pt (\(p_T\)) is the momentum in the transverse (x-y) plane
  • eta (\(\eta\)) is the pseudorapidity, \(\eta = -\ln(\tanh(\theta/2))\) where \(\theta\) is the angle of the 3-momentum in the x-z plane relative to the z axis
  • phi (\(\phi\)) is the angle of the 3-momentum in the x-y plane relative to the x axis

Relationships between \(p_T, \eta, \phi\) and \(p_x, p_y, p_z\):

\[\begin{split}p_x &= p_T * \cos(\phi)\end{split}\]\[\begin{split}p_y &= p_T * \sin(\phi)\end{split}\]\[\begin{split}p_z &= p_T * \sinh (\eta) = p * \cos(\theta)\end{split}\]

Note that if \(p_T = 0\), \(\eta = \mathrm{sign}(p_z) * \infty\).

Parameters:py, pz (px,) – Cartesian component of momentum along x, y, z axis, respectively
Returns:pt, eta, phi – Transverse momentum, pseudorapidity, and azimuthal angle (in radians).
Return type:float

pythiaplotter.parsers.generic_text_parser module

pythiaplotter.parsers.hepmc_parser module

Handle parsing of HepMC files.

Default is EDGE representation.

See example/example_hepmc.hepmc for example input file.

class pythiaplotter.parsers.hepmc_parser.GenVertex(barcode, n_orphan_in=0)[source]

Bases: object

Helper class to represent a HepMC GenVertex object.

Vertices have a barcode that is an integer.

Only exists inside this parser module since it is only used for parsing file and when assigning particles to a NetworkX graph.

Use a namedtuple instead?

class pythiaplotter.parsers.hepmc_parser.HepMCParser(filename, event_num=0)[source]

Bases: object

Main class to parse a HepMC file.

User can pass in an event number to return the event with that ID. If unassigned, or no events with that event number, return first event in file.

parse()[source]

Parse contents of the input file, extract particles, and assign to a NetworkX graph.

Returns:
  • Event – Event object containing info about the event.
  • list[EdgeParticle] – Collection of EdgeParticles to be assigned to a graph.
parse_event_line(line)[source]

Parse a HepMC GenEvent line and return an Event object

parse_particle_line(line)[source]

Parse a HepMC GenParticle line and return an EdgeParticle object

Note that the EdgeParticle does not have vtx_out_barcode assigned here, since we are parsing a line in isolation. The vtx_out_barcode is added in the main pars() method. We just use a dummy value for now.

parse_units_line(line)[source]

Parse units specification line.

Parameters:line (str) – Line to parse
Returns:Energy and length units
Return type:str, str
parse_vertex_line(line)[source]

Parse a HepMC GenVertex line and return a GenVertex object

pythiaplotter.parsers.heppy_parser module

pythiaplotter.parsers.lhe_parser module

Handle parsing of LHE files.

Default is NODE representation for particles.

See example/example_lhe.lhe for example input file.

class pythiaplotter.parsers.lhe_parser.LHEParser(filename, event_num=0)[source]

Bases: object

Main class to parse a LHE file.

User can pass in an event number to return that event (first event = 1) If unassigned, or no events with that event number, return first event in file.

parse()[source]

Parse contents of the input file, extract particles, and assign to a NetworkX graph.

Returns:
  • Event – Event object containing info about the event.
  • list[NodeParticle] – Collection of NodeParticles to be assigned to a graph.
parse_event_line(line, event_num)[source]

Parse a LHE event info line.

Parameters:
  • line (str) – Line of text describing the event.
  • event_num (int) – Event number, as it is not included in the event line.
Returns:

Event object with information from the line.

Return type:

Event

parse_event_text(text)[source]

Parse the text in a <event>...</event> block

The first line is compulsory event info Each line after represents a particle.

Parameters:text (str) – Event text block to be parsed.
Returns:Event object filled with info about the event, as well as NodeParticles in the event.
Return type:Event
parse_init_text(text)[source]

Parse the initialisation info. Currently does nothing.

The first line is compulsory process-numer-independent info. Each line after represents a process

Parameters:text (str) – Text in the <init></init> tags.
Returns:
Return type:None
parse_particle_line(line, barcode)[source]

Parse a line that describes a particle and its mothers from a LHE file.

Need to supply barcode to make Particle obj unique, since not supplied as part of LHE format

Parameters:
  • line (str) – Line of text describing a particle
  • barcode (int) – Unique barcode for this particle
Returns:

NodeParticle object that contains the Particle, as well as its mother barcodes.

Return type:

NodeParticle

pythiaplotter.parsers.parser_base module

pythiaplotter.parsers.pythia8_parser module

Handle parsing of standalone Pythia 8 screen output.

Default is NODE representation for particles.

See example/example_pythia8.txt for example input file.

TODO: reshuffle blocks - non optimal spreading out atm

class pythiaplotter.parsers.pythia8_parser.Pythia8Parser(filename, event_num=0)[source]

Bases: object

Main class to parse Pythia 8 screen output from a text file.

full_evt_end = 'End PYTHIA Event Listing'
full_evt_start = 'PYTHIA Event Listing (complete event)'
hard_evt_end = 'End PYTHIA Event Listing'
hard_evt_start = 'PYTHIA Event Listing (hard process)'
info_end = 'End PYTHIA Info Listing'
info_start = 'PYTHIA Info Listing'
parse()[source]

Parse contents of the input file, extract particles, and assign to a NetworkX graph.

Returns:
  • Event – Event object containing info about the event.
  • list[NodeParticle] – Collection of NodeParticles to be assigned to a graph.
stats_end = 'End PYTHIA Event and Cross Section Statistics'
stats_start = 'PYTHIA Event and Cross Section Statistics'
class pythiaplotter.parsers.pythia8_parser.PythiaBlock(name, contents=None, parser=None)[source]

Bases: object

parse_block()[source]

Run the instance parser over contents, and store results.

pythiaplotter.parsers.pythia8_parser.parse_event_block(contents)[source]

Parse Event listing block in Pythia output

Parameters:contents (list[str]) – Contents of event block.
Returns:NodeParticles extracted from event, with mother barcodes set.
Return type:list[NodeParticle]
pythiaplotter.parsers.pythia8_parser.parse_info_block(contents)[source]

Method to parse Info block. Makes Event object to hold particles

pythiaplotter.parsers.pythia8_parser.parse_stats_block(contents)[source]

Method to parse Statistics block. Kept unimplemented.

Module contents

Parsers read the input file, and convert the information into a set of particles. These can then be attached to a graph.

pythiaplotter.parsers.parser_opts

dict[str, ParserOption]

Dictionary of all available parsers, along with info about each.

class pythiaplotter.parsers.ParserOption(description, parser, default_representation, file_extension)[source]

Bases: object