14import modularAnalysis
as ma
22 """Reconstruct stuff with tight Mbc cut."""
24 testFile = tempfile.NamedTemporaryFile()
26 main = basf2.create_path()
29 'analysis/1000_B_DstD0Kpi_skimmed.root',
'validation', py_case=self)
30 ma.inputMdst(inputfile, path=main)
32 ma.fillParticleList(
'pi+:a',
'pionID > 0.5', path=main)
33 ma.fillParticleList(
'K+:a',
'kaonID > 0.5', path=main)
35 ma.reconstructDecay(
'D0:rec -> K-:a pi+:a',
'', 0, path=main)
36 ma.reconstructDecay(
'D*+:rec -> D0:rec pi+:a',
'', 0, path=main)
37 ma.reconstructDecay(
'B0:rec -> D*+:rec pi-:a',
' InvM > 5.27', 0, path=main)
38 ma.matchMCTruth(
'B0:rec', path=main)
40 ntupler = basf2.register_module(
'VariablesToNtuple')
41 ntupler.param(
'fileName', testFile.name)
42 ntupler.param(
'variables', [
'isSignal'])
43 ntupler.param(
'particleList',
'B0:rec')
44 main.add_module(ntupler)
48 ntuplefile = TFile(testFile.name)
49 ntuple = ntuplefile.Get(
'ntuple')
51 self.assertFalse(ntuple.GetEntries() == 0,
"Ntuple is empty.")
53 allBkg = ntuple.GetEntries(
"isSignal == 0")
54 allSig = ntuple.GetEntries(
"isSignal > 0")
56 print(f
"True candidates {allSig}")
57 print(f
"False candidates {allBkg}")
63 allSig == sig_expected,
64 f
"Mbc cut efficiency has changed! n_sig expected: {sig_expected} found: {allSig}.")
65 self.assertTrue(allBkg == bkg_expected, f
"Mbc cut background has changed! n_bkg expected: {bkg_expected} found: {allBkg}.")
67 print(
"Test passed, cleaning up.")
70if __name__ ==
'__main__':
def require_file(filename, data_type="", py_case=None)
def clean_working_directory()