Belle II Software  release-06-01-15
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 19 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 22 of file test_reconstructmcdecay.py.

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

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