The unit test case for TreeFitter
Definition at line 19 of file treeFit_referenced_ignore_charged.py.
◆ testFit()
Run the test fit
Definition at line 22 of file treeFit_referenced_ignore_charged.py.
23 """Run the test fit"""
25 testFile = tempfile.NamedTemporaryFile()
27 main = basf2.create_path()
30 ma.inputMdst(inputfile, path=main)
32 ma.fillParticleList(
'pi+:a',
'pionID > 0.5', path=main)
34 ma.fillParticleList(
'gamma:a',
'', path=main)
35 ma.reconstructDecay(
'pi0:a -> gamma:a gamma:a',
'0.125 < InvM < 0.145', 0, path=main)
37 ma.reconstructDecay(
'B0:rec -> pi-:a pi+:a pi0:a',
'', 0, path=main)
38 ma.matchMCTruth(
'B0:rec', path=main)
41 main.add_module(
'TreeFitter',
42 particleList=
'B0:rec',
44 massConstraintList=[],
45 massConstraintListParticlename=[],
46 expertUseReferencing=
True,
48 updateAllDaughters=
True,
49 ignoreFromVertexFit=
'B0 -> ^pi- pi+ pi0')
51 ntupler = basf2.register_module(
'VariablesToNtuple')
52 ntupler.param(
'fileName', testFile.name)
53 ntupler.param(
'variables', [
'chiProb',
'M',
'isSignal',
'Mbc'])
54 ntupler.param(
'particleList',
'B0:rec')
55 main.add_module(ntupler)
59 ntuplefile = TFile(testFile.name)
60 ntuple = ntuplefile.Get(
'ntuple')
62 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
64 allBkg = ntuple.GetEntries(
"isSignal == 0")
65 allSig = ntuple.GetEntries(
"isSignal > 0")
66 SigMbcReasonable = ntuple.GetEntries(
"isSignal > 0 && Mbc > 5.27")
68 truePositives = ntuple.GetEntries(
"(chiProb > 0) && (isSignal > 0)")
69 falsePositives = ntuple.GetEntries(
"(chiProb > 0) && (isSignal == 0)")
71 mustBeZero = ntuple.GetEntries(f
"(chiProb < {conf})")
73 print(f
"True fit survivors: {truePositives} out of {allSig} true candidates")
74 print(f
"False fit survivors: {falsePositives} out of {allBkg} false candidates")
76 self.assertTrue(falsePositives < 2156,
"Background rejection too small.")
78 self.assertTrue(truePositives > 34,
"Signal rejection too high")
79 self.assertFalse(mustBeZero, f
"We should have dropped all candidates with confidence level less than {conf}.")
81 self.assertTrue(SigMbcReasonable > 33,
"Signal kinematics is wrongly reconstructed too much")
83 print(
"Test passed, cleaning up.")
def require_file(filename, data_type="", py_case=None)
The documentation for this class was generated from the following file: