Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use particle package to get PDG data #114

Merged
merged 7 commits into from
Aug 1, 2020

Conversation

peterstangl
Copy link
Collaborator

This PR replaces the functions for reading PDG data files by an interface to the python package particle as suggested and discussed in isse #112.

The main changes are:

  • Particles are now identified by their flavio_name, which is the name used e.g. in the mass parameters, and by their PDG IDs. Translating the former into the latter is done using the pdg_particles dictionary, replacing the old lists pdg_include and pdg_translate.
  • Masses and widths are now obtained from particle. PDG data files and the old function _read_pdg_masswidth are removed.
  • The latex names are now obtained from particle, but simplified using the new _pdg_tex_simplify function. The result is equivalent to the one of the old _pdg_particle_string_to_tex function, which is removed.
  • New tests are added that check the masses and latex names of all particles currently contained in pdg_particles.

@coveralls
Copy link

coveralls commented Jul 31, 2020

Coverage Status

Coverage increased (+0.002%) to 93.876% when pulling 2b8e496 on peterstangl:particles into b91383c on flav-io:master.

sub = m.group(2)
sup = (m.group(3) or '') + (m.group(5) or '')
par = m.group(4)
if sub or name in 'W Z H e \\mu \\tau':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be name in ["W", "Z", ...]? I think "\\mu" in "\\mu" is False since it iterates character by characters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"\\mu" in "\\mu" is True since in tests for substring containment (cf. https://docs.python.org/3/reference/expressions.html#membership-test-details).
But I agree that it's maybe not a good idea to just test for substring containment since e.g. also names a, u, and au would be in '\\tau'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right, sorry! But yeah, list might still be better.

if sub or name in 'W Z H e \\mu \\tau':
# remove superscripts +-0 and keep only *
sup = '*' if '*' in sup else ''
if not sub and par and par.upper().isupper() and par not in '1S':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in "1S" matches everything except 1 and S

Copy link
Collaborator Author

@peterstangl peterstangl Jul 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I think this should maybe better be ... and name != 'J/\\psi'.
The idea was to add a subscript with what is inside the parentheses of the latex name in case this is more than just a number (usually corresponding to the mass) and if there is no other subscript. So e.g. 'D^{*}(2007)^{0}' becomes'D^{*0}' since the parentheses contain only a number, but '\\psi(2S)' becomes '\\psi_{2S}' since the parentheses do not contain only a number. (Checking the content of the parentheses is currently done using par.upper().isupper() but should probably better be done by not par.isdigit())
The only exception from this rule is 'J/\\psi(1S)', which should become 'J/\\psi'. So I guess it's clearer to apply this exception only to 'J/\\psi' and not to anything contained 1S.

@DavidMStraub
Copy link
Contributor

Great! Possibly all the particle-specific stuff could be collected in a class (e.g. class FlavioParticle(Particle)), which would allow to make the read_pdg much more concise. Just a thought.

@peterstangl
Copy link
Collaborator Author

Great! Possibly all the particle-specific stuff could be collected in a class (e.g. class FlavioParticle(Particle)), which would allow to make the read_pdg much more concise. Just a thought.

This is a very good idea and I have now moved everything to the new FlavioParticle class in commit da46a40.
Since it is a class, should it be moved to flavio.classes?
I'm also not sure what to do with the pdg_particles dictionary. In principle this is more like a config setting that one could move to a yaml file. Do you have a good idea in which file this could fit?

@DavidMStraub
Copy link
Contributor

Nice!

Since it is a class, should it be moved to flavio.classes?

I think it's fine... classes is anyway a bit of a silly name for a module. There are also classes in other modules like probability.

I'm also not sure what to do with the pdg_particles dictionary. In principle this is more like a config setting that one could move to a yaml file. Do you have a good idea in which file this could fit?

It's a constant and it's only needed by the class, so I think it naturally fits as a class attribute:

class FlavioParticle(Particle):
    """..."""

    PDG_PARTICLES = {...}

which can be accessed as cls.PDG_PARTICLES in the class methods and self.PDG_PARTICLES in the instance methods.

@peterstangl
Copy link
Collaborator Author

It's a constant and it's only needed by the class, so I think it naturally fits as a class attribute:

Yes, I agree and have implemented this in 0582522.
In 2b8e496, I now also added the class method flavio_all, which returns a set of all instances used in flavio. This simplifies looping over the particles, as e.g. done in the read_pdg function.

This now looks quite complete and I would merge this PR soon.

@peterstangl peterstangl merged commit 1f8b010 into flav-io:master Aug 1, 2020
@peterstangl peterstangl deleted the particles branch August 1, 2020 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants