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