Belle II Software development
ParticleStatisticsModule Class Reference
Inheritance diagram for ParticleStatisticsModule:

Public Member Functions

def __init__ (self)
 
def initialize (self)
 
def event (self)
 
def terminate (self)
 

Public Attributes

 tfile
 save statistics in here
 

Detailed Description

Collect statistics on particles - also parallel processable

Definition at line 58 of file register_pystorearray.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
set module flags

Definition at line 61 of file register_pystorearray.py.

61 def __init__(self):
62 """set module flags"""
63 super().__init__()
64 self.set_property_flags(
65 basf2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED |
66 basf2.ModulePropFlags.TERMINATEINALLPROCESSES)
67

Member Function Documentation

◆ event()

def event (   self)
actually collect info

Definition at line 98 of file register_pystorearray.py.

98 def event(self):
99 """actually collect info"""
100 ntuple = Belle2.PyStoreObj("ParticleMomenta", Belle2.DataStore.c_Persistent)
101 hist = Belle2.PyStoreObj("AbsMomentum", Belle2.DataStore.c_Persistent)
102
103 mcParticles = Belle2.PyStoreArray(Belle2.MCParticle.Class())
104
105 for mcParticle in mcParticles:
106 momentum = mcParticle.getMomentum()
107 ntuple.get().Fill(momentum.X(),
108 momentum.Y(),
109 momentum.Z())
110
111 hist.get().Fill(momentum.Mag())
112
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67

◆ initialize()

def initialize (   self)
init

Definition at line 68 of file register_pystorearray.py.

68 def initialize(self):
69 """init"""
70
71 self.tfile = ROOT.TFile("ParticleStatistics.root", "recreate")
72
73 ntuple = Belle2.PyStoreObj(Belle2.RootMergeable("TNtuple").Class(), "ParticleMomenta", Belle2.DataStore.c_Persistent)
74 ntuple.registerInDataStore()
75 print("IsValid", ntuple.isValid())
76 ntuple.create()
77 print("IsValid", ntuple.isValid())
78 ntuple.obj().assign(ROOT.TNtuple("Particles", # ROOT name
79 "Momentum compontents of the particles", # ROOT title
80 "px:py:pz" # Var list
81 ))
82
83 hist = Belle2.PyStoreObj(Belle2.RootMergeable("TH1D").Class(), "AbsMomentum", Belle2.DataStore.c_Persistent)
84 hist.registerInDataStore()
85 print("IsValid", hist.isValid())
86 hist.create()
87 print("IsValid", hist.isValid())
88 hist.obj().assign(ROOT.TH1D("AbsMomentum", # ROOT name
89 "Absolute momentum of particles", # ROOT title
90 20, # n bins
91 0, # upper bound
92 2 # lower bound
93 ))
94
95 print("IsValid", ntuple.isValid())
96 print("IsValid", hist.isValid())
97
Wrap a root histogram or TNtuple to make it mergeable.
Definition: RootMergeable.h:61

◆ terminate()

def terminate (   self)
terminate

Definition at line 113 of file register_pystorearray.py.

113 def terminate(self):
114 """terminate"""
117 print("Writting objects")
118 ntuple = Belle2.PyStoreObj("ParticleMomenta", Belle2.DataStore.c_Persistent)
119 ntuple.write(self.tfile)
120
121 hist = Belle2.PyStoreObj("AbsMomentum", Belle2.DataStore.c_Persistent)
122 hist.write(self.tfile)
123
124 self.tfile.Close()
125
126
static bool isOutputProcess()
Return true if the process is an output process.
Definition: ProcHandler.cc:232
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
Definition: ProcHandler.cc:226

Member Data Documentation

◆ tfile

tfile

save statistics in here

Definition at line 71 of file register_pystorearray.py.


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