Decay file parser — decaylanguage.dec#

Submodule with classes and utilities to deal with and parse .dec decay files.

Basic assumptions#

  1. For standard particle names not defined via aliases:
    • Decay modes defined via a ‘Decay’ statement.

    • Related antiparticle decay modes either defined via a ‘CDecay’ statement or via a ‘Decay’ statement. The latter option is often used if CP matters.

  2. For particle names defined via aliases:
    • Particle decay modes defined as above.

    • Related antiparticle decay modes defined with either options above, but there needs to be a ‘ChargeConj’ statement specifying the particle-antiparticle match. Typically:

      Alias MyP+ P+
      Alias MyP- P-
      ChargeConj MyP+ MyP-
      Decay MyP+
      ...
      Enddecay
      CDecay MyP-
      
  3. As a consequence, particles that are self-conjugate should not be used in ‘CDecay’ statements, obviously.

  4. Decays defined via a ‘CopyDecay’ statement are simply (deep) copied and no copy of the corresponding antiparticle is performed unless explicitly requested with another ‘CopyDecay’ statement.

exception decaylanguage.dec.dec.DecFileNotParsed[source]#
exception decaylanguage.dec.dec.DecayNotFound[source]#
class decaylanguage.dec.dec.DecFileParser(*filenames)[source]#

The class to parse a .dec decay file.

Example

>>> dfp = DecFileParser('my-decay-file.dec')
>>> dfp.parse()
Parameters:

filenames (str | os.PathLike[str])

classmethod from_string(filecontent)[source]#

Constructor from a .dec decay file provided as a multi-line string.

Parameters:

filecontent (str) – Input .dec decay file content.

Parameters:

filecontent (str)

Return type:

Self

parse(include_ccdecays=True)[source]#

Parse the given .dec decay file(s) according to the default Lark parser and specified options.

Use the method load_additional_decay_models before parse to load decay models that might not yet be available in DecayLanguage.

Parameters:

include_ccdecays (boolean, optional, default=True) – Choose whether or not to consider charge-conjugate decays, which are specified via “CDecay <MOTHER>”. Make sure you understand the consequences of ignoring charge conjugate decays - you won’t have a complete picture otherwise!

Parameters:

include_ccdecays (bool)

Return type:

None

grammar()[source]#

Access the internal Lark grammar definition file, effectively loading the default grammar with default parsing options if no grammar has been loaded before.

Returns:

out (str) – The Lark grammar definition file.

Return type:

str

grammar_info()[source]#

Access the internal Lark grammar definition file name and parser options, effectively loading the default grammar with default parsing options if no grammar has been loaded before.

Returns:

out (dict) – The Lark grammar definition file name and parser options.

Return type:

dict[str, Any]

load_additional_decay_models(*models)[source]#

Add one or more EvtGen decay models in addition to the ones already provided via decaylanguage.dec.enums.known_decay_models.

Parameters:

models (str) – names of the additional decay models to be considered.

Parameters:

models (str)

Return type:

None

property grammar_loaded: bool#

Check to see if the Lark grammar definition file is loaded.

dict_decays2copy()[source]#

Return a dictionary of all statements in the input parsed file defining a decay to be copied, of the form “CopyDecay <NAME> <DECAY_TO_COPY>”, as {‘NAME1’: DECAY_TO_COPY1, ‘NAME2’: DECAY_TO_COPY2, …}.

Return type:

dict[str, str]

dict_definitions()[source]#

Return a dictionary of all definitions in the input parsed file, of the form “Define <NAME> <VALUE>”, as {‘NAME1’: VALUE1, ‘NAME2’: VALUE2, …}.

Return type:

dict[str, float]

dict_model_aliases()[source]#

Return a dictionary of all model alias definitions in the input parsed file, of the form “ModelAlias <NAME> <MODEL>”, as as {‘NAME1’: [MODEL_NAME, MODEL_OPTION1, MODEL_OPTION2,…],}.

Return type:

dict[str, list[str]]

dict_aliases()[source]#

Return a dictionary of all alias definitions in the input parsed file, of the form “Alias <NAME> <ALIAS>”, as {‘NAME1’: ALIAS1, ‘NAME2’: ALIAS2, …}.

Return type:

dict[str, str]

dict_charge_conjugates()[source]#

