8 #include <analysis/dataobjects/Particle.h>
9 #include <analysis/dataobjects/RestOfEvent.h>
10 #include <analysis/dataobjects/ParticleExtraInfoMap.h>
11 #include <mdst/dataobjects/MCParticle.h>
12 #include <mdst/dataobjects/ECLCluster.h>
13 #include <mdst/dataobjects/KLMCluster.h>
14 #include <mdst/dataobjects/V0.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 #include <framework/gearbox/Const.h>
18 #include <framework/utilities/TestHelpers.h>
20 #include <analysis/utility/ParticleCopy.h>
22 #include <TDatabasePDG.h>
24 #include <gtest/gtest.h>
32 class ParticleTest :
public ::testing::Test {
37 DataStore::Instance().setInitializeActive(
true);
46 particles.registerInDataStore();
52 particles.registerRelationTo(mcparticles);
53 particles.registerRelationTo(roes);
54 DataStore::Instance().setInitializeActive(
false);
58 void TearDown()
override
60 DataStore::Instance().reset();
65 TEST_F(ParticleTest, Constructors)
69 EXPECT_EQ(0, p.getPDGCode());
70 EXPECT_TRUE(TLorentzVector(0, 0, 0, 0) == p.get4Vector());
71 EXPECT_EQ(Particle::c_Undefined, p.getParticleSource());
74 TLorentzVector momentum(1, 2, 3, 4);
76 EXPECT_EQ(421, p.getPDGCode());
77 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
78 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
79 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
80 EXPECT_FLOAT_EQ(momentum.Energy(), p.getEnergy());
81 EXPECT_FLOAT_EQ(momentum.M(), p.getMass());
82 EXPECT_EQ(Particle::c_Undefined, p.getParticleSource());
85 TLorentzVector momentum(1, 2, 3, 4);
86 Particle p(momentum, 22, Particle::c_Unflavored, Particle::c_MCParticle, 123);
87 EXPECT_EQ(22, p.getPDGCode());
88 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
89 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
90 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
91 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
92 EXPECT_EQ(Particle::c_MCParticle, p.getParticleSource());
93 EXPECT_EQ(123u, p.getMdstArrayIndex());
100 cluster->setIsTrack(
false);
101 cluster->addHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
102 cluster->setEnergy(1337);
105 EXPECT_EQ(22, p.getPDGCode());
106 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
107 EXPECT_EQ(Particle::c_ECLCluster, p.getParticleSource());
108 EXPECT_FLOAT_EQ(1337, p.getEnergy());
109 EXPECT_EQ(cluster, p.getECLCluster());
110 EXPECT_EQ(
nullptr, p.getTrack());
118 TLorentzVector momentum(1, 2, 3, 4);
119 Particle p(momentum, 310, Particle::c_Unflavored, Particle::c_V0, 0);
120 EXPECT_EQ(310, p.getPDGCode());
121 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
122 EXPECT_EQ(Particle::c_V0, p.getParticleSource());
123 EXPECT_EQ(0u, p.getMdstArrayIndex());
124 EXPECT_EQ(p.getV0(), v0);
128 TEST_F(ParticleTest, Daughters)
130 TLorentzVector momentum;
131 const int nDaughters = 6;
133 std::vector<int> daughterIndices;
134 for (
int i = 0; i < nDaughters; i++) {
135 Particle d(TLorentzVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
136 momentum += d.get4Vector();
137 Particle* newDaughters = particles.appendNew(d);
141 const Particle& p = *(particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices));
142 EXPECT_EQ(411, p.getPDGCode());
143 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
144 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
145 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
146 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
147 EXPECT_EQ(Particle::c_Composite, p.getParticleSource());
148 EXPECT_EQ(0u, p.getMdstArrayIndex());
149 EXPECT_EQ((
unsigned int)nDaughters, p.getNDaughters());
150 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughters().size());
151 EXPECT_EQ((
unsigned int)nDaughters, p.getFinalStateDaughters().size());
152 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughterProperties().size());
154 const Particle pLocal(momentum, 411, Particle::c_Unflavored, daughterIndices, particles.getPtr());
155 EXPECT_DOUBLE_EQ(p.getMass(), pLocal.getMass());
156 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getNDaughters());
157 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughters().size());
158 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getFinalStateDaughters().size());
159 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughterProperties().size());
163 EXPECT_B2FATAL(
Particle p2 =
Particle(momentum, 411, Particle::c_Unflavored, daughterIndices));
166 TEST_F(ParticleTest, DaughterProperties)
168 TLorentzVector momentum;
169 const int nDaughters = 6;
171 std::vector<int> daughterIndices;
172 std::vector<int> daughterProperties;
173 for (
int i = 0; i < nDaughters; i++) {
174 Particle d(TLorentzVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
175 momentum += d.get4Vector();
176 Particle* newDaughters = particles.appendNew(d);
178 daughterProperties.push_back(Particle::PropertyFlags::c_Ordinary);
181 const Particle& p = *(particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices));
182 EXPECT_EQ(411, p.getPDGCode());
183 EXPECT_FLOAT_EQ(0.0, momentum.DeltaPhi(p.get4Vector()));
184 EXPECT_FLOAT_EQ(0.0, momentum.DeltaR(p.get4Vector()));
185 EXPECT_FLOAT_EQ(momentum.Energy(), p.get4Vector().Energy());
186 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
187 EXPECT_EQ(Particle::c_Composite, p.getParticleSource());
188 EXPECT_EQ(0u, p.getMdstArrayIndex());
189 EXPECT_EQ((
unsigned int)nDaughters, p.getNDaughters());
190 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughters().size());
191 EXPECT_EQ((
unsigned int)nDaughters, p.getFinalStateDaughters().size());
192 EXPECT_EQ((
unsigned int)nDaughters, p.getDaughterProperties().size());
193 EXPECT_EQ(Particle::PropertyFlags::c_Ordinary, (p.getDaughterProperties())[0]);
196 const Particle pLocal(momentum, 411, Particle::c_Unflavored, daughterIndices,
197 Particle::PropertyFlags::c_Ordinary, daughterProperties,
199 EXPECT_DOUBLE_EQ(p.getMass(), pLocal.getMass());
200 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getNDaughters());
201 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughters().size());
202 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getFinalStateDaughters().size());
203 EXPECT_EQ((
unsigned int)nDaughters, pLocal.getDaughterProperties().size());
207 EXPECT_B2FATAL(
Particle p2 =
Particle(momentum, 411, Particle::c_Unflavored, daughterIndices));
211 struct ParticleChildrenCounter {
214 bool operator()(
const Particle*) { ++count;
return false; }
217 TEST_F(ParticleTest, ForEachDaughters)
220 TLorentzVector momentum;
221 const int nDaughters = 6;
223 std::vector<int> daughterIndices;
224 int nGrandDaughters = 0;
225 for (
int i = 0; i < nDaughters; i++) {
226 Particle d(TLorentzVector(1, 0, 0, 3.0), (i % 2) ? 211 : -211);
227 momentum += d.get4Vector();
228 Particle* newDaughters = particles.appendNew(d);
231 Particle* grandDaughter = particles.appendNew(d);
236 const Particle& p = *(particles.appendNew(momentum, 411, Particle::c_Unflavored, daughterIndices));
240 auto counterFct = [&count](
const Particle*) { ++count;
return false; };
241 EXPECT_FALSE(p.forEachDaughter(counterFct,
false,
false));
242 EXPECT_EQ(count, nDaughters);
244 EXPECT_FALSE(p.forEachDaughter(counterFct,
true,
false));
245 EXPECT_EQ(count, nDaughters + nGrandDaughters);
247 EXPECT_FALSE(p.forEachDaughter(counterFct,
false,
true));
248 EXPECT_EQ(count, nDaughters + 1);
250 EXPECT_FALSE(p.forEachDaughter(counterFct,
true,
true));
251 EXPECT_EQ(count, nDaughters + nGrandDaughters + 1);
254 ParticleChildrenCounter counterStruct;
255 EXPECT_FALSE(p.forEachDaughter(counterStruct));
256 EXPECT_EQ(counterStruct.count, 0);
258 EXPECT_FALSE(p.forEachDaughter(std::reference_wrapper<ParticleChildrenCounter>(counterStruct)));
259 EXPECT_EQ(counterStruct.count, nDaughters + nGrandDaughters + 1);
263 int maxchildren{1}, total{nDaughters + nGrandDaughters + 1};
264 auto returnFctTester = [&count, &maxchildren](
const Particle*) {++count;
return count >= maxchildren; };
265 for (; maxchildren < 2 * total; ++maxchildren) {
267 EXPECT_EQ(p.forEachDaughter(returnFctTester), maxchildren <= total);
268 EXPECT_EQ(count, std::min(maxchildren, total));
273 TEST_F(ParticleTest, ExtraInfo)
277 EXPECT_THROW(p.getExtraInfo(
"htns"), std::runtime_error);
279 p.addExtraInfo(
"htns", 32.0);
282 EXPECT_THROW(p.addExtraInfo(
"htns", 1234.0), std::runtime_error);
284 EXPECT_DOUBLE_EQ(32.0, p.getExtraInfo(
"htns"));
289 TEST_F(ParticleTest, Copies)
297 eclGamma1->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
301 eclGamma2->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
305 eclGamma3->
setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
309 eclKL->
setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
314 Particle* T1Pion = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 211, Particle::c_Flavored, Particle::c_Track, 1));
315 Particle* T2Pion = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), -211, Particle::c_Flavored, Particle::c_Track, 2));
318 Particle* T1PionCopy = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 211, Particle::c_Flavored, Particle::c_Track, 1));
321 Particle* T1Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 321, Particle::c_Flavored, Particle::c_Track, 1));
322 Particle* T2Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), -321, Particle::c_Flavored, Particle::c_Track, 2));
323 Particle* T3Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 321, Particle::c_Flavored, Particle::c_Track, 3));
324 Particle* T4Kaon = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), -321, Particle::c_Flavored, Particle::c_Track, 4));
327 Particle* T1Gamma = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 22, Particle::c_Unflavored, Particle::c_ECLCluster,
330 Particle* T2Gamma = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 22, Particle::c_Unflavored, Particle::c_ECLCluster,
334 Particle* T3Gamma = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 22, Particle::c_Unflavored, Particle::c_ECLCluster,
337 Particle* T4KL = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), Const::Klong.getPDGCode(), Particle::c_Unflavored,
338 Particle::c_ECLCluster,
341 MC1Pion->
setPDG(Const::pion.getPDGCode());
342 MC1Pion->
set4Vector(TLorentzVector(0, 0, 0, 0));
350 EXPECT_TRUE(T1Pion->
isCopyOf(T1PionCopy));
351 EXPECT_FALSE(T1Pion->
isCopyOf(T1Kaon));
352 EXPECT_FALSE(T1Pion->
isCopyOf(T1Gamma));
353 EXPECT_FALSE(T2Gamma->
isCopyOf(T1Gamma));
356 EXPECT_TRUE(T1Pion->
isCopyOf(T1PionCopy,
true));
357 EXPECT_TRUE(T1Pion->
isCopyOf(T1Kaon,
true));
358 EXPECT_FALSE(T2Gamma->
isCopyOf(T1Gamma,
true));
359 EXPECT_TRUE(T3Gamma->
isCopyOf(T4KL,
true));
360 EXPECT_FALSE(T1PionFromMC->
isCopyOf(T1Pion,
true));
361 EXPECT_FALSE(T1Pion->
isCopyOf(T1PionFromMC,
true));
363 Particle* D0Pi1Pi2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
367 Particle* D0Pi1Pi2Copy = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
371 Particle* D0Pi1Pi2Copy2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
375 Particle* D0K1K2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
379 Particle* D0K1Pi2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
383 EXPECT_FALSE(D0Pi1Pi2->
isCopyOf(D0K1K2));
384 EXPECT_FALSE(D0Pi1Pi2->
isCopyOf(D0K1Pi2));
385 EXPECT_TRUE(D0Pi1Pi2->
isCopyOf(D0Pi1Pi2Copy));
386 EXPECT_TRUE(D0Pi1Pi2->
isCopyOf(D0Pi1Pi2Copy2));
387 EXPECT_TRUE(D0Pi1Pi2Copy->
isCopyOf(D0Pi1Pi2Copy2));
390 Particle* D0K3K4 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 421));
394 Particle* B0_1 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
398 Particle* B0_2 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
402 Particle* B0_3 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
410 Particle* B0_4 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
414 Particle* B0_5 = particles.appendNew(
Particle(TLorentzVector(0, 0, 0, 0), 511));
424 TEST_F(ParticleTest, ExtraInfoMap)
430 p.addExtraInfo(
"htns", 1.0);
431 EXPECT_EQ(1u, map->getNMaps());
434 p.addExtraInfo(
"somethingelse", 2.0);
435 EXPECT_EQ(1u, map->getNMaps());
439 q.addExtraInfo(
"htns", 11.0);
440 EXPECT_EQ(1u, map->getNMaps());
441 q.addExtraInfo(
"somethingelse", 12.0);
442 EXPECT_EQ(1u, map->getNMaps());
445 p.addExtraInfo(
"thirdvar_p", 3.0);
446 EXPECT_EQ(1u, map->getNMaps());
448 q.addExtraInfo(
"thirdvar_q", 13.0);
449 EXPECT_EQ(2u, map->getNMaps());
454 s.addExtraInfo(
"htns", 1.0);
455 s.addExtraInfo(
"somethingelse", 2.0);
456 s.addExtraInfo(
"thirdvar_p", 3.0);
458 t.addExtraInfo(
"htns", 1.0);
459 t.addExtraInfo(
"somethingelse", 2.0);
460 t.addExtraInfo(
"thirdvar_q", 3.0);
462 EXPECT_EQ(2u, map->getNMaps());
464 EXPECT_THROW(s.getExtraInfo(
"thirdvar_q"), std::runtime_error);
465 EXPECT_THROW(t.getExtraInfo(
"thirdvar_p"), std::runtime_error);
469 EXPECT_THROW(u.getExtraInfo(
"htns"), std::runtime_error);
470 u.addExtraInfo(
"htns", 1.0);
471 EXPECT_THROW(u.getExtraInfo(
"somethingelse"), std::runtime_error);
472 EXPECT_THROW(u.getExtraInfo(
"thirdvar_p"), std::runtime_error);
473 EXPECT_THROW(u.getExtraInfo(
"thirdvar_q"), std::runtime_error);
474 u.addExtraInfo(
"somethingelse", 2.0);
475 EXPECT_THROW(u.getExtraInfo(
"thirdvar_p"), std::runtime_error);
476 EXPECT_THROW(u.getExtraInfo(
"thirdvar_q"), std::runtime_error);
481 v.addExtraInfo(
"first", 0.0);
482 v.addExtraInfo(
"htns", 1.0);
483 v.addExtraInfo(
"somethingelse", 2.0);
484 v.addExtraInfo(
"thirdvar_q", 3.0);
488 EXPECT_DOUBLE_EQ(1.0, p.getExtraInfo(
"htns"));
489 EXPECT_DOUBLE_EQ(2.0, p.getExtraInfo(
"somethingelse"));
490 EXPECT_DOUBLE_EQ(3.0, p.getExtraInfo(
"thirdvar_p"));
492 EXPECT_DOUBLE_EQ(11.0, q.getExtraInfo(
"htns"));
493 EXPECT_DOUBLE_EQ(12.0, q.getExtraInfo(
"somethingelse"));
494 EXPECT_DOUBLE_EQ(13.0, q.getExtraInfo(
"thirdvar_q"));
496 EXPECT_DOUBLE_EQ(1.0, s.getExtraInfo(
"htns"));
497 EXPECT_DOUBLE_EQ(2.0, s.getExtraInfo(
"somethingelse"));
498 EXPECT_DOUBLE_EQ(3.0, s.getExtraInfo(
"thirdvar_p"));
500 EXPECT_DOUBLE_EQ(1.0, t.getExtraInfo(
"htns"));
501 EXPECT_DOUBLE_EQ(2.0, t.getExtraInfo(
"somethingelse"));
502 EXPECT_DOUBLE_EQ(3.0, t.getExtraInfo(
"thirdvar_q"));
504 EXPECT_DOUBLE_EQ(0.0, v.getExtraInfo(
"first"));
505 EXPECT_DOUBLE_EQ(1.0, v.getExtraInfo(
"htns"));
506 EXPECT_DOUBLE_EQ(2.0, v.getExtraInfo(
"somethingelse"));
507 EXPECT_DOUBLE_EQ(3.0, v.getExtraInfo(
"thirdvar_q"));
512 EXPECT_DOUBLE_EQ(2.0, tCopy.
getExtraInfo(
"somethingelse"));
513 EXPECT_DOUBLE_EQ(3.0, tCopy.
getExtraInfo(
"thirdvar_q"));
519 TEST_F(ParticleTest, ParticleCopyUtility)
526 Particle* T1Pion = particles.appendNew(
Particle(TLorentzVector(1, 1, 1, 1), 211, Particle::c_Flavored, Particle::c_Track, 1));
531 Particle* T2Kaon = particles.appendNew(
Particle(TLorentzVector(2, 2, 2, 2), -321, Particle::c_Flavored, Particle::c_Track, 2));
536 Particle* T3Kaon = particles.appendNew(
Particle(TLorentzVector(3, 3, 3, 3), 321, Particle::c_Flavored, Particle::c_Track, 3));
541 Particle* ROEPion = particles.appendNew(
Particle(TLorentzVector(3.5, 3.5, 3.5, 3.5), 211, Particle::c_Flavored,
542 Particle::c_Track, 4));
545 Particle* D0KK = particles.appendNew(
Particle(TLorentzVector(4, 4, 4, 4), 421));
549 Particle* B0 = particles.appendNew(
Particle(TLorentzVector(5, 5, 5, 5), 511));
561 EXPECT_EQ(particles.getEntries(), 6);
568 EXPECT_EQ(particles.getEntries(), 11);
610 EXPECT_TRUE(mc1orig == mc1copy);
611 EXPECT_TRUE(mc2orig == mc2copy);
612 EXPECT_TRUE(mc3orig == mc3copy);
614 EXPECT_TRUE(mc1orig->
getPDG() == mc1copy->getPDG());
615 EXPECT_TRUE(mc2orig->getPDG() == mc2copy->getPDG());
616 EXPECT_TRUE(mc3orig->getPDG() == mc3copy->getPDG());
618 EXPECT_TRUE(roeorig->hasParticle(ROEPion) && roecopy->hasParticle(ROEPion));
628 EXPECT_FALSE(mc4orig ==
nullptr);
629 EXPECT_TRUE(mc4copy ==
nullptr);
644 EXPECT_TRUE(mc5orig ==
nullptr);
645 EXPECT_FALSE(mc5copy ==
nullptr);
655 TEST_F(ParticleTest, ECLClusterBased)
660 cluster->setHypothesis(ECLCluster::EHypothesisBit::c_nPhotons);
661 cluster->setEnergy(1.);
662 cluster->setEnergyRaw(2.);
665 EXPECT_FLOAT_EQ(1., p.getECLClusterEnergy());
666 EXPECT_FLOAT_EQ(1., p.getEnergy());
667 EXPECT_EQ(ECLCluster::EHypothesisBit::c_nPhotons, p.getECLClusterEHypothesisBit());
668 EXPECT_FLOAT_EQ(0, p.getMass());
673 cluster->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
674 cluster->setEnergy(1.);
675 cluster->setEnergyRaw(2.);
678 EXPECT_EQ(130, p.getPDGCode());
679 EXPECT_FLOAT_EQ(2., p.getECLClusterEnergy());
680 EXPECT_FLOAT_EQ(std::sqrt(4. + 0.497614 * 0.497614), p.getEnergy());
681 EXPECT_EQ(ECLCluster::EHypothesisBit::c_neutralHadron, p.getECLClusterEHypothesisBit());
682 int pdg = Const::Klong.getPDGCode();
683 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
684 EXPECT_FLOAT_EQ(m, p.getMass());
689 cluster->setHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron);
690 cluster->setEnergy(1.);
691 cluster->setEnergyRaw(2.);
693 Particle p(cluster, Const::neutron);
694 EXPECT_EQ(2112, p.getPDGCode());
695 EXPECT_FLOAT_EQ(2., p.getECLClusterEnergy());
696 EXPECT_FLOAT_EQ(std::sqrt(4. + 0.93956536 * 0.93956536), p.getEnergy());
697 EXPECT_EQ(ECLCluster::EHypothesisBit::c_neutralHadron, p.getECLClusterEHypothesisBit());
698 int pdg = Const::neutron.getPDGCode();
699 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
700 EXPECT_FLOAT_EQ(m, p.getMass());
705 TEST_F(ParticleTest, KLMClusterBased)
710 cluster->setTime(1.1);
711 cluster->setClusterPosition(1.1, 1.1, 1.0);
712 cluster->setLayers(1);
713 cluster->setInnermostLayer(1);
714 cluster->setMomentumMag(1.0);
717 int pdg = Const::Klong.getPDGCode();
718 EXPECT_EQ(pdg, p.getPDGCode());
719 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
720 EXPECT_FLOAT_EQ(sqrt(1. + m * m), p.getEnergy());
721 EXPECT_EQ(Particle::c_Unflavored, p.getFlavorType());
722 EXPECT_FLOAT_EQ(m, p.getMass());
727 cluster->setTime(1.1);
728 cluster->setClusterPosition(1.1, 1.1, 1.0);
729 cluster->setLayers(1);
730 cluster->setInnermostLayer(1);
731 cluster->setMomentumMag(1.0);
733 Particle p(cluster, Const::neutron.getPDGCode());
734 int pdg = Const::neutron.getPDGCode();
735 EXPECT_EQ(pdg, p.getPDGCode());
736 double m = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
737 EXPECT_FLOAT_EQ(sqrt(1. + m * m), p.getEnergy());
738 EXPECT_EQ(Particle::c_Flavored, p.getFlavorType());
739 EXPECT_FLOAT_EQ(m, p.getMass());
void setConnectedRegionId(int crid)
Set connected region id.
void setClusterId(int clusterid)
Set cluster id.
void setHypothesis(EHypothesisBit hypothesis)
Set hypotheses.
A Class to store the Monte Carlo particle information.
void set4Vector(const TLorentzVector &p4)
Sets the 4Vector of particle.
void setPDG(int pdg)
Set PDG code of the particle.
int getPDG() const
Return PDG code of particle.
Class to store reconstructed particles.
bool overlapsWith(const Particle *oParticle) const
Returns true if final state ancestors of oParticle overlap.
TClonesArray * getArrayPointer() const
Returns the pointer to the store array which holds the daughter particles.
bool isCopyOf(const Particle *oParticle, bool doDetailedComparison=false) const
Returns true if this Particle and oParticle are copies of each other.
float getExtraInfo(const std::string &name) const
Return given value if set.
int getPDGCode(void) const
Returns PDG code.
void addExtraInfo(const std::string &name, float value)
Sets the user-defined data of given name to the given value.
unsigned getNDaughters(void) const
Returns number of daughter particles.
TLorentzVector get4Vector() const
Returns Lorentz vector.
void print() const
Prints the contents of a Particle object to standard output.
void appendDaughter(const Particle *daughter, const bool updateType=true)
Appends index of daughter to daughters index array.
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
This is a general purpose class for collecting reconstructed MDST data objects that are not used in r...
void addParticles(const std::vector< const Particle * > &particle)
Add StoreArray indices of given Particles to the list of unused particles in the event.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
Object holding information for V0s.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Functions that create copies of Particles.
Particle * copyParticle(const Particle *original)
Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters.
Abstract base class for different kinds of events.