Belle II Software development
particlelisthelper.py
1#!/usr/bin/env python3
2
3
10
11"""
12Simple 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
18import basf2
19from ROOT import Belle2
20from ROOT.Math import PxPyPzEVector
21
22
23class 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
37basf2.set_random_seed("something important")
38path = basf2.create_path()
39path.add_module("EventInfoSetter", evtNumList=[2])
40path.add_module(MyParticleCreator())
41path.add_module("ParticlePrinter", listName="B0:all")
42path.add_module("ParticlePrinter", listName="pi0:all")
43basf2.process(path)
44
45# @endcond
Class to help managing creation and adding to ParticleLists.