ComPWA / expertsystem

Rule based particle reaction problem solver on a quantum number level
http://expertsystem.rtfd.io
1 stars 3 forks source link

Get particle info from PDG #23

Closed redeboer closed 4 years ago

redeboer commented 4 years ago
redeboer commented 4 years ago

@sebastianJaeger @Leongrim I added some snippets to the issue description :) Let me know if it you have questions!

Leongrim commented 4 years ago

I looked into the particle package from scikit-hep. There are a few problems with it.

This package does not get the information from the webpage but from a .csv file which comes with the package which does not include all the particles that are found on the webpage.

The larger issue is not all quantum numbers are accessible. Something like Bottomness or IsospinZ are still calculable from the quarks. But regarding the lepton numbers there seems to be no a work around.

redeboer commented 4 years ago

This package does not get the information from the webpage but from a .csv file which comes with the package which does not include all the particles that are found on the webpage.

Yes, this is true. But I am not aware of an official API for the PDG, so I think this package is the closest we can get, that is, 'outsource the downloading of the latest CSV file' to that package.

The larger issue is not all quantum numbers are accessible. Something like Bottomness or IsospinZ are still calculable from the quarks. But regarding the lepton numbers there seems to be no a work around.

Right, this sounds like a big problem... I had a quick look into the package and had the same impression, so glad that is confirmed.

So if I understand correctly, the particle package does offer quark content, but you have to compute the numbers yourself... We should consider if that's feasible.

redeboer commented 4 years ago

Btw, note that this issue is still independent of #152

Leongrim commented 4 years ago

You could work around this by a huge pile of if statements😬 It would be possible to get the lepton numbers from the names.

redeboer commented 4 years ago

You could work around this by a huge pile of if statementsgrimacing

I see. Well, it would be worth the effort, I think. Because if we manage to import all PDG info into a ParticleCollection instance, one can do any quick search, like:

[
    particle
    for particle in DATABASE
    if particle.state.spin == 0 and particle.state.bottom == 1
]  # List[Particle]

And if you wrap put all these if statements under some function like

def load_pdg() -> ParticleCollection:
    ...

then it can be refactored later on if there is a cleaner solution (possibly not using the particle package).

It would be possible to get the lepton numbers from the names.

How so?

Leongrim commented 4 years ago

Through the name you can distinguish e, mu and tau and also neutrinos.

Leongrim commented 4 years ago

For the hadrons I get already something like


    Baryonnumber=0
    Strangeness = 0
    Charmness = 0
    Bottomness = 0
    Topness = 0
    isospinZ = 0
    if pdg.pdgid.is_baryon:
        Baryonnumber = 1
        if pdg.pdgid<0: 
            Baryonnumber = -1
if pdg.pdgid.is_hadron:
        for quark in pdg.quarks:
            if quark in ["u","D"]: 
                isospinZ += 1/2
            elif quark in ["U","d"]:  
                isospinZ -= 1/2
            elif quark == "S":
                Strangeness += 1
            elif quark == "s":
                Strangeness -= 1
            elif quark == "c":
                Charmness += 1
            elif quark == "C":
                Charmness -= 1
            elif quark == "b":
                Bottomness += 1
            elif quark == "B":
                Bottomness -= 1
            elif quark == "t":
                Topness += 1
            elif quark == "T":
                Topness -= 1
redeboer commented 4 years ago

Hmm, it's the right direction for sure, but there's at least one worry: how to determine the magnitude of isospin?

Leongrim commented 4 years ago

That you can get from pdg.I and also all the parity quantum numbers are easy accessible e.g pdg.P.

redeboer commented 4 years ago

Ah but that sounds good. Hang on, I'll create a small branch that can serve as a starting point.

redeboer commented 4 years ago

Okay guys, have a look at this branch: https://github.com/ComPWA/expertsystem/tree/23-PDG-as-source-of-truth

This is where the magic should happen: https://github.com/ComPWA/expertsystem/blob/cfcdb6de052316c6e818307c34af1ea1ecace29a/expertsystem/io/_pdg.py#L17-L43

Notice that item is a Particle instance from the scikit-hep package https://github.com/ComPWA/expertsystem/blob/cfcdb6de052316c6e818307c34af1ea1ecace29a/expertsystem/io/_pdg.py#L14-L16 So the challenge is to properly extract all attributes required for the expertsystem.data.Particle instance from item.

Leongrim commented 4 years ago

If you do if item.mass is not None: the neutrinos are getting lost.

sebastianJaeger commented 4 years ago

I just want to add that the lepton numbers are also of only very minor importance in this context, since we usually dont deal with leptons in pwa, and since there are a fixed number of 6 leptons, whose properties are very well tested, hardcoding them into the database should actually be a good option. The only thing that can reasonably be expected to change over time would be the tau branching fractions, but branching fractions in general are not yet included in the expertsystem i think.

redeboer commented 4 years ago

Ah yeah, but that's just a detail, can be removed of course.

But yes, that is the place where the logic of those if statements should happen.

redeboer commented 4 years ago

I just want to add that the lepton numbers are also of only very minor importance in this context, since we usually don't deal with leptons in pwa, and since there are a fixed number of 6 leptons

The reason why Particle carries attributes like these is that the expertsystem needs those number internally to check conservation rules. So for the outside, this info is trivial, but internally it's super important :sweat_smile:

Leongrim commented 4 years ago

What do we do about nucleus? They could be removed by all_pdg_particles = PdgDatabase.findall(lambda p: abs(p).pdgid<1e8). Sadly something like all_pdg_particles = PdgDatabase.findall(lambda p: not p.pdgid.is_nucleus) is not an option because this would remove protons and neutrons.

redeboer commented 4 years ago

Good point. Are we sure that pdgid<1e8 does not exclude particles that are of interest?

Leongrim commented 4 years ago

I don´t think so but I have to check it.