The unit test case for TreeFitter
Definition at line 14 of file treeFit_referenced_charged_tree_2dBeam.py.
◆ testFit()
Run the test fit
Definition at line 17 of file treeFit_referenced_charged_tree_2dBeam.py.
18 """Run the test fit"""
20 testFile = tempfile.NamedTemporaryFile()
22 main = basf2.create_path()
25 'analysis/1000_B_DstD0Kpi_skimmed.root',
'validation', py_case=self)
26 ma.inputMdst(
'default', inputfile, path=main)
28 ma.fillParticleList(
'pi+:a',
'pidProbabilityExpert(211, ALL) > 0.5', path=main)
29 ma.fillParticleList(
'K+:a',
'pidProbabilityExpert(321, ALL) > 0.5', path=main)
31 ma.reconstructDecay(
'D0:rec -> K-:a pi+:a',
'', 0, path=main)
32 ma.reconstructDecay(
'D*+:rec -> D0:rec pi+:a',
'', 0, path=main)
33 ma.reconstructDecay(
'B0:rec -> D*+:rec pi-:a',
' InvM > 5', 0, path=main)
34 ma.matchMCTruth(
'B0:rec', path=main)
37 main.add_module(
'TreeFitter',
38 particleList=
'B0:rec',
40 massConstraintList=[],
41 massConstraintListParticlename=[],
42 expertUseReferencing=
True,
45 updateAllDaughters=
False)
47 ntupler = basf2.register_module(
'VariablesToNtuple')
48 ntupler.param(
'fileName', testFile.name)
49 ntupler.param(
'variables', [
'chiProb',
'M',
'isSignal'])
50 ntupler.param(
'particleList',
'B0:rec')
51 main.add_module(ntupler)
55 ntuplefile = TFile(testFile.name)
56 ntuple = ntuplefile.Get(
'ntuple')
58 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
60 allBkg = ntuple.GetEntries(
"isSignal == 0")
61 allSig = ntuple.GetEntries(
"isSignal > 0")
63 truePositives = ntuple.GetEntries(
"(chiProb > 0) && (isSignal > 0)")
64 falsePositives = ntuple.GetEntries(
"(chiProb > 0) && (isSignal == 0)")
66 mustBeZero = ntuple.GetEntries(
"(chiProb < {})".format(conf))
68 print(
"True fit survivors: {0} out of {1} true candidates".format(truePositives, allSig))
69 print(
"False fit survivors: {0} out of {1} false candidates".format(falsePositives, allBkg))
71 self.assertFalse(truePositives == 0,
"No signal survived the fit.")
73 self.assertTrue(falsePositives < 1413, f
"Background rejection {falsePositives} out of {allBkg}")
75 self.assertTrue(truePositives > 148, f
"Signal rejection too high {truePositives} out of {allSig}")
76 self.assertFalse(mustBeZero,
"We should have dropped all candidates with confidence level less than {}.".format(conf))
78 print(
"Test passed, cleaning up.")
The documentation for this class was generated from the following file: