Belle II Software  release-08-01-10
particlelisthelper.py
1 #!/usr/bin/env python3
2 
3 
10 
11 """
12 Simple script to create some particles in a list with a python module
13 """
14 
15 # Go away doxygen, no one likes you
16 # @cond
17 
18 import basf2
19 from ROOT import Belle2
20 from ROOT.Math import PxPyPzEVector
21 
22 
23 class MyParticleCreator(basf2.Module):
24  def initialize(self):
25  self.listB0 = Belle2.ParticleListHelper("B0:all")
26  self.listPi0 = Belle2.ParticleListHelper("pi0:all")
27  print(self.listB0.isSelfConjugated(), self.listPi0.isSelfConjugated())
28 
29  def event(self):
30  self.listB0.create()
31  self.listPi0.create()
32  for i in range(5):
33  self.listB0.addParticle(PxPyPzEVector(i, 0, 0, i), i % 2 == 0)
34  self.listPi0.addParticle(PxPyPzEVector(i, 0, 0, i), i % 2 == 0)
35 
36 
37 basf2.set_random_seed("something important")
38 path = basf2.create_path()
39 path.add_module("EventInfoSetter", evtNumList=[2])
40 path.add_module(MyParticleCreator())
41 path.add_module("ParticlePrinter", listName="B0:all")
42 path.add_module("ParticlePrinter", listName="pi0:all")
43 basf2.process(path)
44 
45 # @endcond
Class to help managing creation and adding to ParticleLists.