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