14 from basf2
import create_path, register_module, process, logging, \
15 LogLevel, Module, statistics
18 from ROOT
import TH1D, TH2D, TCanvas, Belle2, PyConfig
20 logging.log_level = LogLevel.WARNING
22 PyConfig.StartGuiThread =
True
25 h_nTracks = TH1D(
'nTracks',
'Number of Tracks per Event', 100, 0, 50)
26 h_pdg = TH1D(
'pid',
'PDG codes', 500, -250, 250)
27 h_momentum = TH1D(
'momentum',
'Momentum p; p/GeV', 200, 0, 10)
28 h_pt = TH1D(
'pt',
'Transverse Momentum p_{t};p_{t}/GeV', 200, 0, 10)
29 h_phi = TH1D(
'phi',
'azimuthal angle #phi; #phi in degree', 200, -180, 180)
30 h_theta = TH1D(
'theta',
'polar angle #theta; #theta in degree', 200, 0, 180)
31 h_costheta = TH1D(
'costheta',
'cos(#theta); cos(#theta)', 200, -1, 1)
32 h_xyvertex = TH2D(
'xyvertex',
'vertex in xy;x/#mum;y/#mum',
33 500, -500, 500, 500, -500, 500)
34 h_zxvertex = TH2D(
'zxvertex',
'vertex in zx;z/#mum;x/#mum',
35 500, -500, 500, 500, -500, 500)
36 h_zyvertex = TH2D(
'zyvertex',
'vertex in zy;z/#mum;y/#mum',
37 500, -500, 500, 500, -500, 500)
41 """Simple module to collect some information about MCParticles"""
44 """Fill the histograms with the values of the MCParticle collection"""
46 h_nTracks.Fill(mcParticles.getEntries())
47 for mc
in mcParticles:
49 h_momentum.Fill(p.Mag())
51 h_phi.Fill(p.Phi() / math.pi * 180)
52 h_theta.Fill(p.Theta() / math.pi * 180)
53 h_costheta.Fill(math.cos(p.Theta()))
54 h_pdg.Fill(mc.getPDG())
55 h_xyvertex.Fill(mc.getProductionVertex().X() * 1e4,
56 mc.getProductionVertex().Y() * 1e4)
57 h_zxvertex.Fill(mc.getProductionVertex().Z() * 1e4,
58 mc.getProductionVertex().X() * 1e4)
59 h_zyvertex.Fill(mc.getProductionVertex().Z() * 1e4,
60 mc.getProductionVertex().Y() * 1e4)
64 eventinfosetter = register_module(
'EventInfoSetter')
65 progress = register_module(
'Progress')
66 particlegun = register_module(
'ParticleGun')
67 vertexsmear = register_module(
'SmearPrimaryVertex')
71 eventinfosetter.param({
'evtNumList': [10000],
'runList': [1]})
80 'pdgCodes': [211, -211, 11, -11],
82 'momentumGeneration':
'normalPt',
84 'momentumParams': [5.0, 1.0],
86 'phiGeneration':
'normal',
88 'phiParams': [90, 30],
90 'thetaGeneration':
'uniformCos',
92 'thetaParams': [17, 150],
94 'vertexGeneration':
'fixed',
99 'independentVertices':
False,
111 'sigma_pvx': 6.18e-4,
117 'angle_pv_zx': -1.11e-2,
123 main.add_module(eventinfosetter)
124 main.add_module(progress)
125 main.add_module(particlegun)
126 main.add_module(vertexsmear)
127 main.add_module(showMCPart)
136 c = TCanvas(
'Canvas',
'Canvas', 1920, 768)
137 c.Divide(5, 2, 1e-5, 1e-5)
140 histograms = [h_nTracks, h_pdg, h_momentum, h_pt, h_theta, h_costheta, h_phi]
141 vertexhists = [h_xyvertex, h_zxvertex, h_zyvertex]
142 for (i, h)
in enumerate(histograms):
146 for (j, h)
in enumerate(vertexhists, i + 2):
152 print(
"Press Enter to exit ...")
A (simplified) python wrapper for StoreArray.