Return a dictionary of all charge conjugate definitions in the input parsed file, of the form “ChargeConj <PARTICLE> <CC_PARTICLE>”, as {‘PARTICLE1’: CC_PARTICLE1, ‘PARTICLE2’: CC_PARTICLE2, …}.

Return type:

dict[str, str]

get_particle_property_definitions()[source]#

Return a dictionary of all particle property definitions in the input parsed file, of the form “Particle <PARTICLE> <MASS> <WIDTH>” or “Particle <PARTICLE> <MASS>”, as:

{'PARTICLE1': {'mass': MASS1, 'width': WIDTH1},
 'PARTICLE2': {'mass': MASS2, 'width': WIDTH2}, ...}.

Note

  1. Masses and widths are in GeV in EvtGen, hence the “Particle <PARTICLE> <MASS>” statement needs to use GeV! A conversion to MeV may be done on the fly when information is required from the Particle package, which uses MeV, the (standard) HEP System of Units.

  2. Particles are often defined via aliases and post-processing may be needed to match the mass and width to the actual particle.

  3. The mass (width) parameter is compulsory (optional). When not specified, the width is taken from the particle or alias.

Return type:

dict[str, dict[str, float]]

dict_pythia_definitions()[source]#

Return a dictionary of all Pythia 8 commands “PythiaGenericParam” and/or “PythiaAliasParam” and/or “PythiaBothParam”, with keys corresponding to the 3 types specifying whether the command is for generic decays, alias decays, or both. The commands are set in the input parsed file with statements of the form “Pythia<TYPE>Param <MODULE>:<PARAM>=<LABEL_OR_VALUE>. The dictionary takes the form:

{"PythiaAliasParam": {'<MODULE1>:<PARAM1>': 'LABEL1', '<MODULE1>:<PARAM2>': VALUE2, ...},
 "PythiaBothParam": {'<MODULE2>:<PARAM3>': 'LABEL3', '<MODULE3>:<PARAM4>': VALUE4, ...},
 "PythiaGenericParam": {'<MODULE4>:<PARAM5>': 'LABEL5', '<MODULE5>:<PARAM6>': VALUE6, ...}}.
Return type:

dict[str, dict[str, str | float]]

dict_jetset_definitions()[source]#

Return a dictionary of all JETSET definitions in the input parsed file, of the form “JetSetPar <MODULE>(<PARAMETER>)=<VALUE>” as:

{'MODULE1': {PARAMETER1: VALUE1, PARAMETER2: VALUE2, ...},
 'MODULE2': {...},
 ...}.
Return type:

dict[str, dict[int, int | float | str]]

expand_decay_modes(particle)[source]#

Return a list of expanded decay descriptors for the given (mother) particle. The set of decay final states is effectively split and returned as a list. NB: this implicitly reverts aliases back to the original (EvtGen) names.

Parameters:

particle (str)

Return type:

list[str]

dict_lineshape_settings()[source]#

Return a dictionary of all lineshape settings, with keys corresponding to particle names or aliases, as:

{PARTICLE1: {'lineshape': 'NAME1',  # E.g. "LSFLAT" or "LSNONRELBW"
  'BlattWeisskopf': VALUE1,
  'ChangeMassMin': VALUE12,
  'ChangeMassMax': VALUE13},
 PARTICLE2: {'lineshape': 'NAME2',
  'BlattWeisskopf': VALUE2,
  'ChangeMassMin': VALUE22,
  'ChangeMassMax': VALUE23,
  'IncludeBirthFactor': TRUE_OR_FALSE,
  'IncludeDecayFactor': TRUE_OR_FALSE},
 ...
}

where not all “sub-dictionaries” may contain all and/or the same keys.

Return type:

dict[str, dict[str, str | float]]

list_lineshapePW_definitions()[source]#

Return a list of all SetLineshapePW definitions in the input parsed file, of the form “SetLineshapePW <MOTHER> <DAUGHTER1> <DAUGHTER2> <VALUE>”, as:

[(['MOTHER1', 'DAUGHTER1-1', 'DAUGHTER1-2'], VALUE1),
 (['MOTHER2', 'DAUGHTER2-1', 'DAUGHTER2-2'], VALUE2),
 ...]
Return type:

list[tuple[list[str], int]]

global_photos_flag()[source]#

Return a boolean-like PhotosEnum enum specifying whether or not PHOTOS has been enabled.

Note: PHOTOS is turned on(off) for all decays with the global flag yesPhotos(noPhotos).

Returns:

