Particle database

Warning

The pycompwa is no longer maintained. Use the ComPWA packages QRules, AmpForm, and TensorWaves instead!

This notebook explains the difference between the particle list in pycompwa and the list used in the ComPWA C++ back-end. The two are only related the way they import and export XML files.

pycompwa particle list

The particle module is required for the expert system (see Step 1: Create an amplitude model): when you create an instance of the StateTransitionManager, it loads the default list of particles that is shipped with ComPWA. This default list is loaded into a dict called particle_list and is used internally by the expert system.

from pycompwa.expertsystem.state.particle import particle_list
from pycompwa.expertsystem.ui.system_control import StateTransitionManager

initial_state = [("J/psi", [-1, 1])]
final_state = [("gamma"), ("pi0"), ("pi0")]
tbd_manager = StateTransitionManager(
    initial_state,
    final_state,
    formalism_type="helicity",
    topology_building="isobar",
)
original_number_of_entries = len(particle_list)
print("loaded", original_number_of_entries, "particles")
2021-10-27 10:25:58,929 INFO [default] Logging to file disabled!
2021-10-27 10:25:58,929 [INFO] Log level: INFO
2021-10-27 10:25:58,929 [INFO] Current date and time: Wed Oct 27 10:25:58 2021
loaded 70 particles

In PWA research, it is quite likely that this particle list is incomplete, particularly if you search for rare resonances or if you analyze a \(e^+e^-\) collision of a particular energy as the initial state. You may therefore want to manipulate this particle list before you do call StateTransitionManager.find_solutions(). There are two ways to do this: (1) through Python or (2) by modifying a copy of the default XML file.

(1) through Python

The particle list instance is a tree of OrderedDict and dict instances that represent the structure of the XML file.

particle_list["D*(2010)+"]
{'@Name': 'D*(2010)+',
 'Pid': '413',
 'Parameter': OrderedDict([('@Type', 'Mass'),
              ('@Name', 'Mass_D*(2010)+'),
              ('Value', '2.01'),
              ('Fix', 'true')]),
 'QuantumNumber': [OrderedDict([('@Class', 'Spin'),
               ('@Type', 'Spin'),
               ('@Value', '1')]),
  OrderedDict([('@Class', 'Int'), ('@Type', 'Charge'), ('@Value', '1')]),
  OrderedDict([('@Class', 'Int'), ('@Type', 'Parity'), ('@Value', '-1')]),
  OrderedDict([('@Class', 'Spin'),
               ('@Type', 'IsoSpin'),
               ('@Value', '0.5'),
               ('@Projection', '0.5')]),
  OrderedDict([('@Class', 'Int'), ('@Type', 'Charm'), ('@Value', '1')]),
  OrderedDict([('@Class', 'Int'),
               ('@Type', 'BaryonNumber'),
               ('@Value', '0')])],
 'DecayInfo': OrderedDict([('@Type', 'relativisticBreitWigner'),
              ('FormFactor', OrderedDict([('@Type', 'BlattWeisskopf')])),
              ('Parameter',
               [OrderedDict([('@Type', 'Width'),
                             ('@Name', 'Width_D*(2010)+'),
                             ('Value', '83.4E-6'),
                             ('Fix', 'true')]),
                OrderedDict([('@Type', 'MesonRadius'),
                             ('@Name', 'Radius_D*(2010)+'),
                             ('Value', '2.5'),
                             ('Fix', 'true'),
                             ('Min', '2.0'),
                             ('Max', '3.0')])])])}

Although this is a bit arduous to work with, it is possible to directly manipulate the entries in there through Python. Whatever modifications to the particle_list instance are later on also used in the expert system. In this case, for instance, we can set a wider width for the \(D^*\):

particle_list["D*(2010)+"]["DecayInfo"]["Parameter"][0]["Value"] = 0.01

It can also happen that you want to add new particles. Because of the hierarchical structure of entries in the particle_list, it is best to work with a deepcopy() of a similar particle that is already in that list. You can get such a copy with get_particle_copy_by_name() and add it back with add_to_particle_list(). This can for instance come in handy if you want to work with several \(e^+e^-\) collision energies:

from pycompwa.expertsystem.state import particle
energies = [4180, 4220, 4420, 4600]  # MeV

for counter, energy in enumerate(energies, 1):
    new_particle = particle.get_particle_copy_by_name("EpEm")
    new_particle["Parameter"]["Value"] = energy / 1e3  # GeV
    pid = int(new_particle["Pid"]) + counter
    new_particle["@Name"] += str(energy)  # new name to not overwrite the old
    new_particle["Pid"] = str(pid)  # set unique PID
    particle.add_to_particle_list(new_particle)

assert original_number_of_entries + len(energies) == len(particle_list)
from IPython.display import display

display(particle.particle_list["EpEm"]["Parameter"])
display(particle.particle_list["EpEm4180"]["Parameter"])
OrderedDict([('@Type', 'Mass'),
             ('@Name', 'Mass_epem'),
             ('Value', '4.300'),
             ('Fix', 'true')])
OrderedDict([('@Type', 'Mass'),
             ('@Name', 'Mass_epem'),
             ('Value', 4.18),
             ('Fix', 'true')])
particle.particle_list["D*(2010)+"]["DecayInfo"]["Parameter"][0][
    "Value"
] = 0.01

Finally, you can write particle to another XML file, so that you can have this particle list manipulation in a separate Python script:

particle.write_particle_list_to_xml("new_particle_list.xml")

(2) through XML

Alternatively, you can copy the default XML file and manipulate it by hand (copy a section, tweak some names, change some parameters) and load it as follows:

particle.load_particle_list_from_xml("../particle_list.xml")

Note that duplicate values in the particle list are overwritten, but that old values are kept:

print("Number of entries in particle_list")
print("  old:", original_number_of_entries)
print("  new:", len(particle.particle_list))
Number of entries in particle_list
  old: 70
  new: 74
particle_list["D*(2010)+"]["DecayInfo"]["Parameter"][0]["Value"]
'83.4E-6'
particle_list["EpEm4420"]["Parameter"]
OrderedDict([('@Type', 'Mass'),
             ('@Name', 'Mass_epem'),
             ('Value', 4.42),
             ('Fix', 'true')])

ComPWA particle list

ComPWA, which we manage through the pycompwa.ui module, works with a different particle list than the one discussed in the previous section, because ComPWA’s objects ‘live’ in the C++ backend. We saw this ParticleList class before, for instance when, generating data. A pycompwa.ui.ParticleList can be created from an XML file as follows:

import pycompwa.ui

particles = pycompwa.ui.read_particles("../particle_list.xml")
2021-10-27 10:25:59,479 [INFO]  Particle a0(980)- with identical ID 9000211 already exists in list with the name a0(980)+ and ID 9000211. Particle properties will be overwritten!
2021-10-27 10:25:59,482 [INFO]  Particle PatricParticle with identical ID 1234 already exists in list with the name Chic1 and ID 1234. Particle properties will be overwritten!
2021-10-27 10:25:59,483 [INFO]  Particle nbar with identical ID 2112 already exists in list with the name n and ID 2112. Particle properties will be overwritten!

You can append particles to this instance from another list with

pycompwa.ui.Logging("error")  # switch off overwrite warnings
pycompwa.ui.insert_particles(particles, "../particle_list.xml")
2021-10-27 10:25:59,491 [INFO] Logging to file disabled!