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_tree_with_neutral.py.

Member Function Documentation

◆ testFit()

def testFit (   self)
Run the test fit

Definition at line 17 of file treeFit_referenced_tree_with_neutral.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_DstD0Kpipi0_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.fillParticleList('gamma:a', 'E > 0.08', path=main)
32  ma.reconstructDecay('pi0:a -> gamma:a gamma:a', '0.125 < InvM < 0.145', 0, path=main)
33 
34  ma.reconstructDecay('D0:rec -> K-:a pi+:a pi0:a', '', 0, path=main)
35  ma.reconstructDecay('D*+:rec -> D0:rec pi+:a', '', 0, path=main)
36  ma.reconstructDecay('B0:rec -> D*+:rec pi-:a', ' InvM > 5', 0, path=main)
37  ma.matchMCTruth('B0:rec', path=main)
38 
39  conf = 0
40  main.add_module('TreeFitter',
41  particleList='B0:rec',
42  confidenceLevel=conf,
43  massConstraintList=[111],
44  massConstraintListParticlename=[],
45  expertUseReferencing=True,
46  ipConstraint=False,
47  updateAllDaughters=False)
48 
49  ntupler = basf2.register_module('VariablesToNtuple')
50  ntupler.param('fileName', testFile.name)
51  ntupler.param('variables', ['chiProb', 'M', 'isSignal'])
52  ntupler.param('particleList', 'B0:rec')
53  main.add_module(ntupler)
54 
55  basf2.process(main)
56 
57  ntuplefile = TFile(testFile.name)
58  ntuple = ntuplefile.Get('ntuple')
59 
60  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
61 
62  allBkg = ntuple.GetEntries("isSignal == 0")
63  allSig = ntuple.GetEntries("isSignal > 0")
64 
65  truePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal > 0)")
66  falsePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 0)")
67 
68  mustBeZero = ntuple.GetEntries("(chiProb < {})".format(conf))
69 
70  print("True fit survivors: {0} out of {1} true candidates".format(truePositives, allSig))
71  print("False fit survivors: {0} out of {1} false candidates".format(falsePositives, allBkg))
72 
73  self.assertFalse(truePositives == 0, "No signal survived the fit.")
74 
75  self.assertTrue(falsePositives < 3038, f"Too many false positives: {falsePositives} out of {allBkg} total bkg events.")
76 
77  self.assertTrue(truePositives > 63, "Signal rejection too high")
78  self.assertFalse(mustBeZero, "We should have dropped all candidates with confidence level less than {}.".format(conf))
79 
80  print("Test passed, cleaning up.")
81 
82 

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