1 #include <analysis/dataobjects/Particle.h>
2 #include <analysis/dataobjects/RestOfEvent.h>
3 #include <analysis/dataobjects/ParticleExtraInfoMap.h>
4 #include <mdst/dataobjects/MCParticle.h>
5 #include <mdst/dataobjects/ECLCluster.h>
6 #include <mdst/dataobjects/KLMCluster.h>
7 #include <mdst/dataobjects/V0.h>
8 #include <framework/datastore/StoreArray.h>
9 #include <framework/datastore/StoreObjPtr.h>
10 #include <framework/utilities/TestHelpers.h>
12 #include <analysis/utility/ParticleCopy.h>
14 #include <TDatabasePDG.h>
16 #include <gtest/gtest.h>
24 class ParticleTest :
public ::testing::Test {
29 DataStore::Instance().setInitializeActive(
true);
37 particleExtraInfo.registerInDataStore();
38 particles.registerInDataStore();
39 mcparticles.registerInDataStore();
40 eclClusters.registerInDataStore();
41 roes.registerInDataStore();
42 klmClusters.registerInDataStore();
43 v0s.registerInDataStore();
44 particles.registerRelationTo(mcparticles);
45 particles.registerRelationTo(roes);
46 DataStore::Instance().setInitializeActive(
false);
50 void TearDown()
override
52 DataStore::Instance().reset();
57 TEST_F(ParticleTest, Constructors)
61 EXPECT_EQ(0, p.getPDGCode());
62 EXPECT_TRUE(TLorentzVector(0, 0, 0, 0) == p.get4Vector());
63 EXPECT_EQ(Particle::c_Undefined, p.getParticleSource());
66 TLorentzVector momentum(1, 2, 3, 4);
68 EXPECT_EQ(421, p.getPDGCode());
69 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
70 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
71 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
72 EXPECT_FLOAT_EQ(momentum.Energy(), p.getEnergy());
73 EXPECT_FLOAT_EQ(momentum.M(), p.getMass());
74 EXPECT_EQ(Particle::c_Undefined, p.getParticleSource());
77 TLorentzVector momentum(1, 2, 3, 4);
78 Particle p(momentum, 22, Particle::c_Unflavored, Particle::c_MCParticle, 123);
79 EXPECT_EQ(22, p.getPDGCode());
80 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
81 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
82 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
83 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
84 EXPECT_EQ(Particle::c_MCParticle, p.getParticleSource());
85 EXPECT_EQ(123u, p.getMdstArrayIndex());
92 cluster->setIsTrack(
false);
93 cluster->addHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
94 cluster->setEnergy(1337);
97 EXPECT_EQ(22, p.getPDGCode());
98 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
99 EXPECT_EQ(Particle::c_ECLCluster, p.getParticleSource());
100 EXPECT_FLOAT_EQ(1337, p.getEnergy());
101 EXPECT_EQ(cluster, p.getECLCluster());
102 EXPECT_EQ(
nullptr, p.getTrack());
110 TLorentzVector momentum(1, 2, 3, 4);
111 Particle p(momentum, 310, Particle::c_Unflavored, Particle::c_V0, 0);
112 EXPECT_EQ(310, p.getPDGCode());
113 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
114 EXPECT_EQ(Particle::c_V0, p.getParticleSource());
115 EXPECT_EQ(0u, p.getMdstArrayIndex());
116 EXPECT_EQ(p.getV0(), v0);
120 TEST_F(ParticleTest, Daughters)
122 TLorentzVector momentum;
123 const int nDaughters = 6;
125 std::vector<int> daughterIndices;
126 for (
int i = 0; i < nDaughters; i++) {
127 Particle d(TLorentzVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
128 momentum += d.get4Vector();
129 Particle* newDaughters = particles.appendNew(d);
133 const Particle& p = *(particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices));
134 EXPECT_EQ(411, p.getPDGCode());
135 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
136 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
137 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
138 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
139 EXPECT_EQ(Particle::c_Composite, p.getParticleSource());
140 EXPECT_EQ(0u, p.getMdstArrayIndex());
141 EXPECT_EQ((
unsigned int)nDaughters, p.getNDaughters());
142 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughters().size());
143 EXPECT_EQ((
unsigned int)nDaughters, p.getFinalStateDaughters().size());
144 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughterProperties().size());
146 const Particle pLocal(momentum, 411, Particle::c_Unflavored, daughterIndices, particles.getPtr());
147 EXPECT_DOUBLE_EQ(p.getMass(), pLocal.getMass());
148 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getNDaughters());
149 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughters().size());
150 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getFinalStateDaughters().size());
151 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughterProperties().size());
155 EXPECT_B2FATAL(
Particle p2 =
Particle(momentum, 411, Particle::c_Unflavored, daughterIndices));
158 TEST_F(ParticleTest, DaughterProperties)
160 TLorentzVector momentum;
161 const int nDaughters = 6;
163 std::vector<int> daughterIndices;
164 std::vector<int> daughterProperties;
165 for (
int i = 0; i < nDaughters; i++) {
166 Particle d(TLorentzVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
167 momentum += d.get4Vector();
168 Particle* newDaughters = particles.appendNew(d);
170 daughterProperties.push_back(Particle::PropertyFlags::c_Ordinary);
173 const Particle& p = *(particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices));
174 EXPECT_EQ(411, p.getPDGCode());
175 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
176 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
177 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
178 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
179 EXPECT_EQ(Particle::c_Composite, p.getParticleSource());
180 EXPECT_EQ(0u, p.getMdstArrayIndex());
181 EXPECT_EQ((
unsigned int)nDaughters, p.getNDaughters());
182 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughters().size());
183 EXPECT_EQ((
unsigned int)nDaughters, p.getFinalStateDaughters().size());
184 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughterProperties().size());
185 EXPECT_EQ(Particle::PropertyFlags::c_Ordinary, (p.getDaughterProperties())[0]);
188 const Particle pLocal(momentum, 411, Particle::c_Unflavored, daughterIndices,
189 Particle::PropertyFlags::c_Ordinary, daughterProperties,
191 EXPECT_DOUBLE_EQ(p.getMass(), pLocal.getMass());
192 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getNDaughters());
193 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughters().size());
194 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getFinalStateDaughters().size());
195 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughterProperties().size());
199 EXPECT_B2FATAL(
Particle p2 =
Particle(momentum, 411, Particle::c_Unflavored, daughterIndices));
203 struct ParticleChildrenCounter {
206 bool operator()(
const Particle*) { ++count;
return false; }
209 TEST_F(ParticleTest, ForEachDaughters)
212 TLorentzVector momentum;
213 const int nDaughters = 6;
215 std::vector<int> daughterIndices;
216 int nGrandDaughters = 0;
217 for (
int i = 0; i < nDaughters; i++) {
218 Particle d(TLorentzVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
219 momentum += d.get4Vector();
220 Particle* newDaughters = particles.appendNew(d);
223 Particle* grandDaughter = particles.appendNew(d);
228 const Particle& p = *(particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices));
232 auto counterFct = [&count](
const Particle*) { ++count;
return false; };
233 EXPECT_FALSE(p.forEachDaughter(counterFct,
false,
false));
234 EXPECT_EQ(count, nDaughters);
236 EXPECT_FALSE(p.forEachDaughter(counterFct,
true,
false));
237 EXPECT_EQ(count, nDaughters + nGrandDaughters);
239 EXPECT_FALSE(p.forEachDaughter(counterFct,
false,
true));
240 EXPECT_EQ(count, nDaughters + 1);
242 EXPECT_FALSE(p.forEachDaughter(counterFct,
true,
true));
243 EXPECT_EQ(count, nDaughters + nGrandDaughters + 1);
246 ParticleChildrenCounter counterStruct;
247 EXPECT_FALSE(p.forEachDaughter(counterStruct));
248 EXPECT_EQ(counterStruct.count, 0);
250 EXPECT_FALSE(p.forEachDaughter(std::reference_wrapper<ParticleChildrenCounter>(counterStruct)));
251 EXPECT_EQ(counterStruct.count, nDaughters + nGrandDaughters + 1);
255 int maxchildren{1}, total{nDaughters + nGrandDaughters + 1};
256 auto returnFctTester = [&count, &maxchildren](
const Particle*) {++count;
return count >= maxchildren; };
257 for (; maxchildren < 2 * total; ++maxchildren) {
259 EXPECT_EQ(p.forEachDaughter(returnFctTester), maxchildren <= total);
260 EXPECT_EQ(count, std::min(maxchildren, total));
265 TEST_F(ParticleTest, ExtraInfo)
269 EXPECT_THROW(p.getExtraInfo(
"htns"), std::runtime_error);
271 p.addExtraInfo(
"htns", 32.0);
274 EXPECT_THROW(p.addExtraInfo(
"htns", 1234.0), std::runtime_error);
276 EXPECT_DOUBLE_EQ(32.0, p.getExtraInfo(
"htns"));
281 TEST_F(ParticleTest, Copies)
289 eclGamma1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
293 eclGamma2->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
297 eclGamma3->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
301 eclKL->
setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
306 Particle* T1Pion = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 211, Particle::c_Flavored, Particle::c_Track, 1));
307 Particle* T2Pion = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), -211, Particle::c_Flavored, Particle::c_Track, 2));
310 Particle* T1PionCopy = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 211, Particle::c_Flavored, Particle::c_Track, 1));
313 Particle* T1Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 321, Particle::c_Flavored, Particle::c_Track, 1));
314 Particle* T2Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), -321, Particle::c_Flavored, Particle::c_Track, 2));
315 Particle* T3Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 321, Particle::c_Flavored, Particle::c_Track, 3));
316 Particle* T4Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), -321, Particle::c_Flavored, Particle::c_Track, 4));
319 Particle* T1Gamma = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 22, Particle::c_Unflavored, Particle::c_ECLCluster,
322 Particle* T2Gamma = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 22, Particle::c_Unflavored, Particle::c_ECLCluster,
326 Particle* T3Gamma = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 22, Particle::c_Unflavored, Particle::c_ECLCluster,
329 Particle* T4KL = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 130, Particle::c_Unflavored, Particle::c_ECLCluster,
333 MC1Pion->
set4Vector(TLorentzVector(0, 0, 0, 0));
341 EXPECT_TRUE(T1Pion->
isCopyOf(T1PionCopy));
342 EXPECT_FALSE(T1Pion->
isCopyOf(T1Kaon));
343 EXPECT_FALSE(T1Pion->
isCopyOf(T1Gamma));
344 EXPECT_FALSE(T2Gamma->
isCopyOf(T1Gamma));
347 EXPECT_TRUE(T1Pion->
isCopyOf(T1PionCopy,
true));
348 EXPECT_TRUE(T1Pion->
isCopyOf(T1Kaon,
true));
349 EXPECT_FALSE(T2Gamma->
isCopyOf(T1Gamma,
true));
350 EXPECT_TRUE(T3Gamma->
isCopyOf(T4KL,
true));
351 EXPECT_FALSE(T1PionFromMC->
isCopyOf(T1Pion,
true));
352 EXPECT_FALSE(T1Pion->
isCopyOf(T1PionFromMC,
true));
354 Particle* D0Pi1Pi2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
358 Particle* D0Pi1Pi2Copy = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
362 Particle* D0Pi1Pi2Copy2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
366 Particle* D0K1K2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
370 Particle* D0K1Pi2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
374 EXPECT_FALSE(D0Pi1Pi2->
isCopyOf(D0K1K2));
375 EXPECT_FALSE(D0Pi1Pi2->
isCopyOf(D0K1Pi2));
376 EXPECT_TRUE(D0Pi1Pi2->
isCopyOf(D0Pi1Pi2Copy));
377 EXPECT_TRUE(D0Pi1Pi2->
isCopyOf(D0Pi1Pi2Copy2));
378 EXPECT_TRUE(D0Pi1Pi2Copy->
isCopyOf(D0Pi1Pi2Copy2));
381 Particle* D0K3K4 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
385 Particle* B0_1 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
389 Particle* B0_2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
393 Particle* B0_3 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
401 Particle* B0_4 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
405 Particle* B0_5 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
415 TEST_F(ParticleTest, ExtraInfoMap)
421 p.addExtraInfo(
"htns", 1.0);
422 EXPECT_EQ(1u, map->getNMaps());
425 p.addExtraInfo(
"somethingelse", 2.0);
426 EXPECT_EQ(1u, map->getNMaps());
430 q.addExtraInfo(
"htns", 11.0);
431 EXPECT_EQ(1u, map->getNMaps());
432 q.addExtraInfo(
"somethingelse", 12.0);
433 EXPECT_EQ(1u, map->getNMaps());
436 p.addExtraInfo(
"thirdvar_p", 3.0);
437 EXPECT_EQ(1u, map->getNMaps());
439 q.addExtraInfo(
"thirdvar_q", 13.0);
440 EXPECT_EQ(2u, map->getNMaps());
445 s.addExtraInfo(
"htns", 1.0);
446 s.addExtraInfo(
"somethingelse", 2.0);
447 s.addExtraInfo(
"thirdvar_p", 3.0);
449 t.addExtraInfo(
"htns", 1.0);
450 t.addExtraInfo(
"somethingelse", 2.0);
451 t.addExtraInfo(
"thirdvar_q", 3.0);
453 EXPECT_EQ(2u, map->getNMaps());
455 EXPECT_THROW(s.getExtraInfo(
"thirdvar_q"), std::runtime_error);
456 EXPECT_THROW(t.getExtraInfo(
"thirdvar_p"), std::runtime_error);
460 EXPECT_THROW(
u.getExtraInfo(
"htns"), std::runtime_error);
461 u.addExtraInfo(
"htns", 1.0);
462 EXPECT_THROW(
u.getExtraInfo(
"somethingelse"), std::runtime_error);
463 EXPECT_THROW(
u.getExtraInfo(
"thirdvar_p"), std::runtime_error);
464 EXPECT_THROW(
u.getExtraInfo(
"thirdvar_q"), std::runtime_error);
465 u.addExtraInfo(
"somethingelse", 2.0);
466 EXPECT_THROW(
u.getExtraInfo(
"thirdvar_p"), std::runtime_error);
467 EXPECT_THROW(
u.getExtraInfo(
"thirdvar_q"), std::runtime_error);
472 v.addExtraInfo(
"first", 0.0);
473 v.addExtraInfo(
"htns", 1.0);
474 v.addExtraInfo(
"somethingelse", 2.0);
475 v.addExtraInfo(
"thirdvar_q", 3.0);
479 EXPECT_DOUBLE_EQ(1.0, p.getExtraInfo(
"htns"));
480 EXPECT_DOUBLE_EQ(2.0, p.getExtraInfo(
"somethingelse"));
481 EXPECT_DOUBLE_EQ(3.0, p.getExtraInfo(
"thirdvar_p"));
483 EXPECT_DOUBLE_EQ(11.0, q.getExtraInfo(
"htns"));
484 EXPECT_DOUBLE_EQ(12.0, q.getExtraInfo(
"somethingelse"));
485 EXPECT_DOUBLE_EQ(13.0, q.getExtraInfo(
"thirdvar_q"));
487 EXPECT_DOUBLE_EQ(1.0, s.getExtraInfo(
"htns"));
488 EXPECT_DOUBLE_EQ(2.0, s.getExtraInfo(
"somethingelse"));
489 EXPECT_DOUBLE_EQ(3.0, s.getExtraInfo(
"thirdvar_p"));
491 EXPECT_DOUBLE_EQ(1.0, t.getExtraInfo(
"htns"));
492 EXPECT_DOUBLE_EQ(2.0, t.getExtraInfo(
"somethingelse"));
493 EXPECT_DOUBLE_EQ(3.0, t.getExtraInfo(
"thirdvar_q"));
495 EXPECT_DOUBLE_EQ(0.0, v.getExtraInfo(
"first"));
496 EXPECT_DOUBLE_EQ(1.0, v.getExtraInfo(
"htns"));
497 EXPECT_DOUBLE_EQ(2.0, v.getExtraInfo(
"somethingelse"));
498 EXPECT_DOUBLE_EQ(3.0, v.getExtraInfo(
"thirdvar_q"));
503 EXPECT_DOUBLE_EQ(2.0, tCopy.
getExtraInfo(
"somethingelse"));
504 EXPECT_DOUBLE_EQ(3.0, tCopy.
getExtraInfo(
"thirdvar_q"));
510 TEST_F(ParticleTest, ParticleCopyUtility)
517 Particle* T1Pion = particles.appendNew(
Particle(TLorentzVector(1, 1, 1, 1), 211, Particle::c_Flavored, Particle::c_Track, 1));
522 Particle* T2Kaon = particles.appendNew(
Particle(TLorentzVector(2, 2, 2, 2), -321, Particle::c_Flavored, Particle::c_Track, 2));
527 Particle* T3Kaon = particles.appendNew(
Particle(TLorentzVector(3, 3, 3, 3), 321, Particle::c_Flavored, Particle::c_Track, 3));
532 Particle* ROEPion = particles.appendNew(
Particle(TLorentzVector(3.5, 3.5, 3.5, 3.5), 211, Particle::c_Flavored,
533 Particle::c_Track, 4));
536 Particle* D0KK = particles.appendNew(
Particle(TLorentzVector(4, 4, 4, 4), 421));
540 Particle* B0 = particles.appendNew(
Particle(TLorentzVector(5, 5, 5, 5), 511));
552 EXPECT_EQ(particles.getEntries(), 6);
559 EXPECT_EQ(particles.getEntries(), 11);
601 EXPECT_TRUE(mc1orig == mc1copy);
602 EXPECT_TRUE(mc2orig == mc2copy);
603 EXPECT_TRUE(mc3orig == mc3copy);
605 EXPECT_TRUE(mc1orig->
getPDG() == mc1copy->getPDG());
606 EXPECT_TRUE(mc2orig->getPDG() == mc2copy->getPDG());
607 EXPECT_TRUE(mc3orig->getPDG() == mc3copy->getPDG());
609 EXPECT_TRUE(roeorig->hasParticle(ROEPion) && roecopy->hasParticle(ROEPion));
619 EXPECT_FALSE(mc4orig ==
nullptr);
620 EXPECT_TRUE(mc4copy ==
nullptr);
635 EXPECT_TRUE(mc5orig ==
nullptr);
636 EXPECT_FALSE(mc5copy ==
nullptr);
646 TEST_F(ParticleTest, ECLClusterBased)
651 cluster->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
652 cluster->setEnergy(1.);
653 cluster->setEnergyRaw(2.);
656 EXPECT_FLOAT_EQ(1., p.getECLClusterEnergy());
657 EXPECT_FLOAT_EQ(1., p.getEnergy());
658 EXPECT_EQ(ECLCluster::EHypothesisBit::c_nPhotons, p.getECLClusterEHypothesisBit());
659 EXPECT_FLOAT_EQ(0, p.getMass());
664 cluster->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
665 cluster->setEnergy(1.);
666 cluster->setEnergyRaw(2.);
669 EXPECT_EQ(130, p.getPDGCode());
670 EXPECT_FLOAT_EQ(2., p.getECLClusterEnergy());
671 EXPECT_FLOAT_EQ(std::sqrt(4. + 0.497614 * 0.497614), p.getEnergy());
672 EXPECT_EQ(ECLCluster::EHypothesisBit::c_neutralHadron, p.getECLClusterEHypothesisBit());
673 int pdg = Const::Klong.getPDGCode();
674 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
675 EXPECT_FLOAT_EQ(m, p.getMass());
680 cluster->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
681 cluster->setEnergy(1.);
682 cluster->setEnergyRaw(2.);
684 Particle p(cluster, Const::neutron);
685 EXPECT_EQ(2112, p.getPDGCode());
686 EXPECT_FLOAT_EQ(2., p.getECLClusterEnergy());
687 EXPECT_FLOAT_EQ(std::sqrt(4. + 0.93956536 * 0.93956536), p.getEnergy());
688 EXPECT_EQ(ECLCluster::EHypothesisBit::c_neutralHadron, p.getECLClusterEHypothesisBit());
689 int pdg = Const::neutron.getPDGCode();
690 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
691 EXPECT_FLOAT_EQ(m, p.getMass());
696 TEST_F(ParticleTest, KLMClusterBased)
701 cluster->setTime(1.1);
702 cluster->setClusterPosition(1.1, 1.1, 1.0);
703 cluster->setLayers(1);
704 cluster->setInnermostLayer(1);
705 cluster->setMomentumMag(1.0);
708 int pdg = Const::Klong.getPDGCode();
709 EXPECT_EQ(pdg, p.getPDGCode());
710 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
711 EXPECT_FLOAT_EQ(sqrt(1. + m * m), p.getEnergy());
712 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
713 EXPECT_FLOAT_EQ(m, p.getMass());
718 cluster->setTime(1.1);
719 cluster->setClusterPosition(1.1, 1.1, 1.0);
720 cluster->setLayers(1);
721 cluster->setInnermostLayer(1);
722 cluster->setMomentumMag(1.0);
724 Particle p(cluster, Const::neutron.getPDGCode());
725 int pdg = Const::neutron.getPDGCode();
726 EXPECT_EQ(pdg, p.getPDGCode());
727 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
728 EXPECT_FLOAT_EQ(sqrt(1. + m * m), p.getEnergy());
729 EXPECT_EQ(Particle::c_Flavored, p.getFlavorType());
730 EXPECT_FLOAT_EQ(m, p.getMass());