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.
58ma.correctBrems(outputList='e+:corrected',
59 inputList='e+:uncorrected',
60 gammaList='gamma:bremsinput',
61 path=my_path)
62ma.matchMCTruth(list_name='e+:corrected',
63 path=my_path)
64
65# uncorrected
66ma.reconstructDecay(decayString='J/psi:uncorrected -> e+:uncorrected e-:uncorrected',
67 cut='',
68 path=my_path)
69ma.reconstructDecay(decayString='J/psi:corrected -> e+:corrected e-:corrected',
70 cut='',
71 path=my_path)
72
73# MC matching
74ma.matchMCTruth(list_name='J/psi:uncorrected', path=my_path)
75ma.matchMCTruth(list_name='J/psi:corrected', path=my_path)
76
77# get all MC particles
78ma.fillParticleListFromMC(decayString='J/psi:MC', cut="", path=my_path)
79
80# write out ntuples
81
82var0 = ['p',
83 'px',
84 'py',
85 'pz',
86 'x',
87 'y',
88 'z',
89 'electronID',
90 'PDG',
91 'mcPDG',
92 'E',
93 'mcPX',
94 'mcPY',
95 'mcPZ',
96 'mcE',
97 'pxErr',
98 'pyErr',
99 'pzErr',
100 'pErr',
101 'isSignal',
102 'mcErrors',
103 'extraInfo(bremsCorrected)'
104 ]
105var1 = ['M',
106 'p',
107 'E',
108 'x', 'y', 'z',
109 'isSignal',
110 'mcErrors',
111 'daughter(0, p)',
112 'daughter(1, p)',
113 'daughter(0, extraInfo(bremsCorrected))',
114 'daughter(1, extraInfo(bremsCorrected))'
115 ]
116
117ma.variablesToNtuple(decayString='e+:uncorrected',
118 variables=var0,
119 treename='e_uncorrected',
120 path=my_path)
121ma.variablesToNtuple(decayString='e+:corrected',
122 variables=var0,
123 treename='e_corrected',
124 path=my_path)
125ma.variablesToNtuple(decayString='J/psi:uncorrected',
126 variables=var1,
127 treename='Jpsi_uncorrected',
128 path=my_path)
129ma.variablesToNtuple(decayString='J/psi:corrected',
130 variables=var1,
131 treename='Jpsi_corrected',
132 path=my_path)
133ma.variablesToNtuple(decayString='J/psi:MC',
134 variables=var1,
135 treename='Jpsi_MC',
136 path=my_path)
137
138# process the events
139b2.process(my_path)
140
141# print out the summary
142print(b2.statistics)