out (PhotosEnum, default=PhotosEnum.no) – PhotosEnum.yes / PhotosEnum.no if PHOTOS enabled / disabled

Return type:

int

list_charge_conjugate_decays()[source]#

Return a (sorted) list of all charge conjugate decay definitions in the input parsed file, of the form “CDecay <MOTHER>”, as [‘MOTHER1’, ‘MOTHER2’, …].

Return type:

list[str]

property number_of_decays: int#

Return the number of particle decays defined in the parsed .dec file.

list_decay_mother_names()[source]#

Return a list of all decay mother names found in the parsed decay file.

Return type:

list[str | Any]

list_decay_modes(mother, pdg_name=False)[source]#

Return a list of decay modes for the given mother particle.

Parameters:
  • mother (str) – Input mother particle name.

  • pdg_name (bool, optional, default=False) – Input mother particle name is the PDG name, not the (default) EvtGen name.

Parameters:
Return type:

list[list[str]]

Example

>>> parser = DecFileParser('my-decay-file.dec')
>>> parser.parse()
>>> # Inspect what decays are defined
>>> parser.list_decay_mother_names()
>>> parser.list_decay_modes('pi0')
print_decay_modes(mother, pdg_name=False, print_model=True, display_photos_keyword=True, ascending=False, normalize=False, scale=None)[source]#

Pretty print of the decay modes of a given particle, optionally with decay model information and/or normalisation or scaling of the branching fractions.

Note

Branching fractions are truncated to 7 significant digits for readability.

Parameters:
  • mother (str) – Input mother particle name.

  • pdg_name (bool, optional, default=False) – Input mother particle name is the PDG name, not the (default) EvtGen name.

  • print_model (bool, optional, default=True) – Specify whether to print the decay model and model parameters, if available.

  • display_photos_keyword (bool, optional, default=True) – Display the “PHOTOS” keyword in decay models.

  • ascending (bool, optional, default=False) – Print the list of decay modes ordered in ascending/descending order of branching fraction.

  • normalize (bool, optional, default=False) – Print the branching fractions normalized to unity. The printing does not affect the values parsed and actually stored in memory.

  • scale (float | None, optional, default=None) – If not None, the branching fractions (BFs) are normalized to the given value, which is taken to be the BF of the highest-BF mode of the list. Must be a number in the range ]0, 1].

Parameters:
Return type:

None

Examples

>>> s = '''Decay MyD_0*+
...  0.533   MyD0   pi+        PHSP;
...  0.08    MyD*0  pi+  pi0   PHSP;
...  0.0271  MyD*+  pi0  pi0   PHSP;
...  0.0542  MyD*+  pi+  pi-   PHSP;
... Enddecay
... '''
>>> p = DecFileParser.from_string(s)
>>> p.parse()
>>>
>>> # Simply print what has been parsed
>>> p.print_decay_modes("MyD_0*+")
  0.533        MyD0 pi+            PHSP;
  0.08         MyD*0 pi+ pi0       PHSP;
  0.0542       MyD*+ pi+ pi-       PHSP;
  0.0271       MyD*+ pi0 pi0       PHSP;
>>>
>>> # Print normalizing the sum of all mode BFs to unity
>>> p.print_decay_modes("MyD_0*+", normalize=True)
  0.7676797    MyD0 pi+            PHSP;
  0.115224     MyD*0 pi+ pi0       PHSP;
  0.07806424   MyD*+ pi+ pi-       PHSP;
  0.03903212   MyD*+ pi0 pi0       PHSP;
>>>
>>> # Print scaling all BFs relative to the BF of the highest-BF mode in the list,
>>> # the latter being set to the value of "scale".
>>> # In this example the decay file as printed would effectively signal, for inspection,
>>> # that about 35% of the total decay width is not accounted for in the list of modes,
>>> # since the sum of probabilities, interpreted as BFs, sum to about 65%.
>>> p.print_decay_modes("MyD_0*+", scale=0.5)
  0.5          MyD0 pi+            PHSP;
  0.0750469    MyD*0 pi+ pi0       PHSP;
  0.05084428   MyD*+ pi+ pi-       PHSP;
  0.02542214   MyD*+ pi0 pi0       PHSP;
build_decay_chains(mother, stable_particles=(), minimum_effective_bf=None)[source]#

Iteratively build the entire decay chains of a given mother particle, optionally considering, on the fly, certain particles as stable. This way, for example, only the B -> D E F part in a decay chain A -> B (-> D E F (-> G H)) C can be trivially selected for inspection.

