Belle II Software light-2406-ragdoll
TestMbcEff Class Reference
Inheritance diagram for TestMbcEff:
Collaboration diagram for TestMbcEff:

Public Member Functions

def testMbcEff (self)
 

Detailed Description

The unit test

Definition at line 18 of file test_mbc_cut_eff.py.

Member Function Documentation

◆ testMbcEff()

def testMbcEff (   self)
Reconstruct stuff with tight Mbc cut.

Definition at line 21 of file test_mbc_cut_eff.py.

21 def testMbcEff(self):
22 """Reconstruct stuff with tight Mbc cut."""
23
24 testFile = tempfile.NamedTemporaryFile()
25
26 main = basf2.create_path()
27
28 inputfile = b2test_utils.require_file(
29 'analysis/1000_B_DstD0Kpi_skimmed.root', 'validation', py_case=self)
30 ma.inputMdst(inputfile, path=main)
31
32 ma.fillParticleList('pi+:a', 'pionID > 0.5', path=main)
33 ma.fillParticleList('K+:a', 'kaonID > 0.5', path=main)
34
35 ma.reconstructDecay('D0:rec -> K-:a pi+:a', '', 0, path=main)
36 ma.reconstructDecay('D*+:rec -> D0:rec pi+:a', '', 0, path=main)
37 ma.reconstructDecay('B0:rec -> D*+:rec pi-:a', ' InvM > 5.27', 0, path=main)
38 ma.matchMCTruth('B0:rec', path=main)
39
40 ntupler = basf2.register_module('VariablesToNtuple')
41 ntupler.param('fileName', testFile.name)
42 ntupler.param('variables', ['isSignal'])
43 ntupler.param('particleList', 'B0:rec')
44 main.add_module(ntupler)
45
46 basf2.process(main)
47
48 ntuplefile = TFile(testFile.name)
49 ntuple = ntuplefile.Get('ntuple')
50
51 self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
52
53 allBkg = ntuple.GetEntries("isSignal == 0")
54 allSig = ntuple.GetEntries("isSignal > 0")
55
56 print(f"True candidates {allSig}")
57 print(f"False candidates {allBkg}")
58
59 sig_expected = 136
60 bkg_expected = 1630
61
62 self.assertTrue(
63 allSig == sig_expected,
64 f"Mbc cut efficiency has changed! n_sig expected: {sig_expected} found: {allSig}.")
65 self.assertTrue(allBkg == bkg_expected, f"Mbc cut background has changed! n_bkg expected: {bkg_expected} found: {allBkg}.")
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: