The unit test case for the ParticleCombinerModule
Definition at line 20 of file chargeConjugation.py.
◆ 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"""
26 testFile = tempfile.NamedTemporaryFile()
31 main = basf2.create_path()
34 ma.fillParticleList(
'pi+:pionlike',
'pionID > 0.5', path=main)
35 ma.fillParticleList(
'K+:kaonlike',
'kaonID > 0.5', path=main)
38 ma.reconstructDecay(
'D0:all -> K-:kaonlike pi+:pionlike',
'', chargeConjugation=
True, path=main)
41 ma.reconstructDecay(
'D0:particle -> K-:kaonlike pi+:pionlike',
'', chargeConjugation=
False, path=main)
44 ma.reconstructDecay(
'anti-D0:anti-particle -> K+:kaonlike pi-:pionlike',
'', chargeConjugation=
False, path=main)
48 'D0:positiveFlavour -> K-:kaonlike pi+:pionlike',
49 'daughter(0, charge) < 0',
50 chargeConjugation=
True,
53 'D0:negativeFlavour -> K-:kaonlike pi+:pionlike',
54 'daughter(0, charge) > 0',
55 chargeConjugation=
True,
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)')
64 allvariables = [
'nDs',
'nD0s',
'nAntiD0s',
'nPositiveFlavourDs',
'nNegativeFlavourDs']
65 ma.variablesToNtuple(
'', variables=allvariables, filename=testFile.name, path=main)
69 ntuplefile = TFile(testFile.name)
70 ntuple = ntuplefile.Get(
'variables')
72 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
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!")
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!")
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!")
89 print(
"Test passed, cleaning up.")
def configure_logging_for_tests(user_replacements=None)
def require_file(filename, data_type="", py_case=None)
The documentation for this class was generated from the following file: