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

Make the particle isospin property return a float #196

Merged
merged 3 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions particle/data/mass_width_2008_ext.fwf
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@
* See the full table for descriptions of fields.
*
*MASS(MeV) ,Err+ ,Err- ,WIDTH(MeV) ,Err+ ,Err- ,I ,G,J ,P,C,A,PDG-MC ,Chrg,R,S,Name ,Quarks
0 ,0 ,0 ,0 ,0 ,0 ,0 , ,1/2 , , ,F, 12, 0, ,D,nu(e) ,
0 ,0 ,0 ,0 ,0 ,0 ,0 , ,1/2 , , ,F, 14, 0, ,D,nu(mu) ,
0 ,0 ,0 ,0 ,0 ,0 ,0 , ,1/2 , , ,F, 16, 0, ,D,nu(tau) ,
0 ,0 ,0 ,0 ,0 ,0 ,0 , ,1 ,-, , , 21, 0, ,R,g ,
0 ,0 ,0 ,0 ,0 ,0 , , ,1/2 , , ,F, 12, 0, ,D,nu(e) ,
0 ,0 ,0 ,0 ,0 ,0 , , ,1/2 , , ,F, 14, 0, ,D,nu(mu) ,
0 ,0 ,0 ,0 ,0 ,0 , , ,1/2 , , ,F, 16, 0, ,D,nu(tau) ,
0 ,0 ,0 ,0 ,0 ,0 , , ,1 ,-, , , 21, 0, ,R,g ,
0 ,0 ,0 ,0 ,0 ,0 , , ,1 ,-,-, , 22, 0, ,R,gamma ,
0 ,0 ,0 ,0 ,0 ,0 , , ,0 , , , , 25, 0, ,R,H ,
0 ,0 ,0 ,0 ,0 ,0 ,1 ,-,1 ,-, ,B,9000213, +, ,R,pi(1)(1400) ,Maybe non-qQ
0 ,0 ,0 ,0 ,0 ,0 ,1 ,-,1 ,-,+, ,9000113, 0, ,R,pi(1)(1400) ,Maybe non-qQ
Expand Down
16 changes: 8 additions & 8 deletions particle/data/particle2019.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ ID,Mass,MassUpper,MassLower,Width,WidthUpper,WidthLower,I,G,P,C,Anti,Charge,Rank
-6,173100,900,900,1420,190,150,0,5,1,5,1,-2,0,0,t,T,\bar{t}
11,0.5109989461,3.1e-09,3.1e-09,0,0,0,,5,5,5,2,-3,0,0,e,,e^{-}
-11,0.5109989461,3.1e-09,3.1e-09,0,0,0,,5,5,5,2,3,0,0,e,,e^{+}
12,0,0,0,0,0,0,0,5,5,5,1,0,0,1,nu(e),,\nu_{e}
-12,0,0,0,0,0,0,0,5,5,5,1,0,0,1,nu(e),,\bar{\nu}_{e}
12,0,0,0,0,0,0,,5,5,5,1,0,0,1,nu(e),,\nu_{e}
-12,0,0,0,0,0,0,,5,5,5,1,0,0,1,nu(e),,\bar{\nu}_{e}
13,105.6583745,2.4e-06,2.4e-06,2.9959847e-16,3e-22,3e-22,,5,5,5,2,-3,0,0,mu,,\mu^{-}
-13,105.6583745,2.4e-06,2.4e-06,2.9959847e-16,3e-22,3e-22,,5,5,5,2,3,0,0,mu,,\mu^{+}
14,0,0,0,0,0,0,0,5,5,5,1,0,0,1,nu(mu),,\nu_{\mu}
-14,0,0,0,0,0,0,0,5,5,5,1,0,0,1,nu(mu),,\bar{\nu}_{\mu}
14,0,0,0,0,0,0,,5,5,5,1,0,0,1,nu(mu),,\nu_{\mu}
-14,0,0,0,0,0,0,,5,5,5,1,0,0,1,nu(mu),,\bar{\nu}_{\mu}
15,1776.86,0.12,0.12,2.267e-09,4e-12,4e-12,,5,5,5,2,-3,0,0,tau,,\tau^{-}
-15,1776.86,0.12,0.12,2.267e-09,4e-12,4e-12,,5,5,5,2,3,0,0,tau,,\tau^{+}
16,0,0,0,0,0,0,0,5,5,5,1,0,0,1,nu(tau),,\nu_{\tau}
-16,0,0,0,0,0,0,0,5,5,5,1,0,0,1,nu(tau),,\bar{\nu}_{\tau}
21,0,0,0,0,0,0,0,5,-1,5,0,0,0,0,g,,g
22,0,0,0,0,0,0,<2,5,-1,-1,0,0,0,0,gamma,,\gamma
16,0,0,0,0,0,0,,5,5,5,1,0,0,1,nu(tau),,\nu_{\tau}
-16,0,0,0,0,0,0,,5,5,5,1,0,0,1,nu(tau),,\bar{\nu}_{\tau}
21,0,0,0,0,0,0,,5,-1,5,0,0,0,0,g,,g
22,0,0,0,0,0,0,,5,-1,-1,0,0,0,0,gamma,,\gamma
23,91187.6,2.1,2.1,2495.2,2.3,2.3,,5,5,5,0,0,0,0,Z,,Z^{0}
24,80379,12,12,2085,42,42,,5,5,5,2,3,0,0,W,,W^{+}
-24,80379,12,12,2085,42,42,,5,5,5,2,-3,0,0,W,,W^{-}
Expand Down
14 changes: 12 additions & 2 deletions particle/particle/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class InvalidParticle(RuntimeError):
pass


