Belle II Software  release-05-02-19
TestNewMCDecayFinder Class Reference
Inheritance diagram for TestNewMCDecayFinder:
Collaboration diagram for TestNewMCDecayFinder:

Public Member Functions

def testNewMCDecayFinder (self)
 

Detailed Description

The unit test

Definition at line 14 of file test_reconstructmcdecay.py.

Member Function Documentation

◆ testNewMCDecayFinder()

def testNewMCDecayFinder (   self)
Reconstruct/search for an MC decay chain using the reconstructMCDecay tool.

Definition at line 17 of file test_reconstructmcdecay.py.

17  def testNewMCDecayFinder(self):
18  """Reconstruct/search for an MC decay chain using the reconstructMCDecay tool."""
19 
20  testFile = tempfile.NamedTemporaryFile()
21 
22  main = create_path()
23 
24  inputfile = b2test_utils.require_file(
25  'analysis/1000_B_DstD0Kpi_skimmed.root', 'validation', py_case=self)
26  inputMdst('default', inputfile, path=main)
27 
28  fillParticleListFromMC('gamma:MC', 'mcPrimary', path=main)
29  fillParticleListFromMC('K+:MC', 'mcPrimary', path=main)
30  fillParticleListFromMC('pi+:MC', 'mcPrimary', path=main)
31 
33  'B0:DstD0Kpi =direct=> [D*+:MC =direct=> [D0:MC =direct=> K-:MC pi+:MC ] pi+:MC] pi-:MC',
34  '',
35  path=main)
36 
37  ntupler = register_module('VariablesToNtuple')
38  ntupler.param('fileName', testFile.name)
39  ntupler.param('variables', ['isSignal'])
40  ntupler.param('particleList', 'B0:DstD0Kpi')
41  main.add_module(ntupler)
42 
44 
45  ntuplefile = TFile(testFile.name)
46  ntuple = ntuplefile.Get('ntuple')
47 
48  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
49 
50  allBkg = ntuple.GetEntries("isSignal == 0")
51  allSig = ntuple.GetEntries("isSignal > 0")
52 
53  print("True candidates {0}".format(allSig))
54  print("False candidates {0}".format(allBkg))
55 
56  sig_expected = 406
57 
58  self.assertTrue(
59  allSig == sig_expected,
60  f"n_sig expected: {sig_expected} found: {sig_expected}.")
61  self.assertTrue(allBkg == 0, f"n_bkg expected 0, found: {allBkg}.")
62 
63  print("Test passed, cleaning up.")
64 
65 

The documentation for this class was generated from the following file:
reconstructMCDecay
Definition: reconstructMCDecay.py:1
b2test_utils.safe_process
def safe_process(*args, **kwargs)
Definition: __init__.py:224
b2test_utils.require_file
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:47