Belle II Software light-2406-ragdoll
vertexfit.py
1#!/usr/bin/env python3
2
3
10
11import tempfile
12import basf2
13import b2test_utils
14import modularAnalysis as ma
15from vertex import kFit
16from ROOT import TFile
17
18
19def 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
36testFile = tempfile.NamedTemporaryFile()
37
38main = basf2.create_path()
39
40ma.inputMdst(b2test_utils.require_file('analysis/tests/mdst.root'), path=main)
41
42ma.fillParticleList('K-', '', path=main)
43ma.fillParticleList('pi+', '', path=main)
44
45ma.fillParticleList('gamma', '', path=main)
46ma.reconstructDecay('pi0 -> gamma gamma', '0.11 < M < 0.15', 0, path=main)
47ma.matchMCTruth('pi0', path=main)
48
49# KFit
50kFit('pi0', 0.0, path=main)
51
52ma.reconstructDecay('D0 -> K- pi+ pi0', '', 0, path=main)
53ma.matchMCTruth('D0', path=main)
54
55kFit('D0', 0.0, decay_string='D0 -> ^K- ^pi+ pi0', path=main)
56
57ntupler = basf2.register_module('VariablesToNtuple')
58ntupler.param('fileName', testFile.name)
59ntupler.param('variables', ['M', 'isSignal', 'distance', 'dr', 'dz', 'significanceOfDistance', 'pValue'])
60ntupler.param('particleList', 'D0')
61main.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