Parameters:
  • mother (str) – Input mother particle name.

  • stable_particles (iterable, optional, default=()) – If provided, stops the decay-chain parsing, taking the “list” as particles to be considered stable.

  • minimum_effective_bf (float | None, optional, default=None) – If provided, only decay chains where the product of branching fractions from the mother down to the stable particles (the “effective branching fraction”) is above this value will be returned. This prunes less likely or negligible decay paths.

Returns:

out (dict) – Decay chain as a dictionary of the form {mother: [{‘bf’: float, ‘fs’: list, ‘model’: str, ‘model_params’: str}]} where ‘bf’ stands for the decay mode branching fraction, ‘fs’ is a list of final-state particle names (strings) and/or dictionaries of the same form as the decay chain above, ‘model’ is the model name, if found, else ‘’, ‘model_params’ are the model parameters, if specified, else ‘’

Parameters:
Return type:

dict[str, list[DecayModeDict]]

Examples

>>> parser = DecFileParser('a-Dplus-decay-file.dec')
>>> parser.parse()
>>> parser.build_decay_chains('D+')
{'D+': [{'bf': 1.0,
   'fs': ['K-',
    'pi+',
    'pi+',
    {'pi0': [{'bf': 0.988228297,
       'fs': ['gamma', 'gamma'],
       'model': 'PHSP',
       'model_params': ''},
      {'bf': 0.011738247,
       'fs': ['e+', 'e-', 'gamma'],
       'model': 'PI0_DALITZ',
       'model_params': ''},
      {'bf': 3.3392e-05,
      'fs': ['e+', 'e+', 'e-', 'e-'],
      'model': 'PHSP',
      'model_params': ''},
      {'bf': 6.5e-08, 'fs': ['e+', 'e-'], 'model': 'PHSP', 'model_params': ''}]}],
   'model': 'PHSP',
   'model_params': ''}]}
>>> p.build_decay_chains('D+', stable_particles=['pi0'])
{'D+': [{'bf': 1.0, 'fs': ['K-', 'pi+', 'pi+', 'pi0'], 'model': 'PHSP', 'model_params': ''}]}
class decaylanguage.dec.dec.DecayModelAliasReplacement(model_alias_defs=None)[source]#

Lark Transformer implementing the replacement of decay model aliases with the model provided in ‘ModelAlias’ statements. This replaces the model_label with a subtree containing both the model name and its options. The replacement is only relevant for Lark Tree instances of name ‘model’ (Tree.data == ‘model’).

Parameters:

model_alias_defs (dict, optional, default={}) – Dictionary with the ‘ModelAlias’ definitions in the parsed file. Argument to be passed to the class constructor.

Parameters:

model_alias_defs (dict[str, Any] | None)

model(treelist)[source]#

Method for the rule (here, a replacement) we wish to implement. Must happen on model level to replace a Lark Token with a Lark Tree. Doesn’t do anything if no model_label is found.

Parameters:

treelist (list[Tree])

Return type:

Tree

class decaylanguage.dec.dec.DecayModelParamValueReplacement(define_defs=None)[source]#

Lark Visitor implementing the replacement of decay model parameter names with the actual parameter values provided in ‘Define’ statements, and replacement of floats stored as strings to the actual floating values. The replacement is only relevant for Lark Tree instances of name ‘model_options’ (Tree.data == ‘model_options’).

Parameters:

define_defs (dict, optional, default={}) – Dictionary with the ‘Define’ definitions in the parsed file. Argument to be passed to the class constructor.

Parameters:

define_defs (dict[str, Any] | None)

Examples

>>> from lark import Tree, Token
>>> ...
>>> t = Tree('decay', [Tree('particle', [Token('LABEL', 'Upsilon(4S)')]),
...         Tree('decayline', [Tree('value', [Token('SIGNED_NUMBER', '1.0')]),
...         Tree('particle', [Token('LABEL', 'B0')]),
...         Tree('particle', [Token('LABEL', 'anti-B0')]),
...         Tree('model', [Token('MODEL_NAME', 'VSS_BMIX'),
...         Tree('model_options', [Token('LABEL', 'dm')])])])])
>>> dict_define_defs = {'dm': 0.507e12}
>>> DecayModelParamValueReplacement(define_defs=dict_define_defs).visit(t)
Tree('decay', [Tree('particle', [Token('LABEL', 'Upsilon(4S)')]),
Tree('decayline', [Tree('value', [Token('SIGNED_NUMBER', '1.0')]),
Tree('particle', [Token('LABEL', 'B0')]),
Tree('particle', [Token('LABEL', 'anti-B0')]),
Tree('model', [Token('MODEL_NAME', 'VSS_BMIX'),
Tree('model_options', [Token('LABEL', 507000000000.0)])])])])
model_options(tree)[source]#

