8#include <analysis/utility/DecayNode.h>
9#include <analysis/utility/DecayTree.h>
10#include <analysis/utility/DecayForest.h>
11#include <framework/gearbox/Const.h>
13#include <gtest/gtest.h>
21 TEST(DecayNodeTest, Constructor)
28 EXPECT_EQ(photon_1.daughters.size(), 0);
31 EXPECT_EQ(pi0.daughters.size(), 2);
35 TEST(DecayNodeTest, FindDecay)
40 DecayNode pi0_1(111, {photon_1, photon_2});
53 EXPECT_TRUE(D_1.find_decay(D_1));
54 EXPECT_TRUE(D_1.find_decay(D_2));
55 EXPECT_FALSE(D_1.find_decay(D_3));
56 EXPECT_TRUE(D_1.find_decay(pi0_1));
57 EXPECT_TRUE(D_1.find_decay(pi0_2));
58 EXPECT_FALSE(D_1.find_decay(pi0_3));
60 EXPECT_TRUE(D_2.find_decay(D_1));
61 EXPECT_TRUE(D_2.find_decay(D_2));
62 EXPECT_TRUE(D_2.find_decay(D_3));
63 EXPECT_TRUE(D_2.find_decay(pi0_1));
64 EXPECT_TRUE(D_2.find_decay(pi0_2));
65 EXPECT_TRUE(D_2.find_decay(pi0_3));
67 EXPECT_FALSE(D_3.find_decay(D_1));
68 EXPECT_TRUE(D_3.find_decay(D_2));
69 EXPECT_TRUE(D_3.find_decay(D_3));
70 EXPECT_FALSE(D_3.find_decay(pi0_1));
71 EXPECT_TRUE(D_3.find_decay(pi0_2));
72 EXPECT_TRUE(D_3.find_decay(pi0_3));
74 EXPECT_TRUE(pi0_1.find_decay(photon_1));
75 EXPECT_TRUE(pi0_1.find_decay(photon_2));
76 EXPECT_TRUE(pi0_1.find_decay(photon_3));
77 EXPECT_FALSE(pi0_1.find_decay(e_1));
80 TEST(DecayTreeTest, FindDecay)
90 DecayTree D_1(
"321 (--> 11 111 (--> 22 22))");
92 DecayTree D_3(
"321 (--> 11 111 (--> 11 -11))");
94 EXPECT_TRUE(D_1.find_decay(D_1));
95 EXPECT_TRUE(D_1.find_decay(D_2));
96 EXPECT_FALSE(D_1.find_decay(D_3));
97 EXPECT_TRUE(D_1.find_decay(pi0_1));
98 EXPECT_TRUE(D_1.find_decay(pi0_2));
99 EXPECT_FALSE(D_1.find_decay(pi0_3));
101 EXPECT_TRUE(D_2.find_decay(D_1));
102 EXPECT_TRUE(D_2.find_decay(D_2));
103 EXPECT_TRUE(D_2.find_decay(D_3));
104 EXPECT_TRUE(D_2.find_decay(pi0_1));
105 EXPECT_TRUE(D_2.find_decay(pi0_2));
106 EXPECT_TRUE(D_2.find_decay(pi0_3));
108 EXPECT_FALSE(D_3.find_decay(D_1));
109 EXPECT_TRUE(D_3.find_decay(D_2));
110 EXPECT_TRUE(D_3.find_decay(D_3));
111 EXPECT_FALSE(D_3.find_decay(pi0_1));
112 EXPECT_TRUE(D_3.find_decay(pi0_2));
113 EXPECT_TRUE(D_3.find_decay(pi0_3));
115 EXPECT_TRUE(pi0_1.find_decay(photon_1));
116 EXPECT_FALSE(pi0_1.find_decay(e_1));
117 EXPECT_TRUE(pi0_3.find_decay(e_2));
121 TEST(DecayTreeTest, IsValid)
126 EXPECT_TRUE(photon_1.isValid());
127 EXPECT_TRUE(pi0_1.isValid());
130 EXPECT_FALSE(no_match.isValid());
134 TEST(DecayTreeTest, MatchSymbolPosition)
137 DecayTree D_0(
"321 (--> 11 111 (--> 11 -11))");
138 DecayTree D_1(
"321 (--> 11 111 (--> ^11 -11))");
139 DecayTree D_2(
"321 (--> ^11 111 (--> 11 -11))");
140 DecayTree D_3(
"^321 (--> 11 111 (--> 11 -11))");
142 EXPECT_EQ(D_0.getMatchSymbolPosition(), -1);
143 EXPECT_EQ(D_0.getNumberOfDecayNodes(), 5);
145 EXPECT_EQ(D_1.getMatchSymbolPosition(), 3);
146 EXPECT_EQ(D_1.getNumberOfDecayNodes(), 5);
148 EXPECT_EQ(D_1.getDecayNode(3).daughters.size(), 0);
150 EXPECT_EQ(D_2.getMatchSymbolPosition(), 1);
151 EXPECT_EQ(D_2.getNumberOfDecayNodes(), 5);
153 EXPECT_EQ(D_2.getDecayNode(1).daughters.size(), 0);
155 EXPECT_EQ(D_3.getMatchSymbolPosition(), 0);
156 EXPECT_EQ(D_3.getNumberOfDecayNodes(), 5);
158 EXPECT_EQ(D_3.getDecayNode(0).daughters.size(), 2);
162 TEST(DecayTreeTest, Constructor)
166 EXPECT_EQ(photon.getNumberOfDecayNodes(), 1);
168 EXPECT_EQ(photon.getDecayNode(0).daughters.size(), 0);
171 EXPECT_EQ(pi0.getNumberOfDecayNodes(), 3);
173 EXPECT_EQ(pi0.getDecayNode(0).daughters.size(), 2);
175 EXPECT_EQ(pi0.getDecayNode(1).daughters.size(), 0);
177 EXPECT_EQ(pi0.getDecayNode(2).daughters.size(), 0);
179 DecayTree D(
"321 (--> 11 111 (--> 11 -11))");
180 EXPECT_EQ(D.getNumberOfDecayNodes(), 5);
182 EXPECT_EQ(D.getDecayNode(0).daughters.size(), 2);
184 EXPECT_EQ(D.getDecayNode(1).daughters.size(), 0);
186 EXPECT_EQ(D.getDecayNode(2).daughters.size(), 2);
188 EXPECT_EQ(D.getDecayNode(3).daughters.size(), 0);
190 EXPECT_EQ(D.getDecayNode(4).daughters.size(), 0);
194 TEST(DecayForestTest, Constructor)
196 DecayForest D(
"321 (--> 11 111 (--> 11 -11)) | No match | 111 (--> 11 -11) | 512 (--> 321 (--> 11 111 (--> 11 -11)) ) ",
false);
198 EXPECT_EQ(D.getNumberOfTrees(), 4);
199 EXPECT_EQ(D.getOriginalTreeNumber(), 2);
201 auto& reconstructed_decay_tree = D.getReconstructedTree();
202 EXPECT_EQ(reconstructed_decay_tree.getNumberOfDecayNodes(), 5);
205 auto& no_match_decay_tree = D.getTree(1);
206 EXPECT_FALSE(no_match_decay_tree.isValid());
208 auto& original_decay_tree = D.getOriginalTree();
209 EXPECT_TRUE(original_decay_tree.isValid());
214 TEST(DecayForestTest, SaveMemory)
216 DecayForest D(
"321 (--> 11 111 (--> 11 -11)) | No match | 111 (--> 11 -11) | 512 (--> 321 (--> 11 111 (--> 11 -11)) ) ",
true);
218 EXPECT_EQ(D.getNumberOfTrees(), 3);
219 EXPECT_EQ(D.getOriginalTreeNumber(), 2);
221 auto& reconstructed_decay_tree = D.getReconstructedTree();
222 EXPECT_EQ(reconstructed_decay_tree.getNumberOfDecayNodes(), 5);
225 auto& no_match_decay_tree = D.getTree(1);
226 EXPECT_FALSE(no_match_decay_tree.isValid());
228 auto& original_decay_tree = D.getOriginalTree();
229 EXPECT_TRUE(original_decay_tree.isValid());
234 TEST(DecayForestTest, FindB2TauNuDecay)
237 Y(
" 300553 (--> -521 (--> 15 (--> -211)) 521 (--> -423 (--> -421 (--> 321 11) 22) 211 211 -211 111 (--> 22 22))) | ^300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) ^-521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> ^15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 ^-211 111 (--> 22 22)) -16)) | 300553 (--> ^521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> ^-423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> ^-421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> ^321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 ^11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) ^22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> ^211 111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) -211) ^211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 22)) ^-211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 ^111 (--> 22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> ^22 22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16)) | 300553 (--> 521 (--> -423 (--> -421 (--> 321 11 -12) 22) 10223 (--> 213 (--> 211 111 (--> 22 ^22)) -211) 211) -521 (--> 15 (--> 16 -211 111 (--> 22 22)) -16))");
239 DecayTree b2taunu_cc(
"521 (--> -15 16)");
241 DecayTree b2taunu2e(
"-521 (--> 15 (11 -12 16) -16)");
242 DecayTree b2taunu2rho(
"-521 (--> 15 (16 -211 111 (--> 22 22)) -16)");
244 EXPECT_FALSE(Y.getOriginalTree().find_decay(b2taunu_cc));
245 EXPECT_TRUE(Y.getOriginalTree().find_decay(b2taunu));
246 EXPECT_FALSE(Y.getOriginalTree().find_decay(b2taunu2e));
247 EXPECT_TRUE(Y.getOriginalTree().find_decay(b2taunu2rho));
251 TEST(DecayForestTest, RemoveRadiativePhotons)
253 DecayForest B(
"521 (--> -421 (--> 325 (--> 321 111 (--> 22 22)) -211) -13 14 22)",
false,
true);
254 DecayForest B2(
"521 (--> -11 12 22)",
false,
true);
255 DecayForest B3(
"521 (--> -11 12 22)",
false,
false);
257 DecayTree case1(
" 521 (--> -421 (--> 325 (--> 321 111 (--> 22 22)) -211) -13 14)",
true);
258 DecayTree case2(
" 521 (--> -11 12 22)",
true);
259 DecayTree case3(
" 521 (--> -11 12 22)",
false);
260 DecayTree case4(
" 521 (--> -11 12)",
false);
263 DecayTree case5(
" 521 (--> -11 12 22)",
false);
264 DecayTree case6(
" 521 (--> -11 12 22)",
true);
265 DecayTree case7(
" 521 (--> -11 12)",
false);
267 EXPECT_TRUE(B.getOriginalTree().find_decay(case1));
269 EXPECT_TRUE(B2.getOriginalTree().find_decay(case2));
270 EXPECT_FALSE(B2.getOriginalTree().find_decay(case3));
271 EXPECT_TRUE(B2.getOriginalTree().find_decay(case4));
273 EXPECT_TRUE(B3.getOriginalTree().find_decay(case5));
274 EXPECT_FALSE(B3.getOriginalTree().find_decay(case6));
275 EXPECT_FALSE(B3.getOriginalTree().find_decay(case7));
int getPDGCode() const
PDG code.
static const ParticleType pi0
neutral pion particle
static const ChargedStable kaon
charged kaon particle
static const ParticleType photon
photon particle
static const ChargedStable electron
electron particle
Contains several DecayTree objects, which belong all to the same candidate.
DecayNode describes the decay of a particle identified by its pdg code, into list of daughters.
This is a helper class for the MCDecayFinderModule.
Abstract base class for different kinds of events.