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