Belle II Software  light-2303-iriomote
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_referenced_single_displaced_vertex.py.

Member Function Documentation

◆ testFit()

def testFit (   self)
Run the test fit

Definition at line 22 of file treeFit_referenced_single_displaced_vertex.py.

22  def testFit(self):
23  """Run the test fit"""
24 
25  testFile = tempfile.NamedTemporaryFile()
26 
27  main = basf2.create_path()
28 
29  inputfile = b2test_utils.require_file(
30  'analysis/1000_B_Jpsi_ks_pipi.root', 'validation', py_case=self)
31  ma.inputMdst(inputfile, path=main)
32 
33  ma.fillParticleList('pi+:a', 'pionID > 0.5', path=main)
34 
35  ma.reconstructDecay('K_S0:pipi -> pi+:a pi-:a', '', 0, path=main)
36  ma.matchMCTruth('K_S0:pipi', path=main)
37 
38  conf = 0
39  main.add_module('TreeFitter',
40  particleList='K_S0:pipi',
41  confidenceLevel=conf,
42  massConstraintList=[],
43  massConstraintListParticlename=[],
44  expertUseReferencing=True,
45  ipConstraint=False,
46  updateAllDaughters=False)
47 
48  ma.printMCParticles(path=main, suppressPrint=True, showStatus=True, showMomenta=True)
49 
50  ntupler = basf2.register_module('VariablesToNtuple')
51  ntupler.param('fileName', testFile.name)
52  ntupler.param('variables', ['chiProb', 'M', 'isSignal', 'mcErrors', 'genParticleID',
53  'daughter(0,genParticleID)', 'daughter(1,genParticleID)'])
54  ntupler.param('particleList', 'K_S0:pipi')
55  main.add_module(ntupler)
56 
57  basf2.process(main)
58 
59  ntuplefile = TFile(testFile.name)
60  ntuple = ntuplefile.Get('ntuple')
61 
62  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
63 
64  allBkg = ntuple.GetEntries("isSignal == 0")
65  allSig = ntuple.GetEntries("isSignal > 0")
66 
67  truePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal > 0)")
68  falsePositives = ntuple.GetEntries("(chiProb > 0) && (isSignal == 0)")
69 
70  mustBeZero = ntuple.GetEntries(f"(chiProb < {conf})")
71 
72  print(f"True fit survivors: {truePositives} out of {allSig} true candidates")
73  print(f"False fit survivors: {falsePositives} out of {allBkg} false candidates")
74 
75  self.assertFalse(truePositives == 0, "No signal survived the fit.")
76 
77  self.assertTrue(falsePositives == 3449, f"Too many false positives: {falsePositives} out of {allBkg} total bkg events.")
78 
79  self.assertTrue(truePositives == 555, "Signal rejection too high")
80  self.assertFalse(mustBeZero, f"We should have dropped all candidates with confidence level less than {conf}.")
81 
82  print("Test passed, cleaning up.")
83 
84 
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54

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