Belle II Software  release-06-01-15
test7_treeFitterFitResolution_Fit.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 <header>
14  <output>../TreeFitted_B0ToJPsiKs.root</output>
15  <contact>Jo-Frederik Krohn; jkrohn@student.unimelb.edu.au</contact>
16  <interval>nightly</interval>
17 </header>
18 """
19 
20 # Reconstruct B0 to J/PsiKs using the TreeFitter. Use the ..._Plot.py
21 # to plot the resolutions.
22 
23 from basf2 import create_path, process, statistics, set_random_seed
24 
25 from modularAnalysis import inputMdst, reconstructDecay, fillParticleList, matchMCTruth
26 import os
27 from vertex import treeFit
28 
29 import sys
30 
31 path = create_path()
32 set_random_seed('#BAADF00D')
33 
34 if 'BELLE2_VALIDATION_DATA_DIR' not in os.environ:
35  sys.exit(0)
36 inputFile = os.path.join(os.environ['BELLE2_VALIDATION_DATA_DIR'], 'analysis/prerel04_eph3_BGx1_b2jpsiks.root')
37 inputMdst('default', inputFile, path=path)
38 
39 
40 fillParticleList('pi+:all', '', path=path)
41 fillParticleList('mu+:all', '', path=path)
42 
43 reconstructDecay('K_S0:pipi -> pi+:all pi-:all', 'dM<0.25', path=path)
44 reconstructDecay('J/psi:mumu -> mu+:all mu-:all', 'dM<0.11', path=path)
45 reconstructDecay('B0:jpsiks -> J/psi:mumu K_S0:pipi', 'Mbc > 5.27 and abs(deltaE)<0.2', path=path)
46 
47 matchMCTruth('B0:jpsiks', path=path)
48 
49 treeFit(
50  list_name='B0:jpsiks',
51  conf_level=-1,
52  updateAllDaughters=True,
53  path=path,
54 )
55 
56 variables = [
57  'isSignal', # B0
58  'M',
59  'InvM',
60  'chiProb',
61 
62  'p',
63  'mcP',
64  'pErr',
65  'E',
66  'mcE',
67  'E_uncertainty',
68 
69  'x',
70  'y',
71  'z',
72  'x_uncertainty',
73  'y_uncertainty',
74  'z_uncertainty',
75  'mcDecayVertexX',
76  'mcDecayVertexY',
77  'mcDecayVertexZ',
78 ]
79 
80 path.add_module('VariablesToNtuple',
81  treeName='B0TreeFit',
82  particleList='B0:jpsiks',
83  variables=variables,
84  fileName='../TreeFitted_B0ToJPsiKs.root')
85 
86 process(path)
87 
88 print(statistics)