Belle II Software development
TestTreeFits Class Reference
Inheritance diagram for TestTreeFits:

Public Member Functions

def testFit (self)
 

Detailed Description

The unit test case for TreeFitter

Definition at line 18 of file treeFit_referenced_ignore_charged.py.

Member Function Documentation

◆ testFit()

def testFit (   self)
Run the test fit

Definition at line 21 of file treeFit_referenced_ignore_charged.py.

21 def testFit(self):
22 """Run the test fit"""
23
24 testFile = tempfile.NamedTemporaryFile()
25
26 main = basf2.create_path()
27
28 inputfile = b2test_utils.require_file('analysis/B0ToPiPiPi0.root', 'validation', py_case=self)
29 ma.inputMdst(inputfile, path=main)
30
31 ma.fillParticleList('pi+:a', 'pionID > 0.5', path=main)
32
33 ma.fillParticleList('gamma:a', '', path=main)
34 ma.reconstructDecay('pi0:a -> gamma:a gamma:a', '0.125 < InvM < 0.145', 0, path=main)
35
36 ma.reconstructDecay('B0:rec -> pi-:a pi+:a pi0:a', '', 0, path=main)
37 ma.matchMCTruth('B0:rec', path=main)
38
39 conf = 0
40 main.add_module('TreeFitter',
41 particleList='B0:rec',
42 confidenceLevel=conf,
43 massConstraintList=[],
44 massConstraintListParticlename=[],
45 expertUseReferencing=True,
46 ipConstraint=True,
47 updateAllDaughters=True,
48 ignoreFromVertexFit='B0 -> ^pi- pi+ pi0')
49
50 ntupler = basf2.register_module('VariablesToNtuple')
51 ntupler.param('fileName', testFile.name)
52 ntupler.param('variables', ['chiProb', 'M', 'isSignal', 'Mbc'])
53 ntupler.param('particleList', 'B0:rec')
54 main.add_module(ntupler)
55
56 basf2.process(main)
57
58 ntuplefile = TFile(testFile.name)
59 ntuple = ntuplefile.Get('ntuple')
60
61 self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
62
63 allBkg = ntuple.GetEntries("isSignal == 0")
64 allSig = ntuple.GetEntries("isSignal > 0")
65 SigMbcReasonable = ntuple.GetEntries("isSignal > 0 && Mbc > 5.27")
66
67 truePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal > 0)")
68 falsePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 0)")
69
70 mustBeZero = ntuple.GetEntries(f"(chiProb < {conf})")
71
72 print(f"True fit survivors: {truePositives} out of {allSig} true candidates")
73 print(f"False fit survivors: {falsePositives} out of {allBkg} false candidates")
74
75 self.assertTrue(falsePositives < 8837, "Background rejection too small.")
76
77 self.assertTrue(truePositives > 212, "Signal rejection too high")
78 self.assertFalse(mustBeZero, f"We should have dropped all candidates with confidence level less than {conf}.")
79
80 self.assertTrue(SigMbcReasonable > 206, "Signal kinematics is wrongly reconstructed too much")
81
82 print("Test passed, cleaning up.")
83
84
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54

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