Belle II Software light-2406-ragdoll
SillyGeneratorModule Class Reference
Inheritance diagram for SillyGeneratorModule:
Collaboration diagram for SillyGeneratorModule:

Public Member Functions

def initialize (self)
 
def event (self)
 

Detailed Description

Small module to demonstrate how the registration of StoreArrays works from Python

Definition at line 23 of file register_pystorearray.py.

Member Function Documentation

◆ event()

def event (   self)
 Access and fill the registered StoreArray 

Definition at line 31 of file register_pystorearray.py.

31 def event(self):
32 """ Access and fill the registered StoreArray """
33 # Alternative access by name
34 mcParticles = Belle2.PyStoreArray("MCParticles")
35 mcParticle = mcParticles.appendNew()
36
37 # Fill one test muon for demonstration
38 vertex = ROOT.TVector3(0, 0, 0)
39
40 # Sample a random momentum vector of
41 # gaus distributed length and uniform distibuted direction
42 phi = ROOT.gRandom.Uniform(0.0, 2.0 * math.pi)
43 costheta = ROOT.gRandom.Uniform(-1.0, 1.0)
44 theta = math.acos(costheta)
45 momentum = ROOT.Math.XYZVector(math.sin(theta) * math.cos(phi), math.sin(theta) * math.sin(phi), costheta)
46
47 mcParticle.setPDG(13)
48 mcParticle.setMassFromPDG()
49 mcParticle.addStatus(Belle2.MCParticle.c_PrimaryParticle)
50 mcParticle.addStatus(Belle2.MCParticle.c_StableInGenerator)
51 mcParticle.setProductionVertex(vertex)
52 mcParticle.setMomentum(momentum)
53 m = mcParticle.getMass()
54 mcParticle.setEnergy(math.sqrt(momentum * momentum + m * m))
55 mcParticle.setDecayTime(float("inf"))
56
57
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ initialize()

def initialize (   self)
 Register a StoreArray on the DataStore

Definition at line 26 of file register_pystorearray.py.

26 def initialize(self):
27 """ Register a StoreArray on the DataStore"""
28 mcParticles = Belle2.PyStoreArray(Belle2.MCParticle.Class())
29 mcParticles.registerInDataStore()
30

The documentation for this class was generated from the following file: