Belle II Software development
B2A501-BremsCorrection.py
1#!/usr/bin/env python3
2
3
10
11
32
33import basf2 as b2
34import modularAnalysis as ma
35
36# create path
37my_path = b2.create_path()
38
39# load input ROOT file
40ma.inputMdst(filename=b2.find_file('JPsi2ee_e2egamma.root', 'examples', False),
41 path=my_path)
42
43
44# fill particleLists
45ma.fillParticleList(decayString='e+:uncorrected',
46 cut='electronID > 0.2 and dr < 2 and abs(dz) < 4',
47 path=my_path)
48ma.fillParticleList(decayString='gamma:bremsinput',
49 cut='E < 1.0',
50 path=my_path)
51
52# MC matching
53ma.matchMCTruth(list_name='e+:uncorrected', path=my_path)
54ma.matchMCTruth(list_name='gamma:bremsinput', path=my_path)
55
56# correction of Bremsstrahlung
57# A new lepton is generated, with the old electron and, if found, a gamma as daughters.
58# Note: the photon selection and the module parameters used here are kept simple on purpose.
59# For the current recommendation on the photon selection and the module parameters, use the
60# b2help-recommendation tool (or https://belle2.pages.desy.de/performance/recommendations/).
61ma.correctBrems(outputList='e+:corrected',
62 inputList='e+:uncorrected',
63 gammaList='gamma:bremsinput',
64 path=my_path)
65ma.matchMCTruth(list_name='e+:corrected',
66 path=my_path)
67
68# uncorrected
69ma.reconstructDecay(decayString='J/psi:uncorrected -> e+:uncorrected e-:uncorrected',
70 cut='',
71 path=my_path)
72ma.reconstructDecay(decayString='J/psi:corrected -> e+:corrected e-:corrected',
73 cut='',
74 path=my_path)
75
76# MC matching
77ma.matchMCTruth(list_name='J/psi:uncorrected', path=my_path)
78ma.matchMCTruth(list_name='J/psi:corrected', path=my_path)
79
80# get all MC particles
81ma.fillParticleListFromMC(decayString='J/psi:MC', cut="", path=my_path)
82
83# write out ntuples
84
85var0 = ['p',
86 'px',
87 'py',
88 'pz',
89 'x',
90 'y',
91 'z',
92 'electronID',
93 'PDG',
94 'mcPDG',
95 'E',
96 'mcPX',
97 'mcPY',
98 'mcPZ',
99 'mcE',
100 'pxErr',
101 'pyErr',
102 'pzErr',
103 'pErr',
104 'isSignal',
105 'mcErrors',
106 'extraInfo(bremsCorrected)'
107 ]
108var1 = ['M',
109 'p',
110 'E',
111 'x', 'y', 'z',
112 'isSignal',
113 'mcErrors',
114 'daughter(0, p)',
115 'daughter(1, p)',
116 'daughter(0, extraInfo(bremsCorrected))',
117 'daughter(1, extraInfo(bremsCorrected))'
118 ]
119
120ma.variablesToNtuple(decayString='e+:uncorrected',
121 variables=var0,
122 treename='e_uncorrected',
123 path=my_path)
124ma.variablesToNtuple(decayString='e+:corrected',
125 variables=var0,
126 treename='e_corrected',
127 path=my_path)
128ma.variablesToNtuple(decayString='J/psi:uncorrected',
129 variables=var1,
130 treename='Jpsi_uncorrected',
131 path=my_path)
132ma.variablesToNtuple(decayString='J/psi:corrected',
133 variables=var1,
134 treename='Jpsi_corrected',
135 path=my_path)
136ma.variablesToNtuple(decayString='J/psi:MC',
137 variables=var1,
138 treename='Jpsi_MC',
139 path=my_path)
140
141# process the events
142b2.process(my_path, calculateStatistics=True)