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