Belle II Software  release-06-00-14
B2A420-OrcaKinFit.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
22 
23 import basf2 as b2
24 from modularAnalysis import inputMdst
25 from modularAnalysis import fillParticleList
26 from modularAnalysis import reconstructDecay
27 from modularAnalysis import matchMCTruth
28 from kinfit import fitKinematic4C
29 from modularAnalysis import variablesToNtuple
30 import variables.collections as vc
31 import variables.utils as vu
32 
33 # create path
34 mypath = b2.create_path()
35 
36 b2.set_log_level(b2.LogLevel.WARNING)
37 
38 # Input file(s).
39 inputMdst(environmentType='default',
40  filename=b2.find_file('B2A424-SimulateMuonPairs.root', 'examples', False),
41  path=mypath)
42 
43 # use standard final state particle lists for muons
44 fillParticleList('mu-:z0', 'chiProb > 0.001 and p > 1.0', path=mypath)
45 fillParticleList('mu-:z0fit', 'chiProb > 0.001 and p > 1.0', path=mypath)
46 
47 # reconstruct Z -> mu+ mu-
48 reconstructDecay('Z0:mm_rec -> mu+:z0 mu-:z0', '9.0 < M < 11.0', path=mypath)
49 reconstructDecay('Z0:mm_kinfit -> mu+:z0fit mu-:z0fit', '9.0 < M < 11.0', path=mypath)
50 
51 # MC truth matching
52 matchMCTruth('Z0:mm_rec', path=mypath)
53 matchMCTruth('Z0:mm_kinfit', path=mypath)
54 
55 # kinematic 4C hard fit
56 fitKinematic4C('Z0:mm_kinfit', path=mypath)
57 
58 # Select variables that we want to store to ntuple
59 muvars = vc.kinematics + vc.mc_truth + vc.mc_kinematics + vc.momentum_uncertainty
60 z0vars = vc.inv_mass + vc.kinematics + vc.mc_kinematics + vc.mc_truth + \
61  vu.create_aliases_for_selected(muvars, 'Z0 -> ^mu+ ^mu-')
62 
63 z0uvars = z0vars + \
64  vu.create_aliases(['OrcaKinFitProb', 'OrcaKinFitChi2', 'OrcaKinFitErrorCode'], 'extraInfo({variable})', "")
65 
66 
67 # Saving variables to ntuple
68 output_file = 'B2A420-OrcaKinFit.root'
69 variablesToNtuple('Z0:mm_rec', z0vars,
70  filename=output_file, treename='Z0_mm_rec', path=mypath)
71 variablesToNtuple('Z0:mm_kinfit', z0uvars,
72  filename=output_file, treename='Z0_mm_kinfit', path=mypath)
73 
74 
75 # Process the events
76 b2.process(mypath)
77 
78 # print out the summary
79 print(b2.statistics)