13from basf2
import create_path, register_module
15from modularAnalysis
import fillParticleListFromMC, reconstructMCDecay, inputMdst, findMCDecay
23 """Reconstruct/search for an MC decay chain using the reconstructMCDecay tool."""
25 testFile = tempfile.NamedTemporaryFile()
30 'analysis/1000_B_DstD0Kpi_skimmed.root',
'validation', py_case=self)
31 inputMdst(inputfile, path=main)
33 fillParticleListFromMC(
'gamma:primaryMC',
'mcPrimary', path=main)
34 fillParticleListFromMC(
'K+:primaryMC',
'mcPrimary', path=main)
35 fillParticleListFromMC(
'pi+:primaryMC',
'mcPrimary', path=main)
38 'B0:DstD0Kpi =direct=> [D*+:MC =direct=> [D0:MC =direct=> K-:primaryMC pi+:primaryMC ] pi+:primaryMC] pi-:primaryMC',
42 ntupler = register_module(
'VariablesToNtuple')
43 ntupler.param(
'fileName', testFile.name)
44 ntupler.param(
'treeName',
'ntuple')
45 ntupler.param(
'variables', [
'isSignal'])
46 ntupler.param(
'particleList',
'B0:DstD0Kpi')
47 main.add_module(ntupler)
51 ntuplefile = TFile(testFile.name)
52 ntuple = ntuplefile.Get(
'ntuple')
54 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
56 allBkg = ntuple.GetEntries(
"isSignal == 0")
57 allSig = ntuple.GetEntries(
"isSignal > 0")
59 print(f
"True candidates {allSig}")
60 print(f
"False candidates {allBkg}")
65 allSig == sig_expected,
66 f
"n_sig expected: {sig_expected} found: {sig_expected}.")
67 self.assertTrue(allBkg == 0, f
"n_bkg expected 0, found: {allBkg}.")
69 print(
"Test passed, cleaning up.")
72 """Reconstruct/search for an MC decay chain using the reconstructMCDecay tool."""
74 testFile = tempfile.NamedTemporaryFile()
79 inputMdst(inputfile, path=main)
81 fillParticleListFromMC(
'pi+:primaryMC',
'mcPrimary', path=main)
85 ntuplerKS = register_module(
'VariablesToNtuple')
86 ntuplerKS.param(
'fileName', testFile.name)
87 ntuplerKS.param(
'treeName',
'ntuple')
88 ntuplerKS.param(
'variables', [
'isSignal'])
89 ntuplerKS.param(
'particleList',
'B0:3KS')
90 main.add_module(ntuplerKS)
94 ntuplefile = TFile(testFile.name)
95 ntuple = ntuplefile.Get(
'ntuple')
97 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
99 allBkg = ntuple.GetEntries(
"isSignal == 0")
100 allSig = ntuple.GetEntries(
"isSignal > 0")
102 print(f
"True candidates {allSig}")
103 print(f
"False candidates {allBkg}")
108 allSig == sig_expected,
109 f
"n_sig expected: {sig_expected} found: {sig_expected}.")
110 self.assertTrue(allBkg == 0, f
"n_bkg expected 0, found: {allBkg}.")
112 print(
"Test passed, cleaning up.")
115 """Reconstruct/search for an MC decay chain using the findMCDecay tool."""
117 testFile = tempfile.NamedTemporaryFile()
122 'analysis/1000_B_DstD0Kpi_skimmed.root',
'validation', py_case=self)
123 inputMdst(inputfile, path=main)
127 'B0 =direct=> [D*+ =direct=> [D0 =direct=> K- pi+ ] pi+] pi-',
130 ntupler = register_module(
'VariablesToNtuple')
131 ntupler.param(
'fileName', testFile.name)
132 ntupler.param(
'variables', [
'isSignal'])
133 ntupler.param(
'particleList',
'B0:DstD0Kpi')
134 main.add_module(ntupler)
138 ntuplefile = TFile(testFile.name)
139 ntuple = ntuplefile.Get(
'ntuple')
141 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
143 allBkg = ntuple.GetEntries(
"isSignal == 0")
144 allSig = ntuple.GetEntries(
"isSignal > 0")
146 print(f
"True candidates {allSig}")
147 print(f
"False candidates {allBkg}")
152 allSig == sig_expected,
153 f
"n_sig expected: {sig_expected} found: {sig_expected}.")
154 self.assertTrue(allBkg == 0, f
"n_bkg expected 0, found: {allBkg}.")
156 print(
"Test passed, cleaning up.")
159 """Reconstruct/search for an MC decay chain using the findMCDecay tool."""
161 testFile = tempfile.NamedTemporaryFile()
166 inputMdst(inputfile, path=main)
170 'B0 -> [K_S0 -> pi+ pi-] [K_S0 -> pi+ pi-] [K_S0 -> pi+ pi-]',
173 ntupler = register_module(
'VariablesToNtuple')
174 ntupler.param(
'fileName', testFile.name)
175 ntupler.param(
'variables', [
'isSignal'])
176 ntupler.param(
'particleList',
'B0:3KS')
177 main.add_module(ntupler)
181 ntuplefile = TFile(testFile.name)
182 ntuple = ntuplefile.Get(
'ntuple')
184 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
186 allBkg = ntuple.GetEntries(
"isSignal == 0")
187 allSig = ntuple.GetEntries(
"isSignal > 0")
189 print(f
"True candidates {allSig}")
190 print(f
"False candidates {allBkg}")
195 allSig == sig_expected,
196 f
"n_sig expected: {sig_expected} found: {sig_expected}.")
197 self.assertTrue(allBkg == 0, f
"n_bkg expected 0, found: {allBkg}.")
199 print(
"Test passed, cleaning up.")
202if __name__ ==
'__main__':
def testMCDecayFinder(self)
def testReconstructMCDecay_3KS(self)
def testReconstructMCDecay(self)
def testMCDecayFinder_3KS(self)
def require_file(filename, data_type="", py_case=None)
def clean_working_directory()
def safe_process(*args, **kwargs)