Belle II Software  release-06-01-15
TestParticleCombiner Class Reference
Inheritance diagram for TestParticleCombiner:
Collaboration diagram for TestParticleCombiner:

Public Member Functions

def testChargeConjugation (self)
 

Detailed Description

The unit test case for the ParticleCombinerModule

Definition at line 20 of file chargeConjugation.py.

Member Function Documentation

◆ testChargeConjugation()

def testChargeConjugation (   self)
Reconstruct decays with and without charge conjugation

Definition at line 23 of file chargeConjugation.py.

23  def testChargeConjugation(self):
24  """Reconstruct decays with and without charge conjugation"""
25 
26  testFile = tempfile.NamedTemporaryFile()
27  # make logging more reproducible by replacing some strings.
28  # Also make sure the testfile name is replaced if necessary
29  b2test_utils.configure_logging_for_tests({testFile.name: "${testfile}"})
30 
31  main = basf2.create_path()
32  ma.inputMdst('default', b2test_utils.require_file('analysis/tests/mdst.root'), path=main)
33 
34  ma.fillParticleList('pi+:pionlike', 'pionID > 0.5', path=main)
35  ma.fillParticleList('K+:kaonlike', 'kaonID > 0.5', path=main)
36 
37  # combine all kaons with all pions for both charge configurations (K- pi+ and K+ pi-)
38  ma.reconstructDecay('D0:all -> K-:kaonlike pi+:pionlike', '', chargeConjugation=True, path=main)
39 
40  # only reconstruct D0
41  ma.reconstructDecay('D0:particle -> K-:kaonlike pi+:pionlike', '', chargeConjugation=False, path=main)
42 
43  # only reconstruct anti-D0
44  ma.reconstructDecay('anti-D0:anti-particle -> K+:kaonlike pi-:pionlike', '', chargeConjugation=False, path=main)
45 
46  # use particle's charge to separate D0 flavors,
47  ma.reconstructDecay(
48  'D0:positiveFlavour -> K-:kaonlike pi+:pionlike',
49  'daughter(0, charge) < 0',
50  chargeConjugation=True,
51  path=main)
52  ma.reconstructDecay(
53  'D0:negativeFlavour -> K-:kaonlike pi+:pionlike',
54  'daughter(0, charge) > 0',
55  chargeConjugation=True,
56  path=main)
57 
58  variables.addAlias('nDs', 'nParticlesInList(D0:all)')
59  variables.addAlias('nD0s', 'nParticlesInList(D0:particle)')
60  variables.addAlias('nAntiD0s', 'nParticlesInList(anti-D0:anti-particle)')
61  variables.addAlias('nPositiveFlavourDs', 'nParticlesInList(D0:positiveFlavour)')
62  variables.addAlias('nNegativeFlavourDs', 'nParticlesInList(D0:negativeFlavour)')
63 
64  allvariables = ['nDs', 'nD0s', 'nAntiD0s', 'nPositiveFlavourDs', 'nNegativeFlavourDs']
65  ma.variablesToNtuple('', variables=allvariables, filename=testFile.name, path=main)
66 
67  basf2.process(main)
68 
69  ntuplefile = TFile(testFile.name)
70  ntuple = ntuplefile.Get('variables')
71 
72  self.assertFalse(ntuple.GetEntries() == 0, "Ntuple is empty.")
73 
74  # sum of D0s and D0bars should be equal to all D0s
75  if (ntuple.GetEntries() != ntuple.GetEntries("nDs == nD0s + nAntiD0s")):
76  ntuple.Scan("nDs:nD0s:nAntiD0s:nPositiveFlavourDs:nNegativeFlavourDs", "", "", 10)
77  self.assertFalse(True, "Number of D0s does not agree with sum of both flavors!")
78 
79  # D0s should be combinations of K- and pi+ only
80  if (ntuple.GetEntries() != ntuple.GetEntries("nD0s == nPositiveFlavourDs")):
81  ntuple.Scan("nDs:nD0s:nAntiD0s:nPositiveFlavourDs:nNegativeFlavourDs", "", "", 10)
82  self.assertFalse(True, "Number of D0s does not agree with number of K- pi+ combinations!")
83 
84  # D0bars should be combinations of K+ and pi- only
85  if (ntuple.GetEntries() != ntuple.GetEntries("nAntiD0s == nNegativeFlavourDs")):
86  ntuple.Scan("nDs:nD0s:nAntiD0s:nPositiveFlavourDs:nNegativeFlavourDs", "", "", 10)
87  self.assertFalse(True, "Number of anti D0s does not agree with number of K+ pi- combinations!")
88 
89  print("Test passed, cleaning up.")
90 
91 
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:106
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54

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