Belle II Software  release-08-01-10
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 19 of file treeFit.py.

Member Function Documentation

◆ testFit()

def testFit (   self)
Run the test fit

Definition at line 22 of file treeFit.py.

22  def testFit(self):
23  """Run the test fit"""
24 
25  testFile = tempfile.NamedTemporaryFile()
26 
27  main = basf2.create_path()
28 
29  ma.inputMdst(b2test_utils.require_file('analysis/B0ToPiPiPi0.root', 'validation'), 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  treeFit('B0:rec', conf_level=-1, ipConstraint=False, updateAllDaughters=True, path=main)
40 
41  ntupler = basf2.register_module('VariablesToNtuple')
42  ntupler.param('fileName', testFile.name)
43  ntupler.param('variables', ['chiProb', 'M', 'isSignal'])
44  ntupler.param('particleList', 'B0:rec')
45  main.add_module(ntupler)
46 
47  basf2.process(main)
48 
49  ntuplefile = TFile(testFile.name)
50  ntuple = ntuplefile.Get('ntuple')
51 
52  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
53 
54  allBkg = ntuple.GetEntries("isSignal == 0")
55  allSig = ntuple.GetEntries("isSignal > 0")
56 
57  truePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal > 0)")
58  falsePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 0)")
59 
60  print(f"True fit survivors: {truePositives} out of {allSig} true candidates")
61  print(f"False fit survivors: {falsePositives} out of {allBkg} false candidates")
62 
63  self.assertTrue(truePositives > 212, f"Signal rejection too high. True positives: {truePositives}")
64 
65  self.assertTrue(falsePositives < 8299, f"Background rejection got worse. False positives: {falsePositives}")
66 
67  print("Test passed, cleaning up.")
68 
69 
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54

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