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