8 #include <analysis/utility/MCMatching.h>
9 #include <analysis/dataobjects/Particle.h>
10 #include <analysis/dataobjects/ParticleExtraInfoMap.h>
11 #include <analysis/variables/BasicParticleInformation.h>
12 #include <analysis/variables/MCTruthVariables.h>
14 #include <mdst/dataobjects/MCParticle.h>
15 #include <mdst/dataobjects/MCParticleGraph.h>
16 #include <framework/datastore/StoreArray.h>
17 #include <framework/datastore/StoreObjPtr.h>
18 #include <framework/gearbox/Const.h>
20 #include <gtest/gtest.h>
52 c_CreateNewMCParticle,
58 Decay(
int pdg,
const std::vector<Decay>& daughters = std::vector<Decay>()):
59 m_pdg(pdg), m_daughterDecays(daughters), m_mcparticle(nullptr), m_particle(nullptr)
62 m_graphParticle->
setPDG(m_pdg);
63 m_graphParticle->setStatus(MCParticle::c_PrimaryParticle);
64 for (
const Decay& d : daughters) {
65 gParticleGraph.
addDecay(*m_graphParticle, *d.m_graphParticle);
72 gParticleGraph.
clear();
75 m_mcparticle = mcparticles[m_graphParticle->getIndex() - 1];
77 for (Decay& d : m_daughterDecays)
82 [[nodiscard]]
Particle* getParticle(
int pdg)
const
84 if (m_pdg == pdg and m_particle)
87 for (
auto& d : m_daughterDecays) {
95 [[nodiscard]]
MCParticle* getMCParticle(
int pdg)
const
97 if (m_pdg == pdg and m_mcparticle)
100 for (
auto& d : m_daughterDecays) {
108 Decay* getDecay(
int pdg)
113 for (
auto& d : m_daughterDecays) {
114 Decay* res = d.getDecay(pdg);
121 Decay& operator[](
int i) {
return m_daughterDecays[i]; }
124 struct ReconstructedDecay {
126 ReconstructedDecay(
int pdg,
const std::vector<ReconstructedDecay>& daughters = std::vector<ReconstructedDecay>(),
127 EBehavior behavior = c_Default):
128 m_pdg(pdg), m_daughterDecays(daughters), m_behavior(behavior), m_optMcPart(nullptr), m_optDecay(nullptr) { }
129 ReconstructedDecay(
int pdg,
const std::vector<ReconstructedDecay>& daughters, EBehavior behavior,
MCParticle* optMcPart):
130 m_pdg(pdg), m_daughterDecays(daughters), m_behavior(behavior), m_optMcPart(optMcPart), m_optDecay(nullptr) { }
131 ReconstructedDecay(
int pdg,
const std::vector<ReconstructedDecay>& daughters, EBehavior behavior, Decay* optDecay):
132 m_pdg(pdg), m_daughterDecays(daughters), m_behavior(behavior), m_optMcPart(nullptr), m_optDecay(optDecay) { }
134 vector<ReconstructedDecay> m_daughterDecays;
135 EBehavior m_behavior;
146 void reconstruct(ReconstructedDecay decay)
151 if (decay.m_behavior == c_CreateNewMCParticle) {
153 m_graphParticle->
setPDG(decay.m_pdg);
155 }
else if (decay.m_behavior == c_RelateWith) {
156 m_mcparticle = decay.m_optMcPart;
157 }
else if (decay.m_behavior == c_ReconstructFrom) {
158 ASSERT_TRUE(decay.m_optDecay !=
nullptr);
159 Decay* mcDecay = decay.m_optDecay;
160 decay.m_optDecay =
nullptr;
161 decay.m_behavior = Decay::c_Default;
162 mcDecay->reconstruct(decay);
167 if (isFSP(decay.m_pdg)) {
169 m_particle = particles.appendNew(m_graphParticle->get4Vector(), decay.m_pdg);
170 m_particle->addRelationTo(m_mcparticle);
173 if (!decay.m_daughterDecays.empty()) {
174 Decay* mcDecay =
this;
175 if (decay.m_behavior == c_ReconstructFrom) {
177 mcDecay = decay.m_optDecay;
179 std::vector<int> daughterIndices;
180 for (
unsigned int i = 0; i < decay.m_daughterDecays.size(); i++) {
182 ReconstructedDecay rd = decay.m_daughterDecays[i];
184 if (rd.m_behavior == c_ReconstructFrom) {
185 ASSERT_NE(rd.m_optDecay,
nullptr);
187 rd.m_optDecay =
nullptr;
188 rd.m_behavior = Decay::c_Default;
190 ASSERT_TRUE(decay.m_daughterDecays.size() > i);
191 d = &(mcDecay->m_daughterDecays[i]);
193 d->reconstruct({rd});
195 daughterIndices.push_back(d->m_particle->getArrayIndex());
198 if (decay.m_pdg != 0) {
200 std::vector<int> decaylist, decaybarlist;
201 for (
int idx : daughterIndices) {
202 const Particle* daughterPart = particles[idx];
204 decaylist.push_back(daughterPDG);
205 decaybarlist.push_back((daughterPart->
getFlavorType() == Particle::c_Flavored) ? (-daughterPDG) : daughterPDG);
207 std::sort(decaylist.begin(), decaylist.end());
208 std::sort(decaybarlist.begin(), decaybarlist.end());
209 bool isUnflavored = (decaylist == decaybarlist);
211 m_particle = particles.appendNew(ROOT::Math::PxPyPzEVector(), decay.m_pdg,
212 isUnflavored ? (Particle::c_Unflavored) : (Particle::c_Flavored),
218 [[nodiscard]]
string getString()
const {
return "Particles(MCParticles,MCMatch,Flags):\n" + getStringInternal(); }
221 vector<Decay> m_daughterDecays;
229 [[nodiscard]]
string getStringInternal(
int depth = 0)
const
233 for (
int i = 0; i < depth; i++)
244 s << m_mcparticle->
getPDG();
251 s <<
", " << mcMatch->
getPDG() <<
", ";
252 if (m_particle->
hasExtraInfo(MCMatching::c_extraInfoMCErrors))
253 s << MCMatching::explainFlags(m_particle->
getExtraInfo(MCMatching::c_extraInfoMCErrors));
262 if (!m_daughterDecays.empty()) {
264 for (
const Decay& d : m_daughterDecays) {
265 s <<
"\n" << d.getStringInternal(depth + 1);
268 s <<
"\n" << spaces <<
"]";
276 class MCMatchingTest :
public ::testing::Test {
279 void SetUp()
override
285 particles.registerInDataStore();
287 particles.registerRelationTo(mcparticles);
291 void TearDown()
override
293 DataStore::Instance().reset();
301 Decay d(111, {22, 22});
305 EXPECT_EQ(mcparticles.getEntries(), 3);
306 EXPECT_EQ(mcparticles[0]->getPDG(), Const::pi0.getPDGCode());
307 EXPECT_EQ(mcparticles[1]->getPDG(), Const::photon.getPDGCode());
308 EXPECT_EQ(mcparticles[2]->getPDG(), Const::photon.getPDGCode());
309 EXPECT_EQ(mcparticles[0]->getMother(),
nullptr);
310 EXPECT_EQ(mcparticles[1]->getMother(), mcparticles[0]);
311 EXPECT_EQ(mcparticles[2]->getMother(), mcparticles[0]);
313 Decay e(111, {22, 22});
315 EXPECT_EQ(mcparticles.getEntries(), 6);
316 EXPECT_EQ(mcparticles[3]->getPDG(), Const::pi0.getPDGCode());
317 EXPECT_EQ(mcparticles[3]->getNDaughters(), 2);
318 EXPECT_EQ(mcparticles[4]->getPDG(), Const::photon.getPDGCode());
319 EXPECT_EQ(mcparticles[5]->getPDG(), Const::photon.getPDGCode());
320 EXPECT_EQ(mcparticles[4]->getNDaughters(), 0);
321 EXPECT_EQ(mcparticles[5]->getNDaughters(), 0);
322 EXPECT_EQ(mcparticles[3]->getMother(),
nullptr);
323 EXPECT_EQ(mcparticles[4]->getMother(), mcparticles[3]);
324 EXPECT_EQ(mcparticles[5]->getMother(), mcparticles[3]);
328 EXPECT_EQ(mcparticles.getEntries(), 7);
329 EXPECT_EQ(mcparticles[6]->getPDG(), Const::pion.getPDGCode());
331 Decay g(421, {321, -211, {111, {22, 22}}});
333 EXPECT_EQ(3, g.m_mcparticle->getNDaughters());
334 EXPECT_EQ(mcparticles.getEntries(), 13);
338 TEST_F(MCMatchingTest, CorrectReconstruction)
343 Decay d(421, {321, -211, {111, {22, 22}}});
344 d.reconstruct({421, {321, -211, {111, {22, 22}}}});
347 EXPECT_EQ(mcparticles[0]->getPDG(), 421);
348 EXPECT_EQ(mcparticles[5]->getPDG(), Const::photon.getPDGCode());
349 EXPECT_EQ(particles.getEntries(), 6);
351 ASSERT_NE(d.m_particle,
nullptr);
352 const auto& fspParticles = d.m_particle->getFinalStateDaughters();
353 EXPECT_EQ(fspParticles.size(), 4u);
355 for (
const Particle* p : fspParticles) {
359 EXPECT_TRUE(mcparticles[0] == d.m_mcparticle);
360 EXPECT_TRUE(mcparticles[0]->getRelated<Particle>() ==
nullptr);
361 EXPECT_TRUE(mcparticles[3]->getRelated<Particle>() ==
nullptr);
364 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
366 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
370 TEST_F(MCMatchingTest, SetMCTruthNeverRun)
372 Decay d(421, {321, -211, {111, {22, 22}}});
373 d.reconstruct({421, {211, -211, {111, {22, 22}}}});
375 EXPECT_EQ(
nullptr, d.m_particle->getRelated<
MCParticle>());
376 ASSERT_FALSE(d.m_particle->hasExtraInfo(MCMatching::c_extraInfoMCErrors));
377 EXPECT_EQ(MCMatching::c_InternalError, MCMatching::getMCErrors(d.m_particle)) << d.getString();
380 TEST_F(MCMatchingTest, SettingTruths)
382 Decay d(421, {321, -211, {111, {22, 22}}});
383 d.reconstruct({421, {211, -211, {111, {22, 22}}}});
386 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
387 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
390 ASSERT_FALSE(d.m_particle->hasExtraInfo(MCMatching::c_extraInfoMCErrors));
391 ASSERT_FALSE(d.getParticle(111)->hasExtraInfo(MCMatching::c_extraInfoMCErrors));
393 EXPECT_EQ(MCMatching::c_MisID, MCMatching::getMCErrors(d.m_particle)) << d.getString();
396 ASSERT_TRUE(d.m_particle->hasExtraInfo(MCMatching::c_extraInfoMCErrors));
397 ASSERT_TRUE(d.getParticle(111)->hasExtraInfo(MCMatching::c_extraInfoMCErrors));
401 TEST_F(MCMatchingTest, MisID)
404 Decay d(421, {321, -211, {111, {22, 22}}});
405 d.reconstruct({421, {211, -211, {111, {22, 22}}}});
406 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
407 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
408 EXPECT_EQ(MCMatching::c_MisID, MCMatching::getMCErrors(d.m_particle)) << d.getString();
412 Decay d(421, {321, -211, {111, {22, 22}}});
413 d.reconstruct({413, {321, -13, {111, {22, 22}}}});
414 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
415 EXPECT_EQ(MCMatching::c_MisID | MCMatching::c_AddedWrongParticle, MCMatching::getMCErrors(d.m_particle)) << d.getString();
418 Decay d(421, {321, -211, {111, {22, 22}}});
419 d.reconstruct({421, {321, 13, {111, {22, 22}}}});
420 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
421 EXPECT_EQ(MCMatching::c_MisID, MCMatching::getMCErrors(d.m_particle)) << d.getString();
424 Decay d(421, {321, -211, {111, {22, 22}}});
425 d.reconstruct({421, {211, 13, {111, {22, 22}}}});
426 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
427 EXPECT_EQ(MCMatching::c_MisID, MCMatching::getMCErrors(d.m_particle)) << d.getString();
431 Decay d(421, {321, -211, {111, {22, 22}}});
432 d.reconstruct({421, { -211, 321, {111, {22, 22}}}});
433 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
434 EXPECT_EQ(MCMatching::c_MisID, MCMatching::getMCErrors(d.m_particle)) << d.getString();
439 TEST_F(MCMatchingTest, MissingParticles)
443 Decay d(421, {321, -211, {111, {22, 22}}});
444 d.reconstruct({421, {321, -211, {0}}});
445 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
446 EXPECT_EQ(MCMatching::c_MissGamma | MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
449 Decay d(421, {321, -211, {111, {22, 22}}});
450 d.reconstruct({421, {321, 0, {111, {22, 22}}}});
451 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
452 EXPECT_EQ(MCMatching::getMCErrors(d.m_particle), MCMatching::c_MissMassiveParticle) << d.getString();
455 Decay d(421, {321, -211, {111, {22, 22}}});
456 d.reconstruct({421, {0, -211, {111, {22, 22}}}});
457 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
458 EXPECT_EQ(MCMatching::getMCErrors(d.m_particle), MCMatching::c_MissMassiveParticle) << d.getString();
461 Decay d(421, {321, -211, {111, {22, 22}}});
462 d.reconstruct({421, {0, -13, {111, {22, 22}}}});
463 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
464 EXPECT_EQ(MCMatching::getMCErrors(d.m_particle), MCMatching::c_MissMassiveParticle | MCMatching::c_MisID) << d.getString();
467 TEST_F(MCMatchingTest, KLongCorrect)
470 Decay d(431, { {323, {321, {111, {22, 22}} }}, { -311, {130}}});
476 d.reconstruct({431, { {323, {321, {111, {22, 22}} }}, {130, {}, Decay::c_ReconstructFrom, d.getDecay(130)}}});
477 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
478 EXPECT_EQ(MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
480 TEST_F(MCMatchingTest, KLongMissed)
483 Decay d(431, { {323, {321, {111, {22, 22}} }}, { -311, {130}}});
489 d.reconstruct({431, { {323, {321, {111, {22, 22}} }}, 0}});
490 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
491 EXPECT_EQ(MCMatching::c_MissKlong | MCMatching::c_MissMassiveParticle | MCMatching::c_MissingResonance,
492 MCMatching::getMCErrors(d.m_particle)) << d.getString();
494 TEST_F(MCMatchingTest, KShortCorrect)
497 Decay d(431, { {323, {321, {111, {22, 22}} }}, { -311, {{310, {211, -211}}}}});
507 d.reconstruct({431, { {323, {321, {111, {22, 22}} }}, {310, {{211, {}, Decay::c_ReconstructFrom, d.getDecay(211)}, { -211, {}, Decay::c_ReconstructFrom, d.getDecay(-211)}}}}});
508 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
509 EXPECT_EQ(MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
511 TEST_F(MCMatchingTest, KShortMissed)
514 Decay d(431, { {323, {321, {111, {22, 22}} }}, { -311, {{310, {211, -211}}}}});
524 d.reconstruct({431, { {323, {321, {111, {22, 22}} }}, 0}});
525 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
526 EXPECT_EQ(MCMatching::c_MissMassiveParticle | MCMatching::c_MissingResonance,
527 MCMatching::getMCErrors(d.m_particle)) << d.getString();
530 TEST_F(MCMatchingTest, PionWithOneGamma)
535 Decay d(421, {321, -211, {111, {22, 22}}});
536 d.reconstruct({421, {321, -211, {111, {0, 22}}}});
538 EXPECT_EQ(particles.getEntries(), 5);
539 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
540 EXPECT_EQ(MCMatching::c_MissGamma, MCMatching::getMCErrors(d.m_particle)) << d.getString();
543 Decay d(421, {321, -211, {111, {22, 22}}});
544 d.reconstruct({421, {321, 0, {111, {0, 22}}}});
545 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
546 EXPECT_EQ(MCMatching::c_MissMassiveParticle | MCMatching::c_MissGamma, MCMatching::getMCErrors(d.m_particle)) << d.getString();
549 TEST_F(MCMatchingTest, TauWithResonance)
553 Decay d(15, {16, { -213, { -211, {111, {22, 22}}}}});
554 d.reconstruct({15, {0, { -213, { -211, {111, {22, 22}}}}}});
555 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
556 EXPECT_EQ(MCMatching::c_MissNeutrino, MCMatching::getMCErrors(d.m_particle)) << d.getString();
560 Decay d(15, {16, { -213, { -211, {111, {22, 22}}}}});
561 d.reconstruct({15, {{ -211, {}, Decay::c_ReconstructFrom, &d[1][0]}, {111, {22, 22}, Decay::c_ReconstructFrom, &d[1][1]}}});
562 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
563 EXPECT_EQ(MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
567 Decay d(15, {16, { -213, { -211, {111, {22, 22}}}}});
568 d.reconstruct({15, {{ -211, {}, Decay::c_ReconstructFrom, &d[1][0]}, {111, {0, {22, {}, Decay::c_ReconstructFrom, &d[1][1][1]}}, Decay::c_ReconstructFrom, &d[1][1]}}});
569 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
570 EXPECT_EQ(MCMatching::c_MissGamma | MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
574 Decay g(-512, {211, -211, -16, {15, {16, { -213, { -211, {111, {22, 22}}}}}}});
576 d.reconstruct({15, {{ -211, {}, Decay::c_ReconstructFrom, &g[1]}, {111, {22, 22}, Decay::c_ReconstructFrom, &d[1][1]}}});
577 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
578 EXPECT_EQ(MCMatching::c_MissMassiveParticle | MCMatching::c_MissingResonance | MCMatching::c_MissNeutrino |
579 MCMatching::c_AddedWrongParticle,
580 MCMatching::getMCErrors(d.m_particle)) << d.getString();
585 TEST_F(MCMatchingTest, MissGamma)
589 Decay d(431, {{421, {321, -211, {111, {22, 22}}}}, {111, {22, 22}}});
590 d.reconstruct({431, {{421, {321, -211, {111, {22, 22}}}}, {111, {22, 22}}}});
591 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
592 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
596 Decay d(431, {{421, {321, -211, {111, {22, 22}}}}, {111, {22, 22}}});
597 Decay& gamma = d[1][0];
598 d.reconstruct({431, {{421, {321, -211, {111, {22, 22}}}}, {22, {}, Decay::c_ReconstructFrom, &gamma}}});
599 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
600 EXPECT_EQ(MCMatching::c_MissGamma | MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
605 Decay d(431, {{421, {321, -211, {111, {22, 22}}}}, 22});
606 d.reconstruct({431, {{421, {321, -211, {111, {22, 22}}}}, 22}});
607 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
608 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
612 Decay d(111, {11, -11, 22});
613 d.reconstruct({111, {11, -11, 22}});
614 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
615 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
619 Decay d(111, {11, -11, 22});
620 d.reconstruct({111, {11, -11, 0}});
621 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
622 EXPECT_EQ(MCMatching::c_MissGamma, MCMatching::getMCErrors(d.m_particle)) << d.getString();
626 Decay d(111, {22, 22});
628 d.reconstruct({111, {22, {22, {}, Decay::c_ReconstructFrom, &gamma}}});
629 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
631 EXPECT_EQ(MCMatching::c_AddedWrongParticle, MCMatching::getMCErrors(d.m_particle)) << d.getString();
635 Decay d(111, {22, 22, 22, 22});
636 d.reconstruct({111, {22, 22, 22, 22}});
637 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
638 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
642 Decay d(111, {22, 22, 22, 22});
643 d.reconstruct({111, {22, 22, 0, 0}});
644 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
645 EXPECT_EQ(MCMatching::c_MissGamma, MCMatching::getMCErrors(d.m_particle)) << d.getString();
649 Decay d(111, {22, 22, 22, 22});
651 d.reconstruct({111, {22, 22, 22, {22, {}, Decay::c_ReconstructFrom, &gamma}}});
652 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
653 EXPECT_EQ(MCMatching::c_MissGamma, MCMatching::getMCErrors(d.m_particle)) << d.getString();
657 TEST_F(MCMatchingTest, WrongPhotonForPi0)
660 Decay d(521, {211, Decay(421, {321, -211, Decay(111, {22, 22})}), 22});
662 d.reconstruct({521, {211, {421, {321, -211, {111, {{22}, {22, {}, Decay::c_RelateWith, d.getMCParticle(211)}}}}}}});
670 Decay* pi0decay = d.getDecay(111);
671 ASSERT_TRUE(MCMatching::setMCTruth(pi0)) << pi0decay->getString();
673 EXPECT_EQ(MCMatching::c_MisID | MCMatching::c_AddedWrongParticle | MCMatching::c_MissMassiveParticle | MCMatching::c_MissGamma |
674 MCMatching::c_MissingResonance,
675 MCMatching::getMCErrors(pi0)) << pi0decay->getString();
679 Decay* d0decay = d.getDecay(421);
680 ASSERT_TRUE(MCMatching::setMCTruth(p)) << d0decay->getString();
681 EXPECT_EQ(MCMatching::c_MisID | MCMatching::c_AddedWrongParticle | MCMatching::c_MissGamma | MCMatching::c_MissingResonance,
682 MCMatching::getMCErrors(p)) << d0decay->getString();
685 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
686 EXPECT_EQ(MCMatching::c_MisID | MCMatching::c_AddedWrongParticle | MCMatching::c_MissGamma | MCMatching::c_MissingResonance,
687 MCMatching::getMCErrors(d.m_particle)) << d.getString();
692 TEST_F(MCMatchingTest, DecayInFlightCorrect)
695 Decay d(421, {321, { -211, {13}}, {111, {22, 22}}});
698 muon->setStatus(muon->getStatus() & (~MCParticle::c_PrimaryParticle));
699 ASSERT_FALSE(muon->hasStatus(MCParticle::c_PrimaryParticle));
700 d.reconstruct({421, {321, -211, {111, {22, 22}}}});
702 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
703 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
704 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
707 Decay d(421, {{321, {11, -12, {111, {22, 22}}}}, -211, {111, {22, 22}}});
708 d.reconstruct({421, {321, -211, {111, {22, 22}}}});
710 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
711 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
712 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
716 TEST_F(MCMatchingTest, DecayInFlight)
722 muon->setStatus(muon->getStatus() & (~MCParticle::c_PrimaryParticle));
723 d.reconstruct({ -211, {}, Decay::c_RelateWith, muon});
725 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
726 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
727 EXPECT_EQ(MCMatching::c_DecayInFlight, MCMatching::getMCErrors(d.m_particle)) << d.getString();
730 Decay d(421, {321, { -211, {13}}, {111, {22, 22}}});
733 muon->setStatus(muon->getStatus() & (~MCParticle::c_PrimaryParticle));
734 d.reconstruct({421, {321, { -211, {}, Decay::c_RelateWith, muon}, {111, {22, 22}}}});
737 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
738 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
739 EXPECT_EQ(MCMatching::c_DecayInFlight, MCMatching::getMCErrors(d.m_particle)) << d.getString();
743 TEST_F(MCMatchingTest, CorrectFSPsWrongDecay)
746 Decay d(-413, {{ -411, {321, -211, -211}}, {111, {22, 22}}});
749 Decay& pi2 = d[0][2];
751 ASSERT_TRUE(d.getDecay(111) == &pi0);
753 d.reconstruct({ -413, {{ -421, {321, -211, {111, {22, 22}, Decay::c_ReconstructFrom, &pi0}}}, { -211, {}, Decay::c_ReconstructFrom, &pi2}}});
756 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
757 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
759 EXPECT_EQ(MCMatching::c_AddedWrongParticle | MCMatching::c_MissingResonance,
760 MCMatching::getMCErrors(d.m_particle)) << d.getString();
764 TEST_F(MCMatchingTest, WrongCombination)
768 Decay d(-413, {{ -421, {321, -211, {111, {22, 22}}}}, -211});
770 Decay* pi1 = &(d[0][1]);
771 Decay* pi2 = &(d[1]);
772 ASSERT_TRUE(pi1->m_pdg == pi2->m_pdg);
774 d.reconstruct({ -413, {{ -421, {321, { -211, {}, Decay::c_ReconstructFrom, pi2}, {111, {22, 22}}}}, { -211, {}, Decay::c_ReconstructFrom, pi1}}});
777 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
778 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
780 EXPECT_EQ(MCMatching::c_AddedWrongParticle | MCMatching::c_MissingResonance,
781 MCMatching::getMCErrors(d.m_particle)) << d.getString();
786 Decay d(511, {{333, {321, -321}}, {333, {321, -321}}});
788 Decay* k1 = &(d[0][1]);
789 Decay* k2 = &(d[1][1]);
790 ASSERT_TRUE(k1->m_pdg == k2->m_pdg);
792 d.reconstruct({511, {
793 {333, {321, { -321, {}, Decay::c_ReconstructFrom, k2}}},
794 {333, {321, { -321, {}, Decay::c_ReconstructFrom, k1}}}
799 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
800 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
802 EXPECT_EQ(MCMatching::c_AddedWrongParticle | MCMatching::c_MissingResonance,
803 MCMatching::getMCErrors(d.m_particle)) << d.getString();
807 TEST_F(MCMatchingTest, SelfCrossFeed)
810 Decay d(300533, {{511, {321, -211, {111, {22, 22}}}}, { -511, { -321, 211, {111, {22, 22}}}}});
812 Decay* pi1 = &(d[0][2]);
813 Decay* pi2 = &(d[1][2]);
814 ASSERT_TRUE(pi1->m_pdg == pi2->m_pdg);
816 d.reconstruct({300533, {
817 {511, {321, -211, {111, {22, 22}, Decay::c_ReconstructFrom, pi2}}},
818 { -511, { -321, 211, {111, {22, 22}, Decay::c_ReconstructFrom, pi1}}}
823 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
824 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
826 EXPECT_EQ(MCMatching::c_AddedWrongParticle | MCMatching::c_MissingResonance,
827 MCMatching::getMCErrors(d.m_particle)) << d.getString();
831 TEST_F(MCMatchingTest, FlavouredD0Decay)
835 Decay d(421, { -321, 211});
836 d.reconstruct({421, { -321, 211}});
837 ASSERT_EQ(Particle::c_Flavored, d.m_particle->getFlavorType());
839 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
840 EXPECT_EQ(d.m_particle->getPDGCode(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
841 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
845 Decay d(-421, { -321, 211});
846 d.reconstruct({ -421, { -321, 211}});
847 ASSERT_EQ(Particle::c_Flavored, d.m_particle->getFlavorType());
849 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
850 EXPECT_EQ(d.m_particle->getPDGCode(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
851 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
855 Decay d(421, { -321, 211});
856 d.reconstruct({ -421, { -321, 211}});
857 ASSERT_EQ(Particle::c_Flavored, d.m_particle->getFlavorType());
859 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
860 EXPECT_EQ(MCMatching::c_AddedWrongParticle, MCMatching::getMCErrors(d.m_particle)) << d.getString();
864 Decay d(-421, { -321, 211});
865 d.reconstruct({421, { -321, 211}});
866 ASSERT_EQ(Particle::c_Flavored, d.m_particle->getFlavorType());
868 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
869 EXPECT_EQ(MCMatching::c_AddedWrongParticle, MCMatching::getMCErrors(d.m_particle)) << d.getString();
873 TEST_F(MCMatchingTest, UnflavouredD0Decay)
877 Decay d(421, { -321, 321});
878 d.reconstruct({421, { -321, 321}});
879 ASSERT_EQ(Particle::c_Unflavored, d.m_particle->getFlavorType());
881 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
882 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
883 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
887 Decay d(-421, { -321, 321});
888 d.reconstruct({ -421, { -321, 321}});
889 ASSERT_EQ(Particle::c_Unflavored, d.m_particle->getFlavorType());
891 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
892 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
893 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
897 Decay d(421, { -321, 321});
898 d.reconstruct({ -421, { -321, 321}});
899 ASSERT_EQ(Particle::c_Unflavored, d.m_particle->getFlavorType());
901 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
902 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
906 Decay d(-421, { -321, 321});
907 d.reconstruct({421, { -321, 321}});
908 ASSERT_EQ(Particle::c_Unflavored, d.m_particle->getFlavorType());
910 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
911 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
916 TEST_F(MCMatchingTest, MissingResonance)
920 Decay d(511, {{ -411, { -321, 321, 211}}, {213, {211, {111, {22, 22}}}}});
921 d.reconstruct({511, {{ -411, { -321, 321, 211}}, {213, {211, {111, {22, 22}}}}}});
923 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
924 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
928 Decay d(511, {{ -411, { -321, 321, 211}}, {213, {211, {111, {22, 22}}}}});
930 Decay* piplus = &(d[1][0]);
931 Decay* pi0 = &(d[1][1]);
933 d.reconstruct({511, {{ -411, { -321, 321, 211}}, {211, {}, Decay::c_ReconstructFrom, piplus}, {111, {22, 22}, Decay::c_ReconstructFrom, pi0}}});
935 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
936 EXPECT_EQ(MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
940 TEST_F(MCMatchingTest, MissingFSPReplacedBySecondary)
942 Decay d(521, {{ -421, {321, { -211, {22, -211}}}}, 211, 211, -211});
943 Decay* pi = &(d[0][1][1]);
944 d.reconstruct({521, {{ -421, {321, -211}}, 211, 211, {
946 Decay::c_ReconstructFrom, pi
950 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
951 EXPECT_EQ(MCMatching::c_MissMassiveParticle, MCMatching::getMCErrors(d.m_particle)) << d.getString();
953 TEST_F(MCMatchingTest, BeamBackground)
955 Decay d(421, {321, -211, {111, {22, 22}}});
958 d.reconstruct({421, {321, { -211, {}, Decay::c_RelateWith, noParticle}, {111, {22, 22}}}});
961 ASSERT_FALSE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
962 EXPECT_EQ(MCMatching::c_InternalError, MCMatching::getMCErrors(d.m_particle)) << d.getString();
963 EXPECT_EQ(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
966 TEST_F(MCMatchingTest, DuplicateTrack)
969 Decay d(421, {321, -211, {111, {22, 22}}});
972 ASSERT_TRUE(kaon !=
nullptr);
974 d.reconstruct({421, {321, { -211, {}, Decay::c_RelateWith, kaon}, {111, {22, 22}}}});
976 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
977 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
978 EXPECT_EQ(MCMatching::c_MissMassiveParticle | MCMatching::c_MisID, MCMatching::getMCErrors(d.m_particle)) << d.getString();
983 TEST_F(MCMatchingTest, MissingFSRMissingPHOTOS)
986 Decay d(521, { -11, 12, 22});
989 EXPECT_FALSE(MCMatching::isFSR(photon));
991 d.reconstruct({521, { -11}});
992 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
993 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
994 EXPECT_EQ(MCMatching::c_MissGamma | MCMatching::c_MissNeutrino, MCMatching::getMCErrors(d.m_particle)) << d.getString();
999 Decay d(521, { -11, 12, 22});
1002 photon->
setStatus(MCParticle::c_PrimaryParticle | MCParticle::c_IsISRPhoton);
1003 EXPECT_FALSE(MCMatching::isFSR(photon));
1005 d.reconstruct({521, { -11}});
1006 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1007 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
1008 EXPECT_EQ(MCMatching::c_MissGamma | MCMatching::c_MissNeutrino, MCMatching::getMCErrors(d.m_particle)) << d.getString();
1013 Decay d(521, { -11, 12, 22});
1016 photon->
setStatus(MCParticle::c_PrimaryParticle | MCParticle::c_IsFSRPhoton);
1017 EXPECT_TRUE(MCMatching::isFSR(photon));
1019 d.reconstruct({521, { -11}});
1020 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1021 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
1022 EXPECT_EQ(MCMatching::c_MissFSR | MCMatching::c_MissNeutrino, MCMatching::getMCErrors(d.m_particle)) << d.getString();
1027 Decay d(521, { -11, 12, 22});
1030 photon->
setStatus(MCParticle::c_PrimaryParticle | MCParticle::c_IsPHOTOSPhoton);
1031 EXPECT_FALSE(MCMatching::isFSR(photon));
1033 d.reconstruct({521, { -11}});
1034 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1035 EXPECT_EQ(d.m_mcparticle->getPDG(), d.m_particle->getRelated<
MCParticle>()->
getPDG());
1036 EXPECT_EQ(MCMatching::c_MissPHOTOS | MCMatching::c_MissNeutrino, MCMatching::getMCErrors(d.m_particle)) << d.getString();
1041 TEST_F(MCMatchingTest, UnspecifiedParticleReconstruction)
1045 Decay d(511, {{30343, {321, -211}}, -13, 13});
1046 d.reconstruct({511, {{30343, {321, -211}}, -13, 13}});
1048 Particle* Xsd = d.m_particle->getDaughters()[0];
1049 ASSERT_TRUE(Xsd !=
nullptr);
1050 EXPECT_EQ(Variable::particleIsUnspecified(Xsd),
false);
1051 Xsd->
setProperty(Particle::PropertyFlags::c_IsUnspecified);
1052 EXPECT_EQ(Variable::particleIsUnspecified(Xsd),
true);
1054 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1055 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
1059 Decay d(511, {{313, {321, -211}}, -13, 13});
1060 d.reconstruct({511, {{30343, {321, -211}}, -13, 13}});
1062 Particle* Xsd = d.m_particle->getDaughters()[0];
1063 ASSERT_TRUE(Xsd !=
nullptr);
1064 EXPECT_EQ(Variable::particleIsUnspecified(Xsd),
false);
1065 Xsd->
setProperty(Particle::PropertyFlags::c_IsUnspecified);
1066 EXPECT_EQ(Variable::particleIsUnspecified(Xsd),
true);
1068 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1069 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(d.m_particle)) << d.getString();
1073 Decay d(511, { {313, {321, -211}}, {443, { -13, 13}}});
1074 Decay* mup = &(d[1][0]);
1075 Decay* mum = &(d[1][1]);
1076 d.reconstruct({511, {{30343, {321, -211}}, { -13, {}, Decay::c_ReconstructFrom, mup}, {13, {}, Decay::c_ReconstructFrom, mum}}});
1078 Particle* Xsd = d.m_particle->getDaughters()[0];
1079 ASSERT_TRUE(Xsd !=
nullptr);
1080 EXPECT_EQ(Variable::particleIsUnspecified(Xsd),
false);
1081 Xsd->
setProperty(Particle::PropertyFlags::c_IsUnspecified);
1082 EXPECT_EQ(Variable::particleIsUnspecified(Xsd),
true);
1084 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1085 EXPECT_EQ(MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
1090 TEST_F(MCMatchingTest, CountMissingParticle)
1094 Decay d(421, {321, -211, {111, {22, 22}}});
1095 d.reconstruct({421, {321, -211, {0}}});
1096 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1097 EXPECT_EQ(MCMatching::c_MissGamma | MCMatching::c_MissingResonance, MCMatching::getMCErrors(d.m_particle)) << d.getString();
1098 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1099 vector<int> daughterPDG{Const::pi0.getPDGCode()};
1100 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG), 1);
1104 Decay d(421, {321, -211, {111, {22, 22}}});
1105 d.reconstruct({421, {321, 0, {111, {22, 22}}}});
1106 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1107 EXPECT_EQ(MCMatching::getMCErrors(d.m_particle), MCMatching::c_MissMassiveParticle) << d.getString();
1108 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1109 vector<int> daughterPDG{Const::pion.getPDGCode()};
1110 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG), 1);
1114 Decay d(421, {321, -211, {111, {22, 22}}});
1115 d.reconstruct({421, {0, -211, {111, {22, 22}}}});
1116 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1117 EXPECT_EQ(MCMatching::getMCErrors(d.m_particle), MCMatching::c_MissMassiveParticle) << d.getString();
1118 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1119 vector<int> daughterPDG{Const::kaon.getPDGCode()};
1120 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG), 1);
1124 Decay d(-521, { -321, {421, {321, -211, {111, {22, 22}}}}});
1125 d.reconstruct({ -521, {0, {421, {0, -211, {111, {22, 22}}}}}});
1126 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1127 EXPECT_EQ(MCMatching::getMCErrors(d.m_particle), MCMatching::c_MissMassiveParticle) << d.getString();
1128 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1129 vector<int> daughterPDG{Const::kaon.getPDGCode()};
1130 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG), 2);
1134 Decay d(431, { {323, {321, {111, {22, 22}} }}, { -311, {{310, {211, -211}}}}});
1144 d.reconstruct({431, { {323, {321, {111, {22, 22}} }}, 0}});
1145 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1146 EXPECT_EQ(MCMatching::c_MissMassiveParticle | MCMatching::c_MissingResonance,
1147 MCMatching::getMCErrors(d.m_particle)) << d.getString();
1148 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1149 vector<int> daughterPDG{Const::Kshort.getPDGCode()};
1150 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG), 1);
1154 Decay d(431, { {323, {321, {111, {22, 22}} }}, { -311, {130}}});
1160 d.reconstruct({431, { {323, {321, {111, {22, 22}} }}, 0}});
1161 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1162 EXPECT_EQ(MCMatching::c_MissKlong | MCMatching::c_MissMassiveParticle | MCMatching::c_MissingResonance,
1163 MCMatching::getMCErrors(d.m_particle)) << d.getString();
1164 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1165 vector<int> daughterPDG{Const::Klong.getPDGCode()};
1166 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG), 1);
1170 Decay d(521, { -11, 12, 22});
1171 d.reconstruct({521, {0, 0, 22}});
1172 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1173 EXPECT_EQ(MCMatching::c_MissNeutrino | MCMatching::c_MissMassiveParticle,
1174 MCMatching::getMCErrors(d.m_particle)) << d.getString();
1175 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1176 vector<int> daughterPDG_E{Const::electron.getPDGCode()};
1177 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG_E), 1);
1178 vector<int> daughterPDG_NuE{12};
1179 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG_NuE), 1);
1180 vector<int> daughterPDG_Nu{12, 14, 16};
1181 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG_Nu), 1);
1185 Decay d(521, { -13, 14, 22});
1186 d.reconstruct({521, {0, 0, 22}});
1187 ASSERT_TRUE(MCMatching::setMCTruth(d.m_particle)) << d.getString();
1188 EXPECT_EQ(MCMatching::c_MissNeutrino | MCMatching::c_MissMassiveParticle,
1189 MCMatching::getMCErrors(d.m_particle)) << d.getString();
1190 ASSERT_NE(
nullptr, d.m_particle->getRelated<
MCParticle>()) << d.getString();
1191 vector<int> daughterPDG_Mu{Const::muon.getPDGCode()};
1192 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG_Mu), 1);
1193 vector<int> daughterPDG_NuMu{14};
1194 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG_NuMu), 1);
1195 vector<int> daughterPDG_Nu{12, 14, 16};
1196 EXPECT_EQ(MCMatching::countMissingParticle(d.m_particle, d.m_particle->getRelated<
MCParticle>(), daughterPDG_Nu), 1);
1202 TEST_F(MCMatchingTest, IsSignalBehavior)
1206 Decay d(511, { {313, {321, -211}}, {443, { -11, 11, 22}}});
1207 Decay* ep = &(d[1][0]);
1208 Decay* em = &(d[1][1]);
1211 d.reconstruct({511, {{313, {321, -211}}, { -11, {}, Decay::c_ReconstructFrom, ep}, {11, {}, Decay::c_ReconstructFrom, em}}});
1214 photon->
setStatus(MCParticle::c_PrimaryParticle | MCParticle::c_IsPHOTOSPhoton);
1219 B->setProperty(Particle::PropertyFlags::c_Ordinary);
1220 ASSERT_TRUE(MCMatching::setMCTruth(B)) << d.getString();
1221 EXPECT_EQ(MCMatching::c_MissingResonance | MCMatching::c_MissPHOTOS, MCMatching::getMCErrors(B)) << d.getString();
1222 EXPECT_EQ(Variable::isSignal(B), 0.0) << d.getString();
1224 B->removeExtraInfo();
1227 B->setProperty(Particle::PropertyFlags::c_IsIgnoreIntermediate);
1228 ASSERT_TRUE(MCMatching::setMCTruth(B)) << d.getString();
1229 EXPECT_EQ(MCMatching::c_MissPHOTOS, MCMatching::getMCErrors(B)) << d.getString();
1230 EXPECT_EQ(Variable::isSignal(B), 0.0) << d.getString();
1232 B->removeExtraInfo();
1235 B->setProperty(Particle::PropertyFlags::c_IsIgnoreRadiatedPhotons);
1236 ASSERT_TRUE(MCMatching::setMCTruth(B)) << d.getString();
1237 EXPECT_EQ(MCMatching::c_MissingResonance, MCMatching::getMCErrors(B)) << d.getString();
1238 EXPECT_EQ(Variable::isSignal(B), 0.0) << d.getString();
1240 B->removeExtraInfo();
1243 B->setProperty(Particle::PropertyFlags::c_IsIgnoreRadiatedPhotons | Particle::PropertyFlags::c_IsIgnoreIntermediate);
1244 ASSERT_TRUE(MCMatching::setMCTruth(B)) << d.getString();
1245 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(B)) << d.getString();
1246 EXPECT_EQ(Variable::isSignal(B), 1.0) << d.getString();
1251 TEST_F(MCMatchingTest, MissingFlagsOfDaughters)
1255 Decay d(300553, { {511, { -13, 13, 321, -211, {111, {22, 22}}}}, {511, {{ -411, {321, -211, -211}}, 211}} });
1258 d.reconstruct({300553, { {511, { -13, 13, 0, 0, {0, {0, 0}}}}, {511, {{ -411, {321, -211, -211}}, 211}} } });
1261 Particle* B1 = d.m_particle->getDaughters()[0];
1262 Particle* B2 = d.m_particle->getDaughters()[1];
1265 ASSERT_TRUE(MCMatching::setMCTruth(B1)) << d.getString();
1266 EXPECT_EQ(MCMatching::c_MissingResonance | MCMatching::c_MissGamma | MCMatching::c_MissMassiveParticle,
1267 MCMatching::getMCErrors(B1)) << d.getString();
1268 EXPECT_EQ(Variable::isSignal(B1), 0.0) << d.getString();
1270 ASSERT_TRUE(MCMatching::setMCTruth(B2)) << d.getString();
1271 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(B2)) << d.getString();
1272 EXPECT_EQ(Variable::isSignal(B2), 1.0) << d.getString();
1274 ASSERT_TRUE(MCMatching::setMCTruth(Y4S)) << d.getString();
1275 EXPECT_EQ(Y4S->
getProperty(), Particle::PropertyFlags::c_Ordinary) << d.getString();
1276 EXPECT_EQ(MCMatching::c_MissingResonance | MCMatching::c_MissGamma | MCMatching::c_MissMassiveParticle,
1277 MCMatching::getMCErrors(Y4S)) << d.getString();
1278 EXPECT_EQ(Variable::isSignal(Y4S), 0.0) << d.getString();
1283 Decay d(300553, { {511, { -13, 13, 321, -211, {111, {22, 22}}}}, {511, {{ -411, {321, -211, -211}}, 211}} });
1286 d.reconstruct({300553, { {511, { -13, 13, 0, 0, {0, {0, 0}}}}, {511, {{ -411, {321, -211, -211}}, 211}} } });
1289 Particle* B1 = d.m_particle->getDaughters()[0];
1290 Particle* B2 = d.m_particle->getDaughters()[1];
1292 int isIgnoreMissing = Particle::PropertyFlags::c_IsIgnoreRadiatedPhotons |
1293 Particle::PropertyFlags::c_IsIgnoreIntermediate |
1294 Particle::PropertyFlags::c_IsIgnoreMassive |
1295 Particle::PropertyFlags::c_IsIgnoreNeutrino |
1296 Particle::PropertyFlags::c_IsIgnoreGamma;
1300 ASSERT_TRUE(MCMatching::setMCTruth(B1)) << d.getString();
1301 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(B1)) << d.getString();
1302 EXPECT_EQ(Variable::isSignal(B1), 1.0) << d.getString();
1305 ASSERT_TRUE(MCMatching::setMCTruth(B2)) << d.getString();
1306 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(B2)) << d.getString();
1307 EXPECT_EQ(Variable::isSignal(B2), 1.0) << d.getString();
1309 ASSERT_TRUE(MCMatching::setMCTruth(Y4S)) << d.getString();
1310 EXPECT_EQ(Y4S->
getProperty(), Particle::PropertyFlags::c_Ordinary) << d.getString();
1311 EXPECT_EQ(MCMatching::c_Correct, MCMatching::getMCErrors(Y4S)) << d.getString();
1312 EXPECT_EQ(Variable::isSignal(Y4S), 1.0) << d.getString();
1318 Decay d(511, {{ -411, { -211, 211, -211, {111, {22, 22}}}}, 211, {113, {211, -211}}});
1321 d.reconstruct({511, {{ -411, { -211, 0, 0, {111, {22, 22}}}}, 211, {0, {0, 0}}}});
1324 Particle* D = d.m_particle->getDaughters()[0];
1329 ASSERT_TRUE(MCMatching::setMCTruth(D)) << d.getString();
1330 EXPECT_EQ(MCMatching::c_MissMassiveParticle,
1331 MCMatching::getMCErrors(D)) << d.getString();
1332 EXPECT_EQ(Variable::isSignal(D), 0.0) << d.getString();
1335 ASSERT_TRUE(MCMatching::setMCTruth(B)) << d.getString();
1336 EXPECT_EQ(MCMatching::c_MissingResonance | MCMatching::c_MissMassiveParticle,
1337 MCMatching::getMCErrors(B)) << d.getString();
1338 EXPECT_EQ(Variable::isSignal(B), 0.0) << d.getString();
1342 Decay d(511, {{ -411, { -211, 211, -211, {111, {22, 22}}}}, 211, {113, {211, -211}}});
1345 d.reconstruct({511, {{ -411, { -211, 0, 0, {111, {22, 22}}}}, 211, {0, {0, 0}}}});
1348 Particle* D = d.m_particle->getDaughters()[0];
1350 int isIgnoreMissing = Particle::PropertyFlags::c_IsIgnoreIntermediate |
1351 Particle::PropertyFlags::c_IsIgnoreMassive;
1353 B->setProperty(isIgnoreMissing);
1356 ASSERT_TRUE(MCMatching::setMCTruth(D)) << d.getString();
1357 EXPECT_EQ(MCMatching::c_MissMassiveParticle,
1358 MCMatching::getMCErrors(D)) << d.getString();
1359 EXPECT_EQ(Variable::isSignal(D), 0.0) << d.getString();
1364 ASSERT_TRUE(MCMatching::setMCTruth(B)) << d.getString();
1365 EXPECT_EQ(MCMatching::c_MissMassiveParticle,
1366 MCMatching::getMCErrors(B)) << d.getString();
1367 EXPECT_EQ(Variable::isSignal(B), 0.0) << d.getString();
Class to represent Particle data in graph.
Class to build, validate and sort a particle decay chain.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
A Class to store the Monte Carlo particle information.
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
unsigned int getStatus(unsigned short int bitmask=USHRT_MAX) const
Return status code of particle.
void setPDG(int pdg)
Set PDG code of the particle.
int getPDG() const
Return PDG code of particle.
void setStatus(unsigned short int status)
Set Status code for the particle.
Class to store reconstructed particles.
void setProperty(const int properties)
sets m_properties
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
EFlavorType getFlavorType() const
Returns flavor type of the decay (for FS particles: flavor type of particle)
int getPDGCode(void) const
Returns PDG code.
int getProperty() const
Returns particle property as a bit pattern The values are defined in the PropertyFlags enum and descr...
double getExtraInfo(const std::string &name) const
Return given value if set.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
void addDecay(GraphParticle &mother, GraphParticle &daughter)
Add decay information between two particles.
void clear()
Reset particles and decay information to make the class reusable.
GraphParticle & addParticle()
Add new particle to the graph.
std::string getString(const TMatrixFBase &matrix, int precision=2, bool color=true)
get HTML table representing a matrix.
Abstract base class for different kinds of events.