Method for the rule (here, a replacement) we wish to implement.

Parameters:

tree (Tree)

Return type:

None

class decaylanguage.dec.dec.ChargeConjugateReplacement(charge_conj_defs=None)[source]#

Lark Visitor implementing the replacement of all particle names with their charge conjugate particle names in a Lark Tree of name ‘particle’ (Tree.data == ‘particle’).

Note

1) There is no check of whether the mother particle is self-conjugate or not. It is the responsibility of the caller to make sure the operation is not trivial, meaning returning the same (self-conjugate) decay! 2) If a particle name (say, ‘UNKOWN’) is not found or known, (search done via the Particle class in the particle package), its charge conjugate name is denoted as ‘ChargeConj(UNKOWN)’.

Parameters:

charge_conj_defs (dict, optional, default={}) – Dictionary with the charge conjugate particle definitions in the parsed file. Argument to be passed to the class constructor.

Parameters:

charge_conj_defs (dict[str, str] | None)

Examples

>>> from lark import Tree, Token
>>> ...
>>> t = Tree('decay', [Tree('particle', [Token('LABEL', 'D0')]), Tree('decayline', [Tree
... ('value', [Token('SIGNED_NUMBER', '1.0')]), Tree('particle', [Token('LABEL', 'K-')]),
... Tree('particle', [Token('LABEL', 'pi+')]), Tree('model', [Token('MODEL_NAME', 'PHSP')])])])
>>> ChargeConjugateReplacement().visit(t)
Tree('decay', [Tree('particle', [Token('LABEL', 'anti-D0')]),
Tree('decayline', [Tree('value', [Token('SIGNED_NUMBER', '1.0')]),
Tree('particle', [Token('LABEL', 'K+')]),
Tree('particle', [Token('LABEL', 'pi-')]),
Tree('model', [Token('MODEL_NAME', 'PHSP')])])])
particle(tree)[source]#

Method for the rule (here, a replacement) we wish to implement.

Parameters:

tree (Tree)

Return type:

None

decaylanguage.dec.dec.find_charge_conjugate_match(pname, dict_cc_names=None)[source]#

Find the charge-conjugate particle name making use of user information from “ChargeConj” statements in a decay file.

The name ChargeConj(pname) is returned if all matching “routes” fail, see charge_conjugate_name(...) function.

Parameters:
Return type:

str

decaylanguage.dec.dec.get_decay_mother_name(decay_tree)[source]#

Return the mother particle name for the decay mode defined in the input Tree of name ‘decay’.

Parameters:

decay_tree (Lark Tree instance) – Input Tree satisfying Tree.data==’decay’.

Parameters:

decay_tree (Tree)

Return type:

str | Any

decaylanguage.dec.dec.get_branching_fraction(decay_mode)[source]#

Return the branching fraction (float) for the decay mode defined in the input Tree of name ‘decayline’.

Parameters:

decay_mode (Lark Tree instance) – Input Tree satisfying Tree.data==’decayline’.

Parameters:

decay_mode (Tree)

Return type:

float

decaylanguage.dec.dec.get_final_state_particles(decay_mode)[source]#

Return a list of Lark Tree instances describing the final-state particles for the decay mode defined in the input Tree of name ‘decayline’.

Parameters:

decay_mode (Lark Tree instance) – Input Tree satisfying Tree.data==’decayline’.

Parameters:

decay_mode (Tree)

Return type:

list[Tree]

Examples

For a decay:

Decay MyB_s0
    1.000     K+     K-     SSD_CP 20.e12 0.1 1.0 0.04 9.6 -0.8 8.4 -0.6;
Enddecay

the list [Tree(particle, [Token(LABEL, 'K+')]), Tree(particle, [Token(LABEL, 'K-')])] will be returned.

decaylanguage.dec.dec.get_final_state_particle_names(decay_mode)[source]#

Return a list of final-state particle names for the decay mode defined in the input Tree of name ‘decayline’.

Parameters:

