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