The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Nodes.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
18"""
19Simple 'decorator for nodes'
20"""
21
22# =============================================================================
23__author__ = "Vanya BELYAEV <Ivan.Belyaev@nikhef.nl>"
24__version__ = ""
25# =============================================================================
26
27# Workaround for ROOT-10769
28import warnings
29
30with warnings.catch_warnings():
31 warnings.simplefilter("ignore")
32 import cppyy
33
34import GaudiPython
35
36# namespaces shortcuts
37Decays = cppyy.gbl.Gaudi.Decays
38std = cppyy.gbl.std
39Gaudi = GaudiPython.gbl.Gaudi
40
41
42# =============================================================================
43
44def _decorate(nodes, opers):
45 """
46 Decorate the functions
47 """
48
49
50 if hasattr(opers, "__call__"):
51
52 def _call_(self, arg):
53 """
54 Evaluate the functor
55
56 >>> fun = ... # get the functor
57 >>> arg = ... # get the argument
58 >>> res = fun ( arg )
59 """
60 result = opers.__call__(self, arg)
61 return True if result else False
62
63 _call_.__doc__ = opers.__call__.__doc__
64
65
66 if hasattr(opers, "__or__"):
67
68 def _or_(self, arg):
69 """
70 LOGICAL or
71
72 >>> fun1 = ... # get the functor
73 >>> fun2 = ... # get the functor
74 >>> fun = fun1 | fun2
75 """
76 return opers.__or__(self, arg)
77
78 _or_.__doc__ = opers.__or__.__doc__
79
80
81 if hasattr(opers, "__ror__"):
82
83 def _ror_(self, arg):
84 """
85 LOGICAL or
86
87 >>> fun1 = ... # get the functor
88 >>> fun2 = ... # get the functor
89 >>> fun = fun1 | fun2
90 """
91 return opers.__ror__(self, arg)
92
93 _or_.__doc__ = opers.__or__.__doc__
94
95
96 if hasattr(opers, "__and__"):
97
98 def _and_(self, arg):
99 """
100 LOGICAL and
101
102 >>> fun1 = ... # get the functor
103 >>> fun2 = ... # get the functor
104 >>> fun = fun1 & fun2
105 """
106 return opers.__and__(self, arg)
107
108 _and_.__doc__ = opers.__and__.__doc__
109
110
111 if hasattr(opers, "__rand__"):
112
113 def _rand_(self, arg):
114 """
115 LOGICAL and
116
117 >>> fun1 = ... # get the functor
118 >>> fun2 = ... # get the functor
119 >>> fun = fun1 & fun2
120 """
121 return opers.__rand__(self, arg)
122
123 _rand_.__doc__ = opers.__rand__.__doc__
124
125
126 if hasattr(opers, "__invert__"):
127
128 def _invert_(self, *arg):
129 """
130 LOGICAL negation
131
132 >>> fun1 = ... # get the functor
133 >>> fun = ~fun2
134 """
135 return opers.__invert__(self, *arg)
136
137 _invert_.__doc__ = opers.__invert__.__doc__
138
139
140 if hasattr(opers, "__rshift__"):
141
142 def _rshift_(self, arg):
143 """
144 Streamers
145
146 >>> fun1 = ... # get the functor
147 >>> fun1 = ... # get the functor
148 >>> fun = fun1 >> fun2
149 """
150 return opers.__rshift__(self, arg)
151
152 _rshift_.__doc__ = opers.__rshift__.__doc__
153
154
155 if hasattr(opers, "__rrshift__"):
156
157 def _rrshift_(self, arg):
158 """
159 Evaluate the functor as streametr shift
160
161 >>> fun = ... # get the functor
162 >>> arg = ... # get the argument
163 >>> res = arg >> fun
164 """
165 result = opers.__rrshift__(self, arg)
166 return True if result else False
167
168 _rrshift_.__doc__ = opers.__rrshift__.__doc__
169
170 for node in nodes:
171 if _call_:
172 node.__call__ = _call_
173 if _or_:
174 node.__or__ = _or_
175 if _ror_:
176 node.__ror__ = _ror_
177 if _and_:
178 node.__and__ = _and_
179 if _rand_:
180 node.__rand__ = _rand_
181 if _rshift_:
182 node.__rshift__ = _rshift_
183 if _rrshift_:
184 node.__rrshift__ = _rrshift_
185 if _invert_:
186 node.__invert__ = _invert_
187
188 node.__repr__ = lambda s: s.toString()
189 node.__str__ = lambda s: s.toString()
190
191 return nodes
192
193
194
195_decorated = _decorate(
196 (
199 #
203 #
233 #
237 ),
239 opers=Decays.Dict.NodeOps,
240)
241
242
243
246#
247Any = Decays.Nodes.Any() # instance
250Lepton = Decays.Nodes.Lepton() # instance
251Nu = Decays.Nodes.Nu() # instance
252Ell = Decays.Nodes.Ell() # instance
253EllPlus = Decays.Nodes.EllPlus() # instance
254EllMinus = Decays.Nodes.EllMinus() # instance
255Hadron = Decays.Nodes.Hadron() # instance
256Meson = Decays.Nodes.Meson() # instance
257Baryon = Decays.Nodes.Baryon() # instance
258Charged = Decays.Nodes.Charged() # instance
259Positive = Decays.Nodes.Positive() # instance
260Negative = Decays.Nodes.Negative() # instance
261Neutral = Decays.Nodes.Neutral() # instance
262HasQuark = Decays.Nodes.HasQuark # type
263JSpin = Decays.Nodes.JSpin # type
264SSpin = Decays.Nodes.SSpin # type
265LSpin = Decays.Nodes.LSpin # type
266Nucleus = Decays.Nodes.Nucleus() # instance
270Invalid = Decays.Nodes.Invalid() # instance
271_Node = Decays.Nodes._Node # type
272
273PosId = Decays.Nodes.PosID() # instance
274NegId = Decays.Nodes.NegID() # instance
275
276Up = HasQuark(Gaudi.ParticleID.up)
277Down = HasQuark(Gaudi.ParticleID.down)
278Strange = HasQuark(Gaudi.ParticleID.strange)
279Charm = HasQuark(Gaudi.ParticleID.charm)
280Beauty = HasQuark(Gaudi.ParticleID.bottom)
281Bottom = HasQuark(Gaudi.ParticleID.bottom)
282Top = HasQuark(Gaudi.ParticleID.top)
283
284Xu = HasQuark(Gaudi.ParticleID.up)
285Xd = HasQuark(Gaudi.ParticleID.down)
286Xs = HasQuark(Gaudi.ParticleID.strange)
287Xc = HasQuark(Gaudi.ParticleID.charm)
288Xb = HasQuark(Gaudi.ParticleID.bottom)
289Xb = HasQuark(Gaudi.ParticleID.bottom)
290Xt = HasQuark(Gaudi.ParticleID.top)
291
292Scalar = JSpin(1)
293Spinor = JSpin(2)
294Vector = JSpin(3)
295Tensor = JSpin(5)
296
297OneHalf = JSpin(2)
298ThreeHalf = JSpin(4)
299FiveHalf = JSpin(6)
300
301CTau = Decays.Nodes.CTau # type
302LongLived_ = Decays.Nodes.LongLived_ # type
303LongLived = Decays.Nodes.LongLived_() # instance
304ShortLived_ = Decays.Nodes.ShortLived_ # type
305ShortLived = Decays.Nodes.ShortLived_() # instance
306Stable = Decays.Nodes.Stable() # instance
307StableCharged = Decays.Nodes.StableCharged() # instance
308Mass = Decays.Nodes.Mass # type
309Light = Decays.Nodes.Light # type
310Heavy = Decays.Nodes.Heavy # type
311Symbol = Decays.Nodes.Symbol # type
312
314
315if "__main__" == __name__:
316 print(f" decorated objects: {_decorated} ")
317 print(_decorated)
318 print(dir())
The generic class to hold the pointer to other node.
Definition iNode.h:74
Helper structure (especially it is light version node-holder the default constructor.
Definition Nodes.h:96
the rather simple (but powerful) node in the decay tree: it matches .AND.
Definition Nodes.h:270
the most simple node in the decay tree: it matches to all valid the Gaudi::Particles
Definition NodesPIDs.h:34
The trivial node : it match the Baryon.
Definition NodesPIDs.h:231
The simple node in the decay tree: it matches to a certain particle ID or its antiparticle.
Definition NodesPIDs.h:94
simple pid-checker for particle lifetime (in c*tau units)
Definition NodesPIDs.h:406
The trivial node : it match the Charged.
Definition NodesPIDs.h:246
The trivial node : it match any charged lepton.
Definition NodesPIDs.h:151
The trivial node : it match any negative lepton.
Definition NodesPIDs.h:184
The trivial node : it match any positive lepton.
Definition NodesPIDs.h:168
The trivial node : it match the Hadron.
Definition NodesPIDs.h:201
The trivial node : it match the quark content.
Definition NodesPIDs.h:321
simple pid-checker for particle mass
Definition NodesPIDs.h:589
the most simple node to represent the invalid node it matches to all valid the Gaudi::Particles
Definition Nodes.h:74
The trivial node : it match the 2J+1 spin.
Definition NodesPIDs.h:342
The trivial node : it match the 2L+1 spin.
Definition NodesPIDs.h:389
The trivial node : it match the Lepton.
Definition NodesPIDs.h:119
simple pid-checker for particle mass
Definition NodesPIDs.h:573
simple pid-checker for particle mass
Definition NodesPIDs.h:555
The trivial node : it match the meson.
Definition NodesPIDs.h:216
The trivial node : it match the negatively charged particles.
Definition NodesPIDs.h:276
The trivial node : it match the Neutral.
Definition NodesPIDs.h:291
Simple node which match "NOT" for the subnode.
Definition Nodes.h:309
The trivial node : it match any neutral lepton.
Definition NodesPIDs.h:134
The trivial node : it match the Nucleus.
Definition NodesPIDs.h:306
the rather simple (but powerful) node in the decay tree: it matches .OR.
Definition Nodes.h:227
The simple node in the decay tree: it matches to a certain particle ID.
Definition NodesPIDs.h:54
The trivial node : it match the positively charged particles.
Definition NodesPIDs.h:261
The trivial node : it match the 2S+1 spin.
Definition NodesPIDs.h:372
represent simple predicate for short-lived particles
Definition NodesPIDs.h:490
represent simple predicate for Stable+Charged particles
Definition NodesPIDs.h:538
represent simple predicate for Stable particles
Definition NodesPIDs.h:523
The abstract class which represents the single "node" of decay tree.
Definition iNode.h:35
_decorate(nodes, opers)
Decorate the nodes.
Definition Nodes.py:44
represent simple predicate for Long-lived particles
Definition NodesPIDs.h:507