decay_mode (Lark Tree instance) – Input Tree satisfying Tree.data==’decayline’.

Parameters:

decay_mode (Tree)

Return type:

list[str]

Examples

For a decay:

Decay MyB_s0
    1.000     K+     K-     SSD_CP 20.e12 0.1 1.0 0.04 9.6 -0.8 8.4 -0.6;
Enddecay

the list ['K+', 'K-'] will be returned.

decaylanguage.dec.dec.get_model_name(decay_mode)[source]#

Return the decay model name in a Tree of name ‘decayline’.

Parameters:

decay_mode (Lark Tree instance) – Input Tree satisfying Tree.data==’decayline’.

Parameters:

decay_mode (Tree)

Return type:

str

Examples

For a decay:

Decay MyB_s0
    1.000     K+     K-     SSD_CP 20.e12 0.1 1.0 0.04 9.6 -0.8 8.4 -0.6;
Enddecay

the string 'SSD_CP' will be returned.

decaylanguage.dec.dec.get_model_parameters(decay_mode)[source]#

Return a list of decay model parameters in a Tree of name ‘decayline’, if defined, else an empty string.

Parameters:

decay_mode (Lark Tree instance) – Input Tree satisfying Tree.data==’decayline’.

Parameters:

decay_mode (Tree)

Return type:

str | list[str | Any]

Examples

For a decay:

Decay MyB_s0
    1.000     K+     K-     SSD_CP 20.e12 0.1 1.0 0.04 9.6 -0.8 8.4 -0.6;
Enddecay

the list [20000000000000.0, 0.1, 1.0, 0.04, 9.6, -0.8, 8.4, -0.6] will be returned.

For a decay:

Decay MyD0
    1.00      K-   pi-   pi+   pi+     LbAmpGen DtoKpipipi_v1 ;
Enddecay

the list ['DtoKpipipi_v1'] will be returned.

decaylanguage.dec.dec.get_decays(parsed_file)[source]#

Return a list of all decay definitions in the input parsed file, of the form “Decay <MOTHER>”, as a tuple of Lark Tree instances with Tree.data==’decay’, i.e.:

[Tree(decay, [Tree(particle, [Token(LABEL, <MOTHER1>]), ...),
 Tree(decay, [Tree(particle, [Token(LABEL, <MOTHER2>]), ...)].
Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

list[Tree]

decaylanguage.dec.dec.get_charge_conjugate_decays(parsed_file)[source]#

Return a (sorted) list of all charge conjugate decay definitions in the input parsed file, of the form “CDecay <MOTHER>”, as [‘MOTHER1’, ‘MOTHER2’, …].

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

list[str]

decaylanguage.dec.dec.get_decays2copy_statements(parsed_file)[source]#

Return a dictionary of all statements in the input parsed file defining a decay to be copied, of the form “CopyDecay <NAME> <DECAY_TO_COPY>”, as {‘NAME1’: DECAY_TO_COPY1, ‘NAME2’: DECAY_TO_COPY2, …}.

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, str]

decaylanguage.dec.dec.get_definitions(parsed_file)[source]#

Return a dictionary of all definitions in the input parsed file, of the form “Define <NAME> <VALUE>”, as {‘NAME1’: VALUE1, ‘NAME2’: VALUE2, …}.

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, float]

decaylanguage.dec.dec.get_model_aliases(parsed_file)[source]#

Return a dictionary of all model alias definitions in the input parsed file, of the form “ModelAlias <NAME> <MODEL_NAME> <MODEL_OPTIONS>”, as {‘NAME1’: [MODEL_NAME, MODEL_OPTION1, MODEL_OPTION2,…], ‘NAME2’: [MODEL_NAME, …]…}.

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, list[str]]

decaylanguage.dec.dec.get_aliases(parsed_file)[source]#

Return a dictionary of all aliases in the input parsed file, of the form “Alias <NAME> <ALIAS>”, as {‘NAME1’: ALIAS1, ‘NAME2’: ALIAS2, …}.

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, str]

decaylanguage.dec.dec.get_charge_conjugate_defs(parsed_file)[source]#

Return a dictionary of all charge conjugate definitions in the input parsed file, of the form “ChargeConj <PARTICLE> <CC_PARTICLE>”, as {‘PARTICLE1’: CC_PARTICLE1, ‘PARTICLE2’: CC_PARTICLE2, …}.

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, str]

decaylanguage.dec.dec.get_particle_property_definitions(parsed_file)[source]#

