Belle II Software  release-08-01-10
B2A504-TrackingSystematics.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
29 
30 import basf2 as b2
31 import modularAnalysis as ma
32 
33 # define systematic tests
34 sys_tests = ['def', 'scale', 'scaleUp', 'scaleDown', 'Efficiency']
35 
36 # Select the systematic variation from the list
37 test = 'scaleDown'
38 
39 if test not in sys_tests:
40  print(f"Unknown systematic test {test}")
41  exit(1)
42 
43 # create path
44 my_path = b2.create_path()
45 
46 # load input ROOT file
47 ma.inputMdst(filename=b2.find_file('JPsi2ee_e2egamma.root', 'examples', False),
48  path=my_path)
49 
50 
51 # fill particleLists
52 ma.fillParticleList(decayString='e+:sel',
53  cut='electronID > 0.2 and dr < 2 and abs(dz) < 4',
54  path=my_path)
55 
56 if test == 'def':
57  pass
58 elif test == 'scale':
59  ma.scaleTrackMomenta(inputListNames=['e+:sel'], scale=1.00056, path=my_path)
60 elif test == 'scaleUp':
61  ma.scaleTrackMomenta(inputListNames=['e+:sel'], scale=1.001, path=my_path)
62 elif test == 'scaleDown':
63  ma.scaleTrackMomenta(inputListNames=['e+:sel'], scale=0.999, path=my_path)
64 elif test == 'Efficiency':
65  ma.removeTracksForTrackingEfficiencyCalculation(inputListNames=['e+:sel'], fraction=0.01, path=my_path)
66 
67 # J/psi
68 ma.reconstructDecay(decayString='J/psi:out -> e+:sel e-:sel',
69  cut='',
70  path=my_path)
71 
72 var1 = ['M',
73  'p',
74  'E',
75  ]
76 
77 ma.variablesToNtuple(decayString='J/psi:out',
78  variables=var1,
79  filename=f'Jpsi_out_{test}.root',
80  path=my_path)
81 
82 # process the events
83 b2.process(my_path)
84 
85 # print out the summary
86 print(b2.statistics)