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