def _isospin_converter(isospin):
vals = {
"0": 0.,
"1/2": 0.5,
"1": 1.0,
"3/2": 1.5
}
return vals.get(isospin, None)


@total_ordering
@attr.s(slots=True, cmp=False, repr=False)
class Particle(object):
Expand Down Expand Up @@ -156,7 +166,7 @@ class Particle(object):
width_upper = attr.ib(-1, converter=lambda v: None if v < 0 else v)
width_lower = attr.ib(-1, converter=lambda v: None if v < 0 else v)
_three_charge = attr.ib(Charge.u, converter=Charge) # charge * 3
I = attr.ib(None)
I = attr.ib(None, converter=_isospin_converter)
# J = attr.ib(None) # Total angular momentum
G = attr.ib(Parity.u, converter=Parity) # Parity: '', +, -, or ?
P = attr.ib(Parity.u, converter=Parity) # Space parity
Expand Down Expand Up @@ -537,7 +547,7 @@ def _charge_in_name(self):
if self.pdgid in (9000113, 9010113): return True # special particles not yet well-known in the 2018 table
# Lambda baryons
if (self.pdgid.is_baryon
and _digit(self.pdgid, Location.Nq2) == 1 and self.I == '0' # 1st check alone is not sufficient to filter out lowest-ground Sigma's
and _digit(self.pdgid, Location.Nq2) == 1 and self.I == 0. # 1st check alone is not sufficient to filter out lowest-ground Sigma's
and self.pdgid.has_strange
and not (self.pdgid.has_charm or self.pdgid.has_bottom or self.pdgid.has_top)
):
Expand Down
30 changes: 30 additions & 0 deletions tests/particle/test_particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,36 @@ def test_spin_type(pid, stype):
assert particle.spin_type == stype


checklist_isospin = (
# Quarks
(1, 0.5), # d
# Gauge bosons
(22, None), # photon
(23, None), # Z0
# Leptons
(11, None), # e-
(-12, None), # nu(e)_bar
# Mesons
(211, 1.0), # pi+
(310, 0.5), # K_S
(-421, 0.5), # D0_bar
(333, 0.0), # phi(1020)
(443, 0.0), # J/psi
(521, 0.5), # B+
(531, 0.0), # Bs
# Baryons
(2212, 0.5), # proton
(2214, 1.5), # Delta+
)


@pytest.mark.parametrize("pid,isospin", checklist_isospin)
def test_isospin(pid, isospin):
particle = Particle.from_pdgid(pid)

assert particle.I == isospin


def test_default_particle():
p = Particle.empty()

Expand Down