Note
Go to the end to download the full example code
Examples for particle model
decay system is model as
- DecayGroup
DecayChain
Decay
Particle
16 import matplotlib.pyplot as plt
17
18 from tf_pwa.amp import Decay, DecayChain, DecayGroup, Particle
19 from tf_pwa.vis import plot_decay_struct
We can easy create some instance of Particle and then combine them as Decay
25 a = Particle("A")
26 b = Particle("B")
27 c = Particle("C")
28 d = Particle("D")
29
30 r = Particle("R")
31
32 dec1 = Decay(a, [r, b])
33 dec2 = Decay(r, [c, d])
DecayChain is a list of Decays.
39 decay_chain = DecayChain([dec1, dec2])
40 decay_chain
[A->R+B, R->C+D]
We can plot it using matplotlib.
45 plot_decay_struct(decay_chain)
46 plt.show()
DecayGroup is a list of DecayChain with the same initial and final states
51 decay_group = DecayGroup([decay_chain])
52 decay_group
[[A->R+B, R->C+D]]
We can build a simple function to infer the charge from final states.
58 def charge_infer(dec, charge_map):
59 # use particle equal condition
60 cached_charge = {Particle(k): v for k, v in charge_map.items()}
61 # loop for all decays in decay chain
62 for i, dec_i in dec.depth_first(False):
63 # all out particles has charge
64 assert all(i in cached_charge for i in dec_i.outs)
65 # the charge or core particle is the sum of
66 cached_charge[dec_i.core] = sum(cached_charge[i] for i in dec_i.outs)
67 return cached_charge
68
69
70 charges = {
71 "B": -1,
72 "C": 0,
73 "D": 1,
74 }
75
76 charge_infer(decay_chain, charges)
{B: -1, C: 0, D: 1, R: 1, A: 0}
See more in cal_chain_boost
.
Total running time of the script: (0 minutes 0.064 seconds)