6 from basf2
import create_path, register_module, process, logging, \
7 LogLevel, Module, statistics
8 logging.log_level = LogLevel.WARNING
11 from ROOT
import TH1D, TH2D, TCanvas, Belle2, PyConfig
14 PyConfig.StartGuiThread =
True
17 h_nTracks = TH1D(
'nTracks',
'Number of Tracks per Event', 100, 0, 50)
18 h_pdg = TH1D(
'pid',
'PDG codes', 500, -250, 250)
19 h_momentum = TH1D(
'momentum',
'Momentum p; p/GeV', 200, 0, 10)
20 h_pt = TH1D(
'pt',
'Transverse Momentum p_{t};p_{t}/GeV', 200, 0, 10)
21 h_phi = TH1D(
'phi',
'azimuthal angle #phi; #phi in degree', 200, -180, 180)
22 h_theta = TH1D(
'theta',
'polar angle #theta; #theta in degree', 200, 0, 180)
23 h_costheta = TH1D(
'costheta',
'cos(#theta); cos(#theta)', 200, -1, 1)
24 h_xyvertex = TH2D(
'xyvertex',
'vertex in xy;x/#mum;y/#mum',
25 500, -500, 500, 500, -500, 500)
26 h_zxvertex = TH2D(
'zxvertex',
'vertex in zx;z/#mum;x/#mum',
27 500, -500, 500, 500, -500, 500)
28 h_zyvertex = TH2D(
'zyvertex',
'vertex in zy;z/#mum;y/#mum',
29 500, -500, 500, 500, -500, 500)
33 """Simple module to collect some information about MCParticles"""
36 """Fill the histograms with the values of the MCParticle collection"""
38 h_nTracks.Fill(mcParticles.getEntries())
39 for mc
in mcParticles:
41 h_momentum.Fill(p.Mag())
43 h_phi.Fill(p.Phi() / math.pi * 180)
44 h_theta.Fill(p.Theta() / math.pi * 180)
45 h_costheta.Fill(math.cos(p.Theta()))
46 h_pdg.Fill(mc.getPDG())
47 h_xyvertex.Fill(mc.getProductionVertex().X() * 1e4,
48 mc.getProductionVertex().Y() * 1e4)
49 h_zxvertex.Fill(mc.getProductionVertex().Z() * 1e4,
50 mc.getProductionVertex().X() * 1e4)
51 h_zyvertex.Fill(mc.getProductionVertex().Z() * 1e4,
52 mc.getProductionVertex().Y() * 1e4)
55 eventinfosetter = register_module(
'EventInfoSetter')
56 progress = register_module(
'Progress')
57 particlegun = register_module(
'ParticleGun')
58 vertexsmear = register_module(
'SmearPrimaryVertex')
62 eventinfosetter.param({
'evtNumList': [10000],
'runList': [1]})
71 'pdgCodes': [211, -211, 11, -11],
73 'momentumGeneration':
'normalPt',
75 'momentumParams': [5.0, 1.0],
77 'phiGeneration':
'normal',
79 'phiParams': [90, 30],
81 'thetaGeneration':
'uniformCos',
83 'thetaParams': [17, 150],
85 'vertexGeneration':
'fixed',
90 'independentVertices':
False,
102 'sigma_pvx': 6.18e-4,
108 'angle_pv_zx': -1.11e-2,
113 main.add_module(eventinfosetter)
114 main.add_module(progress)
115 main.add_module(particlegun)
116 main.add_module(vertexsmear)
117 main.add_module(showMCPart)
126 c = TCanvas(
'Canvas',
'Canvas', 1920, 768)
127 c.Divide(5, 2, 1e-5, 1e-5)
130 histograms = [h_nTracks, h_pdg, h_momentum, h_pt, h_theta, h_costheta, h_phi]
131 vertexhists = [h_xyvertex, h_zxvertex, h_zyvertex]
132 for (i, h)
in enumerate(histograms):
136 for (j, h)
in enumerate(vertexhists, i + 2):
142 print(
"Press Enter to exit ...")