Belle II Software light-2406-ragdoll
TestTreeFits Class Reference
Inheritance diagram for TestTreeFits:
Collaboration diagram for TestTreeFits:

Public Member Functions

def testFit (self)
 

Detailed Description

The unit test case for TreeFitter

Definition at line 22 of file treeFit_referenced_klong.py.

Member Function Documentation

◆ testFit()

def testFit (   self)
Run the test fit

Definition at line 25 of file treeFit_referenced_klong.py.

25 def testFit(self):
26 """Run the test fit"""
27
28 basf2.set_random_seed('klong')
29 testFile = tempfile.NamedTemporaryFile()
30
31 main = basf2.create_path()
32
33 ma.inputMdstList([basf2.find_file('B02JpsiKL_Jpsi2mumu.root', 'examples', False)], path=main)
34
35 ma.fillParticleList('mu+:sig', 'muonID > 0.5', path=main)
36 stdKlongs('allklm', path=main)
37
38 ma.reconstructDecay('J/psi:mumu -> mu-:sig mu+:sig', '3.08 < M < 3.12', path=main)
39 ma.reconstructDecay('B0:sig -> J/psi:mumu K_L0:allklm', '', path=main)
40 ma.matchMCTruth('B0:sig', path=main)
41
42 conf = -1
43 main.add_module('TreeFitter',
44 particleList='B0:sig',
45 confidenceLevel=conf,
46 massConstraintList=[],
47 massConstraintListParticlename=['B0'],
48 expertUseReferencing=True,
49 ipConstraint=True,
50 updateAllDaughters=True)
51
52 ntupler = basf2.register_module('VariablesToNtuple')
53 ntupler.param('fileName', testFile.name)
54 ntupler.param('variables', ['chiProb', 'isSignal', 'Mbc', 'deltaE', 'dz'])
55 ntupler.param('particleList', 'B0:sig')
56 main.add_module(ntupler)
57
58 basf2.process(main)
59
60 ntuplefile = TFile(testFile.name)
61 ntuple = ntuplefile.Get('ntuple')
62
63 self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
64
65 allSig = ntuple.GetEntries("isSignal == 1")
66 allBkg = ntuple.GetEntries("isSignal == 0")
67
68 truePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 1)")
69 falsePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 0)")
70
71 SigDeltaEReasonable = ntuple.GetEntries("isSignal==1 && deltaE<0.1 && chiProb>0")
72
73 print(f"True fit survivors: {truePositives} out of {allSig} true candidates")
74 print(f"False fit survivors: {falsePositives} out of {allBkg} false candidates")
75 print(f"True fit survivors with reasonable deltaE: {SigDeltaEReasonable}")
76
77 self.assertTrue(falsePositives == 1247, "Background rejection too small.")
78 self.assertTrue(truePositives == 319, "Signal rejection too high")
79
80 self.assertTrue(SigDeltaEReasonable == 273, "Signal kinematics is wrongly reconstructed too much")
81
82 print("Test passed, cleaning up.")
83
84

The documentation for this class was generated from the following file: