Belle II Software  release-06-01-15
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 20 of file treeFit.py.

Member Function Documentation

◆ testFit()

def testFit (   self)
Run the test fit

Definition at line 23 of file treeFit.py.

23  def testFit(self):
24  """Run the test fit"""
25 
26  testFile = tempfile.NamedTemporaryFile()
27 
28  # we want to use the latest grated globaltag, not the old one from the
29  # file
30  basf2.conditions.disable_globaltag_replay()
31 
32  main = basf2.create_path()
33 
34  ma.inputMdst('default', b2test_utils.require_file('analysis/tests/100_noBKG_B0ToPiPiPi0.root'), path=main)
35 
36  ma.fillParticleList('pi+:a', 'pionID > 0.5', path=main)
37 
38  ma.fillParticleList('gamma:a', '', path=main)
39  ma.reconstructDecay('pi0:a -> gamma:a gamma:a', '0.125 < InvM < 0.145', 0, path=main)
40 
41  ma.reconstructDecay('B0:rec -> pi-:a pi+:a pi0:a', '', 0, path=main)
42  ma.matchMCTruth('B0:rec', path=main)
43 
44  treeFit('B0:rec', conf_level=-1, ipConstraint=False, updateAllDaughters=True, path=main)
45 
46  ntupler = basf2.register_module('VariablesToNtuple')
47  ntupler.param('fileName', testFile.name)
48  ntupler.param('variables', ['chiProb', 'M', 'isSignal'])
49  ntupler.param('particleList', 'B0:rec')
50  main.add_module(ntupler)
51 
52  basf2.process(main)
53 
54  ntuplefile = TFile(testFile.name)
55  ntuple = ntuplefile.Get('ntuple')
56 
57  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
58 
59  allBkg = ntuple.GetEntries("isSignal == 0")
60  allSig = ntuple.GetEntries("isSignal > 0")
61 
62  truePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal > 0)")
63  falsePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 0)")
64 
65  print(f"True fit survivors: {truePositives} out of {allSig} true candidates")
66  print(f"False fit survivors: {falsePositives} out of {allBkg} false candidates")
67 
68  self.assertTrue(truePositives > 32, f"Signal rejection too high. True positives: {truePositives}")
69 
70  self.assertTrue(falsePositives < 2129, f"Background rejection got worse. False positives: {falsePositives}")
71 
72  print("Test passed, cleaning up.")
73 
74 
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54

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