Belle II Software  release-08-01-10
vertexfit.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import tempfile
12 import basf2
13 import b2test_utils
14 import modularAnalysis as ma
15 from vertex import kFit
16 from ROOT import TFile
17 
18 
19 def check(filename):
20  """
21  Verify results make sense.
22  """
23  ntuplefile = TFile(filename)
24  ntuple = ntuplefile.Get('ntuple')
25 
26  if ntuple.GetEntries() == 0:
27  basf2.B2FATAL("No D0s saved")
28 
29  if ntuple.GetEntries("significanceOfDistance < 0 && significanceOfDistance != -1") > 0:
30  basf2.B2FATAL("Some entries have negative significanceOfDistance?")
31 
32  if ntuple.GetEntries("significanceOfDistance > 0") == 0:
33  basf2.B2FATAL("significanceOfDistance never positive?")
34 
35 
36 testFile = tempfile.NamedTemporaryFile()
37 
38 main = basf2.create_path()
39 
40 ma.inputMdst(b2test_utils.require_file('analysis/tests/mdst.root'), path=main)
41 
42 ma.fillParticleList('K-', '', path=main)
43 ma.fillParticleList('pi+', '', path=main)
44 
45 ma.fillParticleList('gamma', '', path=main)
46 ma.reconstructDecay('pi0 -> gamma gamma', '0.11 < M < 0.15', 0, path=main)
47 ma.matchMCTruth('pi0', path=main)
48 
49 # KFit
50 kFit('pi0', 0.0, path=main)
51 
52 ma.reconstructDecay('D0 -> K- pi+ pi0', '', 0, path=main)
53 ma.matchMCTruth('D0', path=main)
54 
55 kFit('D0', 0.0, decay_string='D0 -> ^K- ^pi+ pi0', path=main)
56 
57 ntupler = basf2.register_module('VariablesToNtuple')
58 ntupler.param('fileName', testFile.name)
59 ntupler.param('variables', ['M', 'isSignal', 'distance', 'dr', 'dz', 'significanceOfDistance', 'pValue'])
60 ntupler.param('particleList', 'D0')
61 main.add_module(ntupler)
62 
65  check(testFile.name)
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54
def clean_working_directory()
Definition: __init__.py:189
def safe_process(*args, **kwargs)
Definition: __init__.py:236