Belle II Software  release-05-01-25
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 14 of file treeFit_referenced_charged_tree_2dBeam.py.

Member Function Documentation

◆ testFit()

def testFit (   self)
Run the test fit

Definition at line 17 of file treeFit_referenced_charged_tree_2dBeam.py.

17  def testFit(self):
18  """Run the test fit"""
19 
20  testFile = tempfile.NamedTemporaryFile()
21 
22  main = basf2.create_path()
23 
24  inputfile = b2test_utils.require_file(
25  'analysis/1000_B_DstD0Kpi_skimmed.root', 'validation', py_case=self)
26  ma.inputMdst('default', inputfile, path=main)
27 
28  ma.fillParticleList('pi+:a', 'pidProbabilityExpert(211, ALL) > 0.5', path=main)
29  ma.fillParticleList('K+:a', 'pidProbabilityExpert(321, ALL) > 0.5', path=main)
30 
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)
35 
36  conf = 0
37  main.add_module('TreeFitter',
38  particleList='B0:rec',
39  confidenceLevel=conf,
40  massConstraintList=[],
41  massConstraintListParticlename=[],
42  expertUseReferencing=True,
43  ipConstraint=True,
44  originDimension=2,
45  updateAllDaughters=False)
46 
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)
52 
53  basf2.process(main)
54 
55  ntuplefile = TFile(testFile.name)
56  ntuple = ntuplefile.Get('ntuple')
57 
58  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
59 
60  allBkg = ntuple.GetEntries("isSignal == 0")
61  allSig = ntuple.GetEntries("isSignal > 0")
62 
63  truePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal > 0)")
64  falsePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 0)")
65 
66  mustBeZero = ntuple.GetEntries("(chiProb < {})".format(conf))
67 
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))
70 
71  self.assertFalse(truePositives == 0, "No signal survived the fit.")
72 
73  self.assertTrue(falsePositives < 1413, f"Background rejection {falsePositives} out of {allBkg}")
74 
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))
77 
78  print("Test passed, cleaning up.")
79 
80 

The documentation for this class was generated from the following file:
basf2.process
def process(path, max_event=0)
Definition: __init__.py:25
b2test_utils.require_file
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:47