8 #include <framework/gearbox/Const.h>
10 #include <TParticlePDG.h>
12 #include <gtest/gtest.h>
19 TEST(ConstTest, ParticleBasics)
32 EXPECT_FALSE(emptyset.
contains(Const::Klong));
35 EXPECT_EQ(0, Const::electron.getIndex());
36 EXPECT_EQ(1, Const::muon.getIndex());
37 EXPECT_EQ(2, Const::pion.getIndex());
38 EXPECT_EQ(3, Const::kaon.getIndex());
39 EXPECT_EQ(4, Const::proton.getIndex());
40 EXPECT_EQ(5, Const::deuteron.getIndex());
44 EXPECT_EQ(1, c.getIndex());
46 EXPECT_EQ(1, p.getIndex());
52 EXPECT_EQ(-1, Const::invalidParticle.getIndex());
53 EXPECT_EQ(-1, Const::Klong.getIndex());
54 EXPECT_EQ(-1, Const::photon.getIndex());
58 TEST(ConstTest, ParticleIteration)
61 EXPECT_FALSE(emptyset.
contains(Const::Klong));
65 EXPECT_EQ(1, (++prefix).getIndex());
67 EXPECT_EQ(0, (postfix++).getIndex());
71 for (
const auto& c : set) {
73 int pdg = c.getPDGCode();
74 unsigned int index = c.getIndex();
93 EXPECT_EQ(1000010020, pdg);
96 EXPECT_TRUE(
false) <<
"Index >5 encountered?";
100 int setSize = Const::ChargedStable::c_SetSize;
101 EXPECT_EQ(setSize, size);
110 EXPECT_TRUE(Const::chargedStableSet.contains(c));
111 EXPECT_EQ(3, c.getIndex());
114 EXPECT_EQ(5, c.getIndex());
115 EXPECT_EQ(1000010020, c.getPDGCode());
119 TEST(ConstTest, ParticleCombination)
144 TEST(ConstTest, FindInParticleSet)
146 for (
const auto& c : Const::chargedStableSet) {
147 int pdg = c.getPDGCode();
148 EXPECT_EQ(pdg, Const::chargedStableSet.find(pdg).getPDGCode());
150 EXPECT_TRUE(Const::chargedStableSet.find(12356467) == Const::invalidParticle);
154 TEST(ConstTest, TDatabasePDG)
156 EXPECT_DOUBLE_EQ(Const::Klong.getParticlePDG()->Charge(), 0);
157 EXPECT_EQ(Const::Klong.getParticlePDG()->PdgCode(), 130);
159 EXPECT_DOUBLE_EQ(Const::proton.getParticlePDG()->Charge(), 3);
160 EXPECT_EQ(Const::proton.getParticlePDG()->PdgCode(), 2212);
163 EXPECT_DOUBLE_EQ(antiproton.getParticlePDG()->Charge(), -3);
164 EXPECT_EQ(antiproton.getParticlePDG()->PdgCode(), -2212);
167 EXPECT_DOUBLE_EQ(1.0, Const::photon.getParticlePDG()->Spin());
168 EXPECT_DOUBLE_EQ(0.5, Const::proton.getParticlePDG()->Spin());
169 EXPECT_DOUBLE_EQ(0.5, Const::electron.getParticlePDG()->Spin());
171 EXPECT_DOUBLE_EQ(0.0, Const::proton.getParticlePDG()->Lifetime());
173 EXPECT_TRUE(Const::neutron.getParticlePDG()->Lifetime() > 800);
174 EXPECT_TRUE(Const::neutron.getParticlePDG()->Lifetime() < 900);
175 EXPECT_TRUE(Const::muon.getParticlePDG()->Lifetime() < 2.2e-6);
176 EXPECT_TRUE(Const::muon.getParticlePDG()->Lifetime() > 2.1e-6);
179 auto* protonnonconst =
const_cast<TParticlePDG*
>(Const::proton.getParticlePDG());
180 auto* photonnonconst =
const_cast<TParticlePDG*
>(Const::photon.getParticlePDG());
183 EXPECT_DOUBLE_EQ(protonnonconst->AntiParticle()->Charge(), -3);
184 EXPECT_EQ(protonnonconst->AntiParticle()->PdgCode(), -2212);
186 EXPECT_TRUE(photonnonconst->AntiParticle() == photonnonconst);
189 EXPECT_TRUE(Const::invalidParticle.getParticlePDG() ==
nullptr);
190 EXPECT_TRUE(Const::unspecifiedParticle.getParticlePDG() ==
nullptr);
194 TEST(ConstTest, DetectorSet)
197 EXPECT_EQ(set, Const::IR);
199 EXPECT_EQ(set, Const::IR + Const::PXD);
201 EXPECT_EQ(set, Const::IR + Const::PXD);
202 EXPECT_TRUE(set == Const::IR + Const::PXD);
203 EXPECT_FALSE(set == Const::IR);
205 EXPECT_EQ(set, Const::PXD);
206 EXPECT_TRUE(set.
contains(Const::PXD));
207 EXPECT_FALSE(set.
contains(Const::IR));
209 EXPECT_EQ(set.getIndex(Const::IR), -1);
210 EXPECT_EQ(set.getIndex(Const::PXD), 0);
213 EXPECT_EQ(*it, Const::PXD);
218 EXPECT_EQ(*it, Const::invalidDetector);
219 EXPECT_EQ(set.
size(), (
size_t)3);
220 EXPECT_EQ(Const::allDetectors.size(), (
size_t)12);
224 TEST(ConstTest, RestrictedDetectorSet)
227 EXPECT_TRUE(Const::PIDDetectors::c_set.size() == Const::PIDDetectors::c_size);
Provides a type-safe way to pass members of the chargedStableSet set.
The DetectorSet class for sets of detector IDs in the form of EDetector values.
A set of ParticleType objects, with defined order.
ParticleType begin() const
Returns first particle.
bool contains(const ParticleType &p) const
Returns true if and only if the set contains 'p'.
unsigned int size() const
Returns number of particles in this set.
ParticleType end() const
Returns an invalid particle to check if iteration should be stopped.
The ParticleType class for identifying different particle types.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.