Return a dictionary of all particle property definitions in the input parsed file, of the form “Particle <PARTICLE> <MASS> <WIDTH>” or “Particle <PARTICLE> <MASS>”, as:

{'PARTICLE1': {'mass': MASS1, 'width': WIDTH1},
 'PARTICLE2': {'mass': MASS2, 'width': WIDTH2}, ...}.

Note

  1. Masses and widths are in GeV in EvtGen, hence the “Particle <PARTICLE> <MASS>” statement needs to use GeV! A conversion to MeV may be done on the fly when information is required from the Particle package, which uses MeV, the (standard) HEP System of Units.

  2. Particles are often defined via aliases and post-processing may be needed to match the mass and width to the actual particle.

  3. The mass (width) parameter is compulsory (optional). When not specified, the width is taken from the particle or alias.

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, dict[str, float]]

decaylanguage.dec.dec.get_pythia_definitions(parsed_file)[source]#

Return a dictionary of all Pythia 8 commands “PythiaGenericParam” and/or “PythiaAliasParam” and/or “PythiaBothParam”, with keys corresponding to the 3 types specifying whether the command is for generic decays, alias decays, or both. The commands are set in the input parsed file with statements of the form “Pythia<TYPE>Param <MODULE>:<PARAM>=<LABEL_OR_VALUE>. The dictionary takes the form:

{"PythiaAliasParam": {'<MODULE1>:<PARAM1>': 'LABEL1', '<MODULE1>:<PARAM2>': VALUE2, ...},
 "PythiaBothParam": {'<MODULE2>:<PARAM3>': 'LABEL3', '<MODULE3>:<PARAM4>': VALUE4, ...},
 "PythiaGenericParam": {'<MODULE4>:<PARAM5>': 'LABEL5', '<MODULE5>:<PARAM6>': VALUE6, ...}}.
Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, dict[str, str | float]]

decaylanguage.dec.dec.get_jetset_definitions(parsed_file)[source]#

Return a dictionary of all JETSET definitions in the input parsed file, of the form “JetSetPar <MODULE>(<PARAMETER>)=<VALUE>” as:

{'MODULE1': {PARAMETER1: VALUE1, PARAMETER2: VALUE2, ...},
 'MODULE2': {...},
 ...}.
Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, dict[int, int | float | str]]

decaylanguage.dec.dec.get_lineshape_settings(parsed_file)[source]#

Return a dictionary of all lineshape settings, with keys corresponding to particle names or aliases, as:

{PARTICLE1: {'lineshape': 'NAME1',  # E.g. "LSFLAT" or "LSNONRELBW"
  'BlattWeisskopf': VALUE11,
  'ChangeMassMin': VALUE12,
  'ChangeMassMax': VALUE13},
 PARTICLE2: {'lineshape': 'NAME2',
  'BlattWeisskopf': VALUE21,
  'ChangeMassMin': VALUE22,
  'ChangeMassMax': VALUE23,
  'IncludeBirthFactor': TRUE_OR_FALSE,
  'IncludeDecayFactor': TRUE_OR_FALSE},
 ...
}

where not all “sub-dictionaries” may contain all and/or the same keys.

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

dict[str, dict[str, str | float]]

decaylanguage.dec.dec.get_lineshapePW_definitions(parsed_file)[source]#

Return a list of all SetLineshapePW definitions in the input parsed file, of the form “SetLineshapePW <MOTHER> <DAUGHTER1> <DAUGHTER2> <VALUE>”, as:

[(['MOTHER1', 'DAUGHTER1-1', 'DAUGHTER1-2'], VALUE1),
 (['MOTHER2', 'DAUGHTER2-1', 'DAUGHTER2-2'], VALUE2),
 ...]
Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Parameters:

parsed_file (Tree)

Return type:

list[tuple[list[str], int]]

decaylanguage.dec.dec.get_global_photos_flag(parsed_file)[source]#

Return a boolean-like PhotosEnum enum specifying whether or not PHOTOS has been enabled.

Note: PHOTOS is turned on(off) for all decays with the global flag yesPhotos(noPhotos).

Parameters:

parsed_file (Lark Tree instance) – Input parsed file.

Returns:

out (PhotosEnum, default=PhotosEnum.no) – PhotosEnum.yes / PhotosEnum.no if PHOTOS enabled / disabled

Parameters:

parsed_file (Tree)

Return type:

int