Belle II Software  release-06-01-15
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(environmentType='default',
42  filename=b2.find_file('darkphotonmumu_mdst.root', 'examples', False),
43  path=mypath)
44 
45 # Creates a list of photons
46 stdPhotons('loose', path=mypath)
47 
48 # use standard final state particle lists for muons
49 fillParticleList('mu-:z0', 'chiProb > 0.001 and p > 1.0', path=mypath)
50 
51 # reconstruct Z -> mu+ mu-
52 reconstructDecay('Z0:mm -> mu+:z0 mu-:z0', '', path=mypath)
53 
54 
55 pdg.add_particle('beam', 9000009, 999., 999., 0, 0) # name, PDG, mass, width, charge, spin
56 reconstructDecay("beam:rec -> gamma:loose Z0:mm", "", path=mypath)
57 reconstructDecay("beam:kinfit -> gamma:loose Z0:mm", "", path=mypath)
58 
59 
60 # MC truth matching
61 matchMCTruth('beam:rec', path=mypath)
62 matchMCTruth('beam:kinfit', path=mypath)
63 
64 # kinematic 3C hard fit
65 fitKinematic3C('beam:kinfit', path=mypath)
66 
67 # Select variables that we want to store to ntuple
68 
69 mugvars = vc.inv_mass + vc.kinematics + vc.mc_truth + vc.mc_kinematics + vc.momentum_uncertainty
70 z0vars = vc.inv_mass + vc.kinematics + vc.mc_kinematics + vc.mc_truth + \
71  vu.create_aliases_for_selected(mugvars, 'beam -> ^gamma [^Z0 -> ^mu+ ^mu-]')
72 
73 z0uvars = z0vars + \
74  vu.create_aliases(['OrcaKinFitProb',
75  'OrcaKinFitChi2',
76  'OrcaKinFitErrorCode'], 'extraInfo({variable})', "")
77 
78 # Saving variables to ntuple
79 output_file = 'B2A422-Orcakinfit_3CFit.root'
80 variablesToNtuple('beam:rec', z0vars,
81  filename=output_file, treename='Z0_mm_rec', path=mypath)
82 variablesToNtuple('beam:kinfit', z0uvars,
83  filename=output_file, treename='Z0_mm_kinfit', path=mypath)
84 
85 # Process the events
86 b2.process(mypath)
87 
88 # print out the summary
89 print(b2.statistics)
def add_particle(name, pdgCode, mass, width, charge, spin, max_width=None, lifetime=0, pythiaID=0)
Definition: pdg.py:133