19 Simple 'decorator for nodes'
22 from __future__
import print_function
25 __author__ =
"Vanya BELYAEV <Ivan.Belyaev@nikhef.nl>"
32 with warnings.catch_warnings():
33 warnings.simplefilter(
"ignore")
39 Decays = cppyy.gbl.Gaudi.Decays
41 Gaudi = GaudiPython.gbl.Gaudi
48 Decorate the functions
52 if hasattr(opers,
"__call__"):
54 def _call_(self, arg):
58 >>> fun = ... # get the functor
59 >>> arg = ... # get the argument
62 result = opers.__call__(self, arg)
63 return True if result
else False
65 _call_.__doc__ = opers.__call__.__doc__
68 if hasattr(opers,
"__or__"):
74 >>> fun1 = ... # get the functor
75 >>> fun2 = ... # get the functor
78 return opers.__or__(self, arg)
80 _or_.__doc__ = opers.__or__.__doc__
83 if hasattr(opers,
"__ror__"):
89 >>> fun1 = ... # get the functor
90 >>> fun2 = ... # get the functor
93 return opers.__ror__(self, arg)
95 _or_.__doc__ = opers.__or__.__doc__
98 if hasattr(opers,
"__and__"):
100 def _and_(self, arg):
104 >>> fun1 = ... # get the functor
105 >>> fun2 = ... # get the functor
106 >>> fun = fun1 & fun2
108 return opers.__and__(self, arg)
110 _and_.__doc__ = opers.__and__.__doc__
113 if hasattr(opers,
"__rand__"):
115 def _rand_(self, arg):
119 >>> fun1 = ... # get the functor
120 >>> fun2 = ... # get the functor
121 >>> fun = fun1 & fun2
123 return opers.__rand__(self, arg)
125 _rand_.__doc__ = opers.__rand__.__doc__
128 if hasattr(opers,
"__invert__"):
130 def _invert_(self, *arg):
134 >>> fun1 = ... # get the functor
137 return opers.__invert__(self, *arg)
139 _invert_.__doc__ = opers.__invert__.__doc__
142 if hasattr(opers,
"__rshift__"):
144 def _rshift_(self, arg):
148 >>> fun1 = ... # get the functor
149 >>> fun1 = ... # get the functor
150 >>> fun = fun1 >> fun2
152 return opers.__rshift__(self, arg)
154 _rshift_.__doc__ = opers.__rshift__.__doc__
157 if hasattr(opers,
"__rrshift__"):
159 def _rrshift_(self, arg):
161 Evaluate the functor as streametr shift
163 >>> fun = ... # get the functor
164 >>> arg = ... # get the argument
167 result = opers.__rrshift__(self, arg)
168 return True if result
else False
170 _rrshift_.__doc__ = opers.__rrshift__.__doc__
174 node.__call__ = _call_
182 node.__rand__ = _rand_
184 node.__rshift__ = _rshift_
186 node.__rrshift__ = _rrshift_
188 node.__invert__ = _invert_
190 node.__repr__ =
lambda s: s.toString()
191 node.__str__ =
lambda s: s.toString()
209 Decays.Nodes.EllPlus,
210 Decays.Nodes.EllMinus,
214 Decays.Nodes.Charged,
215 Decays.Nodes.Positive,
216 Decays.Nodes.Negative,
217 Decays.Nodes.Neutral,
218 Decays.Nodes.HasQuark,
222 Decays.Nodes.Nucleus,
224 Decays.Nodes.ShortLived_,
225 Decays.Nodes.LongLived_,
227 Decays.Nodes.StableCharged,
233 Decays.Nodes.Invalid,
241 opers=Decays.Dict.NodeOps,
249 Any = Decays.Nodes.Any()
250 Pid = Decays.Nodes.Pid
252 Lepton = Decays.Nodes.Lepton()
253 Nu = Decays.Nodes.Nu()
254 Ell = Decays.Nodes.Ell()
255 EllPlus = Decays.Nodes.EllPlus()
256 EllMinus = Decays.Nodes.EllMinus()
257 Hadron = Decays.Nodes.Hadron()
258 Meson = Decays.Nodes.Meson()
259 Baryon = Decays.Nodes.Baryon()
260 Charged = Decays.Nodes.Charged()
261 Positive = Decays.Nodes.Positive()
262 Negative = Decays.Nodes.Negative()
263 Neutral = Decays.Nodes.Neutral()
264 HasQuark = Decays.Nodes.HasQuark
265 JSpin = Decays.Nodes.JSpin
266 SSpin = Decays.Nodes.SSpin
267 LSpin = Decays.Nodes.LSpin
268 Nucleus = Decays.Nodes.Nucleus()
270 And = Decays.Nodes.And
271 Not = Decays.Nodes.Not
272 Invalid = Decays.Nodes.Invalid()
273 _Node = Decays.Nodes._Node
275 PosId = Decays.Nodes.PosID()
276 NegId = Decays.Nodes.NegID()
291 Xb =
HasQuark(Gaudi.ParticleID.bottom)
303 CTau = Decays.Nodes.CTau
304 LongLived_ = Decays.Nodes.LongLived_
305 LongLived = Decays.Nodes.LongLived_()
306 ShortLived_ = Decays.Nodes.ShortLived_
307 ShortLived = Decays.Nodes.ShortLived_()
308 Stable = Decays.Nodes.Stable()
309 StableCharged = Decays.Nodes.StableCharged()
310 Mass = Decays.Nodes.Mass
311 Light = Decays.Nodes.Light
312 Heavy = Decays.Nodes.Heavy
313 Symbol = Decays.Nodes.Symbol
317 if "__main__" == __name__:
318 print(
" decorated objects: %s " % str(_decorated))