Belle II Software  release-05-02-19
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 14 of file test_mbc_cut_eff.py.

Member Function Documentation

◆ testMbcEff()

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

Definition at line 17 of file test_mbc_cut_eff.py.

17  def testMbcEff(self):
18  """Reconstruct stuff with tight Mbc cut."""
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.27', 0, path=main)
34  ma.matchMCTruth('B0:rec', path=main)
35 
36  ntupler = basf2.register_module('VariablesToNtuple')
37  ntupler.param('fileName', testFile.name)
38  ntupler.param('variables', ['isSignal'])
39  ntupler.param('particleList', 'B0:rec')
40  main.add_module(ntupler)
41 
42  basf2.process(main)
43 
44  ntuplefile = TFile(testFile.name)
45  ntuple = ntuplefile.Get('ntuple')
46 
47  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
48 
49  allBkg = ntuple.GetEntries("isSignal == 0")
50  allSig = ntuple.GetEntries("isSignal > 0")
51 
52  print("True candidates {0}".format(allSig))
53  print("False candidates {0}".format(allBkg))
54 
55  sig_expected = 136
56  bkg_expected = 1630
57 
58  self.assertTrue(
59  allSig == sig_expected,
60  f"Mbc cut efficency has changed! n_sig expected: {sig_expected} found: {allSig}.")
61  self.assertTrue(allBkg == bkg_expected, f"Mbc cut background has changed! n_bkg expected: {bkg_expected} found: {allBkg}.")
62 
63  print("Test passed, cleaning up.")
64 
65 

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