Belle II Software  release-06-01-15
B2A421-OrcaKinFit_1CFit.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
21 
22 import basf2 as b2
23 from modularAnalysis import inputMdst
24 from modularAnalysis import fillParticleList
25 from modularAnalysis import reconstructDecay
26 from modularAnalysis import matchMCTruth
27 from kinfit import UnmeasuredfitKinematic1C
28 from modularAnalysis import variablesToNtuple
29 import variables.collections as vc
30 import variables.utils as vu
31 
32 # create path
33 mypath = b2.create_path()
34 
35 b2.set_log_level(b2.LogLevel.WARNING)
36 
37 # Input file(s).
38 inputMdst(environmentType='default',
39  filename=b2.find_file('darkphotonmumu_mdst.root', 'examples', False),
40  path=mypath)
41 
42 # use standard final state particle lists for muons
43 fillParticleList('mu-:z0', 'chiProb > 0.001 and p > 1.0', path=mypath)
44 fillParticleList('mu-:z0fit', 'chiProb > 0.001 and p > 1.0', path=mypath)
45 
46 # reconstruct Z -> mu+ mu-
47 reconstructDecay('Z0:mm_rec -> mu+:z0 mu-:z0', '9.0 < M < 11.0', path=mypath)
48 reconstructDecay('Z0:mm_kinfit -> mu+:z0fit mu-:z0fit', '9.0 < M < 11.0', path=mypath)
49 
50 # MC truth matching
51 matchMCTruth('Z0:mm_rec', path=mypath)
52 matchMCTruth('Z0:mm_kinfit', path=mypath)
53 
54 # kinematic 1C hard fit
55 UnmeasuredfitKinematic1C('Z0:mm_kinfit', path=mypath)
56 
57 # Select variables that we want to store to ntuple
58 
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',
65  'OrcaKinFitChi2',
66  'OrcaKinFitErrorCode',
67  'OrcaKinFitUnmeasuredTheta',
68  'OrcaKinFitUnmeasuredPhi',
69  'OrcaKinFitUnmeasuredE'], 'extraInfo({variable})', "")
70 
71 # Saving variables to ntuple
72 output_file = 'B2A421-Orcakinfit_1CFit.root'
73 variablesToNtuple('Z0:mm_rec', z0vars,
74  filename=output_file, treename='Z0_mm_rec', path=mypath)
75 variablesToNtuple('Z0:mm_kinfit', z0uvars,
76  filename=output_file, treename='Z0_mm_kinfit', path=mypath)
77 
78 
79 # Process the events
80 b2.process(mypath)
81 
82 # print out the summary
83 print(b2.statistics)