The Gaudi Framework  master (181af51f)
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
22from __future__ import print_function
23
24# =============================================================================
25__author__ = "Vanya BELYAEV <Ivan.Belyaev@nikhef.nl>"
26__version__ = ""
27# =============================================================================
28
29# Workaround for ROOT-10769
30import warnings
31
32with warnings.catch_warnings():
33 warnings.simplefilter("ignore")
34 import cppyy
35
36import GaudiPython
37
38# namespaces shortcuts
39Decays = cppyy.gbl.Gaudi.Decays
40std = cppyy.gbl.std
41Gaudi = GaudiPython.gbl.Gaudi
42
43
44# =============================================================================
45
46def _decorate(nodes, opers):
47 """
48 Decorate the functions
49 """
50
51
52 if hasattr(opers, "__call__"):
53
54 def _call_(self, arg):
55 """
56 Evaluate the functor
57
58 >>> fun = ... # get the functor
59 >>> arg = ... # get the argument
60 >>> res = fun ( arg )
61 """
62 result = opers.__call__(self, arg)
63 return True if result else False
64
65 _call_.__doc__ = opers.__call__.__doc__
66
67
68 if hasattr(opers, "__or__"):
69
70 def _or_(self, arg):
71 """
72 LOGICAL or
73
74 >>> fun1 = ... # get the functor
75 >>> fun2 = ... # get the functor
76 >>> fun = fun1 | fun2
77 """
78 return opers.__or__(self, arg)
79
80 _or_.__doc__ = opers.__or__.__doc__
81
82
83 if hasattr(opers, "__ror__"):
84
85 def _ror_(self, arg):
86 """
87 LOGICAL or
88
89 >>> fun1 = ... # get the functor
90 >>> fun2 = ... # get the functor
91 >>> fun = fun1 | fun2
92 """
93 return opers.__ror__(self, arg)
94
95 _or_.__doc__ = opers.__or__.__doc__
96
97
98 if hasattr(opers, "__and__"):
99
100 def _and_(self, arg):
101 """
102 LOGICAL and
103
104 >>> fun1 = ... # get the functor
105 >>> fun2 = ... # get the functor
106 >>> fun = fun1 & fun2
107 """
108 return opers.__and__(self, arg)
109
110 _and_.__doc__ = opers.__and__.__doc__
111
112
113 if hasattr(opers, "__rand__"):
114
115 def _rand_(self, arg):
116 """
117 LOGICAL and
118
119 >>> fun1 = ... # get the functor
120 >>> fun2 = ... # get the functor
121 >>> fun = fun1 & fun2
122 """
123 return opers.__rand__(self, arg)
124
125 _rand_.__doc__ = opers.__rand__.__doc__
126
127
128 if hasattr(opers, "__invert__"):
129
130 def _invert_(self, *arg):
131 """
132 LOGICAL negation
133
134 >>> fun1 = ... # get the functor
135 >>> fun = ~fun2
136 """
137 return opers.__invert__(self, *arg)
138
139 _invert_.__doc__ = opers.__invert__.__doc__
140
141
142 if hasattr(opers, "__rshift__"):
143
144 def _rshift_(self, arg):
145 """
146 Streamers
147
148 >>> fun1 = ... # get the functor
149 >>> fun1 = ... # get the functor
150 >>> fun = fun1 >> fun2
151 """
152 return opers.__rshift__(self, arg)
153
154 _rshift_.__doc__ = opers.__rshift__.__doc__
155
156
157 if hasattr(opers, "__rrshift__"):
158
159 def _rrshift_(self, arg):
160 """
161 Evaluate the functor as streametr shift
162
163 >>> fun = ... # get the functor
164 >>> arg = ... # get the argument
165 >>> res = arg >> fun
166 """
167 result = opers.__rrshift__(self, arg)
168 return True if result else False
169
170 _rrshift_.__doc__ = opers.__rrshift__.__doc__
171
172 for node in nodes:
173 if _call_:
174 node.__call__ = _call_
175 if _or_:
176 node.__or__ = _or_
177 if _ror_:
178 node.__ror__ = _ror_
179 if _and_:
180 node.__and__ = _and_
181 if _rand_:
182 node.__rand__ = _rand_
183 if _rshift_:
184 node.__rshift__ = _rshift_
185 if _rrshift_:
186 node.__rrshift__ = _rrshift_
187 if _invert_:
188 node.__invert__ = _invert_
189
190 node.__repr__ = lambda s: s.toString()
191 node.__str__ = lambda s: s.toString()
192
193 return nodes
194
195
196
197_decorated = _decorate(
198 (
201 #
205 #
235 #
239 ),
241 opers=Decays.Dict.NodeOps,
242)
243
244
245
248#
249Any = Decays.Nodes.Any() # instance
252Lepton = Decays.Nodes.Lepton() # instance
253Nu = Decays.Nodes.Nu() # instance
254Ell = Decays.Nodes.Ell() # instance
255EllPlus = Decays.Nodes.EllPlus() # instance
256EllMinus = Decays.Nodes.EllMinus() # instance
257Hadron = Decays.Nodes.Hadron() # instance
258Meson = Decays.Nodes.Meson() # instance
259Baryon = Decays.Nodes.Baryon() # instance
260Charged = Decays.Nodes.Charged() # instance
261Positive = Decays.Nodes.Positive() # instance
262Negative = Decays.Nodes.Negative() # instance
263Neutral = Decays.Nodes.Neutral() # instance
264HasQuark = Decays.Nodes.HasQuark # type
265JSpin = Decays.Nodes.JSpin # type
266SSpin = Decays.Nodes.SSpin # type
267LSpin = Decays.Nodes.LSpin # type
268Nucleus = Decays.Nodes.Nucleus() # instance
272Invalid = Decays.Nodes.Invalid() # instance
273_Node = Decays.Nodes._Node # type
274
275PosId = Decays.Nodes.PosID() # instance
276NegId = Decays.Nodes.NegID() # instance
277
278Up = HasQuark(Gaudi.ParticleID.up)
279Down = HasQuark(Gaudi.ParticleID.down)
280Strange = HasQuark(Gaudi.ParticleID.strange)
281Charm = HasQuark(Gaudi.ParticleID.charm)
282Beauty = HasQuark(Gaudi.ParticleID.bottom)
283Bottom = HasQuark(Gaudi.ParticleID.bottom)
284Top = HasQuark(Gaudi.ParticleID.top)
285
286Xu = HasQuark(Gaudi.ParticleID.up)
287Xd = HasQuark(Gaudi.ParticleID.down)
288Xs = HasQuark(Gaudi.ParticleID.strange)
289Xc = HasQuark(Gaudi.ParticleID.charm)
290Xb = HasQuark(Gaudi.ParticleID.bottom)
291Xb = HasQuark(Gaudi.ParticleID.bottom)
292Xt = HasQuark(Gaudi.ParticleID.top)
293
294Scalar = JSpin(1)
295Spinor = JSpin(2)
296Vector = JSpin(3)
297Tensor = JSpin(5)
298
299OneHalf = JSpin(2)
300ThreeHalf = JSpin(4)
301FiveHalf = JSpin(6)
302
303CTau = Decays.Nodes.CTau # type
304LongLived_ = Decays.Nodes.LongLived_ # type
305LongLived = Decays.Nodes.LongLived_() # instance
306ShortLived_ = Decays.Nodes.ShortLived_ # type
307ShortLived = Decays.Nodes.ShortLived_() # instance
308Stable = Decays.Nodes.Stable() # instance
309StableCharged = Decays.Nodes.StableCharged() # instance
310Mass = Decays.Nodes.Mass # type
311Light = Decays.Nodes.Light # type
312Heavy = Decays.Nodes.Heavy # type
313Symbol = Decays.Nodes.Symbol # type
314
316
317if "__main__" == __name__:
318 print(" decorated objects: %s " % str(_decorated))
319 print(_decorated)
320 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:46
represent simple predicate for Long-lived particles
Definition NodesPIDs.h:507