Belle II Software  release-08-01-10
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(filename=b2.find_file('JPsi2ee_e2egamma.root', 'examples', False),
41  path=my_path)
42 
43 
44 # fill particleLists
45 ma.fillParticleList(decayString='e+:uncorrected',
46  cut='electronID > 0.2 and dr < 2 and abs(dz) < 4',
47  path=my_path)
48 ma.fillParticleList(decayString='gamma:bremsinput',
49  cut='E < 1.0',
50  path=my_path)
51 
52 # MC matching
53 ma.matchMCTruth(list_name='e+:uncorrected', path=my_path)
54 ma.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 ma.correctBrems(outputList='e+:corrected',
59  inputList='e+:uncorrected',
60  gammaList='gamma:bremsinput',
61  path=my_path)
62 ma.matchMCTruth(list_name='e+:corrected',
63  path=my_path)
64 
65 # uncorrected
66 ma.reconstructDecay(decayString='J/psi:uncorrected -> e+:uncorrected e-:uncorrected',
67  cut='',
68  path=my_path)
69 ma.reconstructDecay(decayString='J/psi:corrected -> e+:corrected e-:corrected',
70  cut='',
71  path=my_path)
72 
73 # MC matching
74 ma.matchMCTruth(list_name='J/psi:uncorrected', path=my_path)
75 ma.matchMCTruth(list_name='J/psi:corrected', path=my_path)
76 
77 # get all MC particles
78 ma.fillParticleListFromMC(decayString='J/psi:MC', cut="", path=my_path)
79 
80 # write out ntuples
81 
82 var0 = ['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  ]
105 var1 = ['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 
117 ma.variablesToNtuple(decayString='e+:uncorrected',
118  variables=var0,
119  treename='e_uncorrected',
120  path=my_path)
121 ma.variablesToNtuple(decayString='e+:corrected',
122  variables=var0,
123  treename='e_corrected',
124  path=my_path)
125 ma.variablesToNtuple(decayString='J/psi:uncorrected',
126  variables=var1,
127  treename='Jpsi_uncorrected',
128  path=my_path)
129 ma.variablesToNtuple(decayString='J/psi:corrected',
130  variables=var1,
131  treename='Jpsi_corrected',
132  path=my_path)
133 ma.variablesToNtuple(decayString='J/psi:MC',
134  variables=var1,
135  treename='Jpsi_MC',
136  path=my_path)
137 
138 # process the events
139 b2.process(my_path)
140 
141 # print out the summary
142 print(b2.statistics)