7 import b2test_utils
as b2tu
8 import modularAnalysis
as ma
9 from variables
import variables
as vm
12 def dump_3_v2nts(names_of_three_lists, path):
13 """Dump each of the three vpho lists into a VariablesToNtuple on path"""
14 first, second, third = names_of_three_lists
15 vs = [
'd0_mdstIndex',
'd0_p']
16 ma.variablesToNtuple(
"vpho:" + first, vs, treename=first, path=path)
17 ma.variablesToNtuple(
"vpho:" + second, vs, treename=second, path=path)
18 ma.variablesToNtuple(
"vpho:" + third, vs, treename=third, path=path)
22 """A simple basf2 analysis job to do some list copying"""
25 vm.addAlias(
"d0_mdstIndex",
"daughter(0, mdstIndex)")
26 vm.addAlias(
"d0_p",
"daughter(0, p)")
30 ma.inputMdst(
"default", b2.find_file(
"analysis/tests/mdst.root"), path=pa)
31 ma.fillParticleList(
"pi+",
"", path=pa)
32 ma.fillParticleList(
"K+",
"", path=pa)
36 ma.reconstructDecay(
"vpho:a -> K+",
"", path=pa, allowChargeViolation=
True)
37 ma.reconstructDecay(
"vpho:b -> K+",
"", path=pa, allowChargeViolation=
True)
38 ma.copyLists(
"vpho:ab", [
"vpho:a",
"vpho:b"], path=pa)
39 dump_3_v2nts([
"a",
"b",
"ab"], path=pa)
43 ma.reconstructDecay(
"vpho:c -> K+",
"", path=pa, allowChargeViolation=
True)
44 ma.reconstructDecay(
"vpho:d -> pi-",
"", path=pa, allowChargeViolation=
True)
45 ma.copyLists(
"vpho:cd", [
"vpho:c",
"vpho:d"], path=pa)
46 dump_3_v2nts([
"c",
"d",
"cd"], path=pa)
51 ma.reconstructDecay(
"vpho:e -> K+ pi-",
"", path=pa)
52 ma.reconstructDecay(
"vpho:f -> pi- K+",
"", path=pa)
53 ma.copyLists(
"vpho:ef", [
"vpho:e",
"vpho:f"], path=pa)
54 dump_3_v2nts([
"e",
"f",
"ef"], path=pa)
56 b2tu.safe_process(pa, 1)
60 """Analyse the output of ``run_copylists``"""
63 """Open the ntuple output and count the number of entries in the list."""
64 df = root_pandas.read_root(
"ntuple.root", listname)
68 """Merging two lists with identical daughters should not double count."""
74 """Merging two lists with different daughters but with the same mdst
75 object should include each of them twice."""
80 """Merging two lists with daughters in a different order should not double count."""
85 if __name__ ==
"__main__":
86 with b2tu.clean_working_directory():