Belle II Software  release-08-01-10
B2A422-OrcaKinFit_3CFit.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 fitKinematic3C
29 from modularAnalysis import variablesToNtuple
30 import variables.collections as vc
31 import variables.utils as vu
32 from stdPhotons import stdPhotons
33 import pdg
34 
35 # create path
36 mypath = b2.create_path()
37 
38 b2.set_log_level(b2.LogLevel.WARNING)
39 
40 # Input file(s).
41 inputMdst(filename=b2.find_file('darkphotonmumu_mdst.root', 'examples', False),
42  path=mypath)
43 
44 # Creates a list of photons
45 stdPhotons('loose', path=mypath)
46 
47 # use standard final state particle lists for muons
48 fillParticleList('mu-:z0', 'chiProb > 0.001 and p > 1.0', path=mypath)
49 
50 # reconstruct Z -> mu+ mu-
51 reconstructDecay('Z0:mm -> mu+:z0 mu-:z0', '', path=mypath)
52 
53 
54 pdg.add_particle('beam', 9000009, 999., 999., 0, 0) # name, PDG, mass, width, charge, spin
55 reconstructDecay("beam:rec -> gamma:loose Z0:mm", "", path=mypath)
56 reconstructDecay("beam:kinfit -> gamma:loose Z0:mm", "", path=mypath)
57 
58 
59 # MC truth matching
60 matchMCTruth('beam:rec', path=mypath)
61 matchMCTruth('beam:kinfit', path=mypath)
62 
63 # kinematic 3C hard fit
64 fitKinematic3C('beam:kinfit', path=mypath)
65 
66 # Select variables that we want to store to ntuple
67 
68 mugvars = vc.inv_mass + vc.kinematics + vc.mc_truth + vc.mc_kinematics + vc.momentum_uncertainty
69 z0vars = vc.inv_mass + vc.kinematics + vc.mc_kinematics + vc.mc_truth + \
70  vu.create_aliases_for_selected(mugvars, 'beam -> ^gamma [^Z0 -> ^mu+ ^mu-]')
71 
72 z0uvars = z0vars + ['OrcaKinFitProb', 'OrcaKinFitChi2', 'OrcaKinFitErrorCode']
73 
74 # Saving variables to ntuple
75 output_file = 'B2A422-Orcakinfit_3CFit.root'
76 variablesToNtuple('beam:rec', z0vars,
77  filename=output_file, treename='Z0_mm_rec', path=mypath)
78 variablesToNtuple('beam:kinfit', z0uvars,
79  filename=output_file, treename='Z0_mm_kinfit', path=mypath)
80 
81 # Process the events
82 b2.process(mypath)
83 
84 # print out the summary
85 print(b2.statistics)
def add_particle(name, pdgCode, mass, width, charge, spin, max_width=None, lifetime=0, pythiaID=0, define_anti_particle=False)
Definition: pdg.py:134