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