15 """A primary M with a per-step split kaon K, a split-once kaon K2 and a sibling.
17 K (set 0, weight 1) is split at t = 2..6 with decay probabilities P, two
18 clones per step. Geant4 decays it at t = 4 on a split step, so it is
19 continued by C, which ends by interacting at t = 7. Secondaries are created
20 along the line with the line's weight at that time. K2 (set 1) decays at
21 t = 3 into four clones of weight 1/4. Clones are pushed with K's mother.
23 P = {2.0: 0.2, 3.0: 0.25, 4.0: 0.3, 5.0: 0.15, 6.0: 0.4}
27 for t, p
in P.items():
28 clones += [(t, w * p / 2)] * 2
31 rows: dict[str, tuple] = {}
32 rows[
"M"] = (
None, -1, NOT_SPLIT, 0.0, 0.0, 1.0, 0)
33 rows[
"s"] = (
"M", -1, NOT_SPLIT, 0.0, 1.0, 1.0, G4)
34 rows[
"K"] = (
"M", 0, SURVIVOR, 1.0, 1.0, line[4.0], G4)
35 rows[
"C"] = (
"M", 0, SURVIVOR, 1.0, 4.0, line[6.0], K_NO_PROCESS)
36 for k, (t, wc)
in enumerate(clones):
37 rows[f
"c{k}"] = (
"M", 0, DECAY, 1.0, t, wc, K_NO_PROCESS)
38 rows[
"y1"] = (
"K", -1, NOT_SPLIT, 0.0, 2.5, line[2.0], G4)
39 rows[
"y2"] = (
"C", -1, NOT_SPLIT, 0.0, 5.5, line[5.0], G4)
40 rows[
"z"] = (
"C", -1, NOT_SPLIT, 0.0, 7.0, line[6.0], G4)
41 rows[
"mu_a"] = (
"c2", -1, NOT_SPLIT, 0.0, 3.0, clones[2][1], G4)
42 rows[
"mu_b"] = (
"c6", -1, NOT_SPLIT, 0.0, 5.0, clones[6][1], G4)
43 rows[
"K2"] = (
"M", 1, SURVIVOR, 1.0, 1.0, 1.0, G4)
45 rows[f
"d{k}"] = (
"M", 1, DECAY, 1.0, 3.0, 0.25, K_NO_PROCESS)
46 rows[
"mu_c"] = (
"d0", -1, NOT_SPLIT, 0.0, 3.0, 0.25, G4)
47 names = [n
for n
in rows
if n
not in pruned]
48 index = {n: i
for i, n
in enumerate(names)}
49 cols = [[]
for _
in range(7)]
51 mother, *rest = rows[n]
52 cols[0].append(index[mother]
if mother
is not None else -1)
53 for c, v
in zip(cols[1:], rest):
105 prov, ix, line = event
108 expected = {name: prov.weight[i]
for name, i
in ix.items()}
111 expected.update(K=1.0, K2=1.0, C=line[4.0])
112 for name, i
in ix.items():
114 tol = 4 * math.sqrt(max(p * (1 - p), 1e-12) / n) + 1e-12
115 assert rate[i] == pytest.approx(p, abs=tol), name
117 others = [i
for name, i
in ix.items()
if name
not in (
"K",
"C",
"K2",
"M")]
118 for i, j
in itertools.combinations(others, 2):
119 p = prov.pair_weight(i, j)
120 together = np.mean(keep[:, i] & keep[:, j])
121 tol = 4 * math.sqrt(max(p * (1 - p), 1e-12) / n) + 1e-12
122 assert together == pytest.approx(p, abs=tol), (i, j)
140 ROOT = root_with_shipdata
141 if not hasattr(ROOT.ShipMCTrack,
"GetSplitSet"):
142 pytest.skip(
"libShipData with split sets not available")
143 mother = ROOT.ShipMCTrack(321, -1, 0.0, 0.0, 50.0, 0.4937, 0.0, 0.0, 0.0, 1.0, 0, 0, 0, 1.0)
144 clone = ROOT.ShipMCTrack(321, -1, 0.0, 0.0, 50.0, 0.4937, 0.0, 0.0, 10.0, 2.0, 0, 0, 1, 0.5)
145 clone.SetSplitSet(0, DECAY, 1.0)
146 clone.SetProcID(K_NO_PROCESS)
147 mother.SetSplitSet(0, SURVIVOR, 1.0)
149 prov = SplitProvenance.from_tracks([mother, clone])
150 assert prov.sets[0][
"decays"] == [1]
151 assert prov.sets[0][
"survivors"] == [0]
152 assert prov.continuation.tolist() == [
False,
False]