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