The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
PartPropSvc.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
18"""Demo-file for interactive work with new Particle Property Service"""
19
20__author__ = "Vanya BELYAEV Ivan.Belyaev@nikhef.nl"
22
23# =============================================================================
25
26# The following is misunderstood by flake8 - the import is needed as it
27# has necessary side effects
28import GaudiPartProp.Service # noqa: F401
29
30# =============================================================================
31
32from GaudiPartProp.Nodes import (
33 CC,
34 Baryon,
35 Bottom,
36 EllMinus,
37 EllPlus,
38 FiveHalf,
39 Hadron,
40 Lepton,
41 Meson,
42 Nu,
43 Tensor,
44 ThreeHalf,
45)
46from GaudiPython.Bindings import AppMgr
47
48gaudi = AppMgr()
49gaudi.initialize()
50
51
52
53def test():
54 """Simple function for the test"""
55 pps = gaudi.gaudiPartProp()
56
57 for l in range(1, 6):
58 # get
59 lst1 = pps.get(lambda x: l == x.pid().lSpin())
60 print(f" {l} == 2*lSpin+1 ")
61 print(lst1)
62
63 for s in range(0, 2):
64 # get
65 lst1 = pps.get(lambda x: s == x.pid().sSpin())
66 print(f" {s} == 2*sSpin+1 ")
67 print(lst1)
68
69 for j in range(0, 7):
70 # get
71 lst1 = pps.get(lambda x: j == x.pid().jSpin())
72 print(f" {j} == 2*jSpi+1 ")
73 print(lst1)
74
75 decays = [
76 "B0 -> K- pi+",
77 "B+ -> J/psi(1S) ( K*0 -> K+ pi- ) ",
78 "D_s+ -> pi+ pi+ pi- ",
79 "B_s0 -> ( J/psi(1S) -> mu+ mu- ) ( phi(1020) -> K+ K- ) ",
80 ]
81
82 for decay in decays:
83 print(f"Decay&CC: {decay} : {pps.cc(decay)} ")
84
85 Item = pps.Item
86 Items = pps.Items
87 Decay = pps.Decay
88 Decays = pps.Decays
89
90 items = Items()
91 items.push_back(Item("K+"))
92 items.push_back(Item("K-"))
93
94 decay = Decay(Item("B0"), items)
95
96 print(decay.validate(pps.svc()))
97
98 decays = Decays()
99 decays.push_back(decay)
100 decays.push_back(decay)
101 decays.push_back(decay)
102
103 print(decay)
104 print(decays)
105
106
107def test2():
108 pps = gaudi.gaudiPartProp()
109
110 nodes = [
111 Lepton & ~Meson,
112 EllPlus | Nu,
113 Lepton & ~Nu,
114 EllMinus | CC("B0"),
115 Hadron & Tensor,
116 Hadron & ThreeHalf,
117 Hadron & FiveHalf,
118 EllPlus | (Bottom & Baryon),
119 ]
120
121 for node in nodes:
122 node.validate(pps.svc())
123
124 lst1 = pps.get(node)
125 print(f' selected by node: "{node}" ')
126 print(lst1)
127
128
129if "__main__" == __name__:
130 test()
131 test2()
test()
simple test-function