15 import b2test_utils
as b2tu
16 import modularAnalysis
as ma
17 from stdPi0s
import stdPi0s
18 from stdV0s
import stdKshorts
19 from variables
import variables
as vm
22 def dump_3_v2nts(names_of_three_lists, path):
23 """Dump each of the three vpho lists into a VariablesToNtuple on path"""
24 first, second, third = names_of_three_lists
25 vs = [
'd0_mdstIndex',
'd0_p']
26 ma.variablesToNtuple(
"vpho:" + first, vs, treename=first, path=path)
27 ma.variablesToNtuple(
"vpho:" + second, vs, treename=second, path=path)
28 ma.variablesToNtuple(
"vpho:" + third, vs, treename=third, path=path)
32 """A simple basf2 analysis job to do some list copying"""
35 vm.addAlias(
"d0_mdstIndex",
"daughter(0, mdstIndex)")
36 vm.addAlias(
"d0_p",
"daughter(0, p)")
40 ma.inputMdst(
"default", b2.find_file(
"analysis/tests/mdst.root"), path=pa)
41 ma.fillParticleList(
"pi+",
"", path=pa)
42 ma.fillParticleList(
"K+",
"", path=pa)
48 ma.reconstructDecay(
"vpho:a -> K+",
"", path=pa, allowChargeViolation=
True)
49 ma.reconstructDecay(
"vpho:b -> K+",
"", path=pa, allowChargeViolation=
True)
50 ma.copyLists(
"vpho:ab", [
"vpho:a",
"vpho:b"], path=pa)
51 dump_3_v2nts([
"a",
"b",
"ab"], path=pa)
55 ma.reconstructDecay(
"vpho:c -> K+",
"", path=pa, allowChargeViolation=
True)
56 ma.reconstructDecay(
"vpho:d -> pi-",
"", path=pa, allowChargeViolation=
True)
57 ma.copyLists(
"vpho:cd", [
"vpho:c",
"vpho:d"], path=pa)
58 dump_3_v2nts([
"c",
"d",
"cd"], path=pa)
63 ma.reconstructDecay(
"vpho:e -> K+ pi-",
"", path=pa)
64 ma.reconstructDecay(
"vpho:f -> pi- K+",
"", path=pa)
65 ma.copyLists(
"vpho:ef", [
"vpho:e",
"vpho:f"], path=pa)
66 dump_3_v2nts([
"e",
"f",
"ef"], path=pa)
70 ma.reconstructDecay(
"tau+:pi -> pi+",
"", dmID=0, path=pa)
71 ma.reconstructDecay(
"tau+:pipi0 -> pi+ pi0:all",
"", dmID=1, path=pa)
73 ma.reconstructDecay(
"vpho:g -> tau+:pi tau-:pipi0",
"", path=pa, chargeConjugation=
False)
75 ma.reconstructDecay(
"vpho:h -> tau-:pi tau+:pipi0",
"", path=pa, chargeConjugation=
False)
78 ma.copyLists(
"vpho:gh", [
"vpho:g",
"vpho:h"], path=pa)
79 dump_3_v2nts([
"g",
"h",
"gh"], path=pa)
83 ma.reconstructDecay(
"tau+:KS0 -> pi+ K_S0:merged",
"", dmID=0, path=pa)
84 ma.reconstructDecay(
"tau+:pi0 -> pi+ pi0:all",
"", dmID=1, path=pa)
86 ma.reconstructDecay(
"vpho:KS -> tau+:KS0 tau-:pi0",
"", path=pa, chargeConjugation=
False)
88 ma.reconstructDecay(
"vpho:pi0 -> tau-:KS0 tau+:pi0",
"", path=pa, chargeConjugation=
False)
91 ma.copyLists(
"vpho:KSpi0", [
"vpho:KS",
"vpho:pi0"], path=pa)
92 dump_3_v2nts([
"KS",
"pi0",
"KSpi0"], path=pa)
94 b2tu.safe_process(pa, 1)
98 """Analyse the output of ``run_copylists``"""
101 """Open the ntuple output and count the number of entries in the list."""
102 df = root_pandas.read_root(
"ntuple.root", listname)
106 """Merging two lists with identical daughters should not double count."""
107 self.assertEqual(self.
_count_count(
"a"), self.
_count_count(
"b"))
108 self.assertEqual(self.
_count_count(
"a"), self.
_count_count(
"ab"))
109 self.assertEqual(self.
_count_count(
"b"), self.
_count_count(
"ab"))
112 """Merging two lists with different daughters but with the same mdst
113 object should include each of them twice."""
114 self.assertEqual(self.
_count_count(
"c"), self.
_count_count(
"d"))
115 self.assertEqual(self.
_count_count(
"c") + self.
_count_count(
"d"), self.
_count_count(
"cd"))
118 """Merging two lists with daughters in a different order should not double count."""
119 self.assertEqual(self.
_count_count(
"e"), self.
_count_count(
"e"))
120 self.assertEqual(self.
_count_count(
"e"), self.
_count_count(
"ef"))
123 """Self-conjugated particles can be daughters of both charge-conjugated mother particles.
124 Those multiple candidates are no duplicates and copying the particle list should not remove them."""
125 self.assertEqual(self.
_count_count(
"g") + self.
_count_count(
"h"), self.
_count_count(
"gh"))
128 """Different self-conjugated particles are daughters of charge-conjugated mother particles.
129 The two mother particles have the same amount of daughters."""
130 self.assertEqual(self.
_count_count(
"KS") + self.
_count_count(
"pi0"), self.
_count_count(
"KSpi0"))
133 if __name__ ==
"__main__":
134 with b2tu.clean_working_directory():
def test_different_association_of_neutrals_same_number_of_daughters(self)
def test_neutrals_in_decays_to_charge_conjugated_daughters(self)
def test_different_daughter_order(self)
def test_merge_two_lists_with_different_mdst_objects(self)
def _count(self, listname)
def test_merge_two_lists_with_identical_daughters(self)