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