Belle II Software  release-06-02-00
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, TLorentzVector
20 
21 
22 class MyParticleCreator(basf2.Module):
23  def initialize(self):
24  self.listB0 = Belle2.ParticleListHelper("B0:all")
25  self.listPi0 = Belle2.ParticleListHelper("pi0:all")
26  print(self.listB0.isSelfConjugated(), self.listPi0.isSelfConjugated())
27 
28  def event(self):
29  self.listB0.create()
30  self.listPi0.create()
31  for i in range(5):
32  self.listB0.addParticle(TLorentzVector(i, 0, 0, i), i % 2 == 0)
33  self.listPi0.addParticle(TLorentzVector(i, 0, 0, i), i % 2 == 0)
34 
35 
36 basf2.set_random_seed("something important")
37 path = basf2.create_path()
38 path.add_module("EventInfoSetter", evtNumList=[2])
39 path.add_module(MyParticleCreator())
40 path.add_module("ParticlePrinter", listName="B0:all")
41 path.add_module("ParticlePrinter", listName="pi0:all")
42 basf2.process(path)
43 
44 # @endcond
Class to help managing creation and adding to ParticleLists.