IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pranav Sampathkumar
corsika
Commits
6a460fac
Commit
6a460fac
authored
4 years ago
by
Maximilian Reininghaus
Committed by
ralfulrich
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
testParticles
parent
91fdc3e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/framework/testParticles.cpp
+85
-84
85 additions, 84 deletions
tests/framework/testParticles.cpp
with
85 additions
and
84 deletions
tests/framework/testParticles.cpp
+
85
−
84
View file @
6a460fac
...
@@ -11,132 +11,133 @@
...
@@ -11,132 +11,133 @@
#include
<catch2/catch.hpp>
#include
<catch2/catch.hpp>
using
namespace
corsika
::
units
;
using
namespace
corsika
::
units
::
si
;
using
namespace
corsika
;
using
namespace
corsika
;
TEST_CASE
(
"ParticleProperties"
,
"[Particles]"
)
{
TEST_CASE
(
"ParticleProperties"
,
"[Particles]"
)
{
SECTION
(
"Types"
)
{
SECTION
(
"Types"
)
{
CHECK
(
Electron
::
GetC
ode
()
==
Code
::
Electron
);
REQUIRE
(
Electron
::
c
ode
==
Code
::
Electron
);
CHECK
(
Positron
::
GetC
ode
()
==
Code
::
Positron
);
REQUIRE
(
Positron
::
c
ode
==
Code
::
Positron
);
CHECK
(
Proton
::
GetC
ode
()
==
Code
::
Proton
);
REQUIRE
(
Proton
::
c
ode
==
Code
::
Proton
);
CHECK
(
Neutron
::
GetC
ode
()
==
Code
::
Neutron
);
REQUIRE
(
Neutron
::
c
ode
==
Code
::
Neutron
);
CHECK
(
Gamma
::
GetC
ode
()
==
Code
::
Gamma
);
REQUIRE
(
Gamma
::
c
ode
==
Code
::
Gamma
);
CHECK
(
PiPlus
::
GetC
ode
()
==
Code
::
PiPlus
);
REQUIRE
(
PiPlus
::
c
ode
==
Code
::
PiPlus
);
}
}
SECTION
(
"Masses"
)
{
SECTION
(
"Masses"
)
{
CHECK
(
Electron
::
GetM
ass
()
/
(
511
_keV
)
==
Approx
(
1
));
REQUIRE
(
Electron
::
m
ass
()
/
(
511
_keV
)
==
Approx
(
1
));
CHECK
(
Electron
::
GetM
ass
()
/
GetM
ass
(
Code
::
Electron
)
==
Approx
(
1
));
REQUIRE
(
Electron
::
m
ass
()
/
m
ass
(
Code
::
Electron
)
==
Approx
(
1
));
REQUIRE
((
Proton
::
GetMass
()
+
Neutron
::
GetMass
())
/
constants
::
nucleonMass
==
REQUIRE
((
Proton
::
mass
()
+
Neutron
::
mass
())
/
constants
::
nucleonMass
==
Approx
(
2
));
Approx
(
2
));
}
}
SECTION
(
"Charges"
)
{
SECTION
(
"Charges"
)
{
CHECK
(
Electron
::
GetC
harge
()
/
constants
::
e
==
Approx
(
-
1
));
REQUIRE
(
Electron
::
c
harge
()
/
constants
::
e
==
Approx
(
-
1
));
CHECK
(
Positron
::
GetC
harge
()
/
constants
::
e
==
Approx
(
+
1
));
REQUIRE
(
Positron
::
c
harge
()
/
constants
::
e
==
Approx
(
+
1
));
CHECK
(
GetC
harge
(
Positron
::
GetAntiParticle
()
)
/
constants
::
e
==
Approx
(
-
1
));
REQUIRE
(
c
harge
(
Positron
::
anti_code
)
/
constants
::
e
==
Approx
(
-
1
));
}
}
SECTION
(
"Names"
)
{
SECTION
(
"Names"
)
{
CHECK
(
Electron
::
GetN
ame
()
==
"e-"
);
REQUIRE
(
Electron
::
n
ame
()
==
"e-"
);
CHECK
(
PiMinus
::
GetN
ame
()
==
"pi-"
);
REQUIRE
(
PiMinus
::
n
ame
()
==
"pi-"
);
CHECK
(
Nucleus
::
GetN
ame
()
==
"nucleus"
);
REQUIRE
(
Nucleus
::
n
ame
()
==
"nucleus"
);
CHECK
(
Iron
::
GetN
ame
()
==
"iron"
);
REQUIRE
(
Iron
::
n
ame
()
==
"iron"
);
}
}
SECTION
(
"PDG"
)
{
SECTION
(
"PDG"
)
{
CHECK
(
Get
PDG
(
Code
::
PiPlus
)
==
PDGCode
::
PiPlus
);
REQUIRE
(
PDG
(
Code
::
PiPlus
)
==
PDGCode
::
PiPlus
);
CHECK
(
Get
PDG
(
Code
::
DPlus
)
==
PDGCode
::
DPlus
);
REQUIRE
(
PDG
(
Code
::
DPlus
)
==
PDGCode
::
DPlus
);
CHECK
(
Get
PDG
(
Code
::
NuMu
)
==
PDGCode
::
NuMu
);
REQUIRE
(
PDG
(
Code
::
NuMu
)
==
PDGCode
::
NuMu
);
CHECK
(
Get
PDG
(
Code
::
NuE
)
==
PDGCode
::
NuE
);
REQUIRE
(
PDG
(
Code
::
NuE
)
==
PDGCode
::
NuE
);
CHECK
(
Get
PDG
(
Code
::
MuMinus
)
==
PDGCode
::
MuMinus
);
REQUIRE
(
PDG
(
Code
::
MuMinus
)
==
PDGCode
::
MuMinus
);
CHECK
(
static_cast
<
int
>
(
Get
PDG
(
Code
::
PiPlus
))
==
211
);
REQUIRE
(
static_cast
<
int
>
(
PDG
(
Code
::
PiPlus
))
==
211
);
CHECK
(
static_cast
<
int
>
(
Get
PDG
(
Code
::
DPlus
))
==
411
);
REQUIRE
(
static_cast
<
int
>
(
PDG
(
Code
::
DPlus
))
==
411
);
CHECK
(
static_cast
<
int
>
(
Get
PDG
(
Code
::
NuMu
))
==
14
);
REQUIRE
(
static_cast
<
int
>
(
PDG
(
Code
::
NuMu
))
==
14
);
CHECK
(
static_cast
<
int
>
(
Get
PDG
(
Code
::
NuEBar
))
==
-
12
);
REQUIRE
(
static_cast
<
int
>
(
PDG
(
Code
::
NuEBar
))
==
-
12
);
CHECK
(
static_cast
<
int
>
(
Get
PDG
(
Code
::
MuMinus
))
==
13
);
REQUIRE
(
static_cast
<
int
>
(
PDG
(
Code
::
MuMinus
))
==
13
);
}
}
SECTION
(
"Conversion PDG -> internal"
)
{
SECTION
(
"Conversion PDG -> internal"
)
{
CHECK
(
C
onvert
F
romPDG
(
PDGCode
::
KStarMinus
)
==
Code
::
KStarMinus
);
REQUIRE
(
c
onvert
_f
rom
_
PDG
(
PDGCode
::
KStarMinus
)
==
Code
::
KStarMinus
);
CHECK
(
C
onvert
F
romPDG
(
PDGCode
::
MuPlus
)
==
Code
::
MuPlus
);
REQUIRE
(
c
onvert
_f
rom
_
PDG
(
PDGCode
::
MuPlus
)
==
Code
::
MuPlus
);
CHECK
(
C
onvert
F
romPDG
(
PDGCode
::
SigmaStarCMinusBar
)
==
Code
::
SigmaStarCMinusBar
);
REQUIRE
(
c
onvert
_f
rom
_
PDG
(
PDGCode
::
SigmaStarCMinusBar
)
==
Code
::
SigmaStarCMinusBar
);
}
}
SECTION
(
"Lifetimes"
)
{
SECTION
(
"Lifetimes"
)
{
REQUIRE
(
GetL
ifetime
(
Code
::
Electron
)
==
REQUIRE
(
l
ifetime
(
Code
::
Electron
)
==
std
::
numeric_limits
<
double
>::
infinity
()
*
si
::
second
);
std
::
numeric_limits
<
double
>::
infinity
()
*
si
::
second
);
REQUIRE
(
GetL
ifetime
(
Code
::
DPlus
)
<
GetL
ifetime
(
Code
::
Gamma
));
REQUIRE
(
l
ifetime
(
Code
::
DPlus
)
<
l
ifetime
(
Code
::
Gamma
));
REQUIRE
(
GetL
ifetime
(
Code
::
RhoPlus
)
/
si
::
second
==
REQUIRE
(
l
ifetime
(
Code
::
RhoPlus
)
/
si
::
second
==
(
Approx
(
4.414566727909413e-24
).
epsilon
(
1e-3
)));
(
Approx
(
4.414566727909413e-24
).
epsilon
(
1e-3
)));
REQUIRE
(
GetL
ifetime
(
Code
::
SigmaMinusBar
)
/
si
::
second
==
REQUIRE
(
l
ifetime
(
Code
::
SigmaMinusBar
)
/
si
::
second
==
(
Approx
(
8.018880848563575e-11
).
epsilon
(
1e-5
)));
(
Approx
(
8.018880848563575e-11
).
epsilon
(
1e-5
)));
REQUIRE
(
GetL
ifetime
(
Code
::
MuPlus
)
/
si
::
second
==
REQUIRE
(
l
ifetime
(
Code
::
MuPlus
)
/
si
::
second
==
(
Approx
(
2.1970332555864364e-06
).
epsilon
(
1e-5
)));
(
Approx
(
2.1970332555864364e-06
).
epsilon
(
1e-5
)));
}
}
SECTION
(
"Particle groups: electromagnetic"
)
{
SECTION
(
"Particle groups: electromagnetic"
)
{
CHECK
(
IsEM
(
Code
::
Gamma
));
REQUIRE
(
is_em
(
Code
::
Gamma
));
CHECK
(
IsEM
(
Code
::
Electron
));
REQUIRE
(
is_em
(
Code
::
Electron
));
CHECK
_FALSE
(
IsEM
(
Code
::
MuPlus
));
REQUIRE
_FALSE
(
is_em
(
Code
::
MuPlus
));
CHECK
_FALSE
(
IsEM
(
Code
::
NuE
));
REQUIRE
_FALSE
(
is_em
(
Code
::
NuE
));
CHECK
_FALSE
(
IsEM
(
Code
::
Proton
));
REQUIRE
_FALSE
(
is_em
(
Code
::
Proton
));
CHECK
_FALSE
(
IsEM
(
Code
::
PiPlus
));
REQUIRE
_FALSE
(
is_em
(
Code
::
PiPlus
));
CHECK
_FALSE
(
IsEM
(
Code
::
Oxygen
));
REQUIRE
_FALSE
(
is_em
(
Code
::
Oxygen
));
}
}
SECTION
(
"Particle groups: hadrons"
)
{
SECTION
(
"Particle groups: hadrons"
)
{
CHECK
_FALSE
(
IsH
adron
(
Code
::
Gamma
));
REQUIRE
_FALSE
(
is_h
adron
(
Code
::
Gamma
));
CHECK
_FALSE
(
IsH
adron
(
Code
::
Electron
));
REQUIRE
_FALSE
(
is_h
adron
(
Code
::
Electron
));
CHECK
_FALSE
(
IsH
adron
(
Code
::
MuPlus
));
REQUIRE
_FALSE
(
is_h
adron
(
Code
::
MuPlus
));
CHECK
_FALSE
(
IsH
adron
(
Code
::
NuE
));
REQUIRE
_FALSE
(
is_h
adron
(
Code
::
NuE
));
CHECK
(
IsH
adron
(
Code
::
Proton
));
REQUIRE
(
is_h
adron
(
Code
::
Proton
));
CHECK
(
IsH
adron
(
Code
::
PiPlus
));
REQUIRE
(
is_h
adron
(
Code
::
PiPlus
));
CHECK
(
IsH
adron
(
Code
::
Oxygen
));
REQUIRE
(
is_h
adron
(
Code
::
Oxygen
));
CHECK
(
IsH
adron
(
Code
::
Nucleus
));
REQUIRE
(
is_h
adron
(
Code
::
Nucleus
));
}
}
SECTION
(
"Particle groups: muons"
)
{
SECTION
(
"Particle groups: muons"
)
{
CHECK_FALSE
(
IsMuon
(
Code
::
Gamma
));
REQUIRE_FALSE
(
is_muon
(
Code
::
Gamma
));
CHECK_FALSE
(
IsMuon
(
Code
::
Electron
));
REQUIRE_FALSE
(
is_muon
(
Code
::
Electron
));
CHECK
(
IsMuon
(
Code
::
MuPlus
));
REQUIRE
(
is_muon
(
Code
::
MuPlus
));
CHECK_FALSE
(
IsMuon
(
Code
::
NuE
));
REQUIRE
(
is_muon
(
Code
::
MuMinus
));
CHECK_FALSE
(
IsMuon
(
Code
::
Proton
));
REQUIRE_FALSE
(
is_muon
(
Code
::
NuE
));
CHECK_FALSE
(
IsMuon
(
Code
::
PiPlus
));
REQUIRE_FALSE
(
is_muon
(
Code
::
Proton
));
CHECK_FALSE
(
IsMuon
(
Code
::
Oxygen
));
REQUIRE_FALSE
(
is_muon
(
Code
::
PiPlus
));
REQUIRE_FALSE
(
is_muon
(
Code
::
Oxygen
));
}
}
SECTION
(
"Particle groups: neutrinos"
)
{
SECTION
(
"Particle groups: neutrinos"
)
{
CHECK_FALSE
(
IsNeutrino
(
Code
::
Gamma
));
REQUIRE_FALSE
(
is_neutrino
(
Code
::
Gamma
));
CHECK_FALSE
(
IsNeutrino
(
Code
::
Electron
));
REQUIRE_FALSE
(
is_neutrino
(
Code
::
Electron
));
CHECK_FALSE
(
IsNeutrino
(
Code
::
MuPlus
));
REQUIRE_FALSE
(
is_neutrino
(
Code
::
MuPlus
));
CHECK
(
IsNeutrino
(
Code
::
NuE
));
REQUIRE_FALSE
(
is_neutrino
(
Code
::
Proton
));
CHECK_FALSE
(
IsNeutrino
(
Code
::
Proton
));
REQUIRE_FALSE
(
is_neutrino
(
Code
::
PiPlus
));
CHECK_FALSE
(
IsNeutrino
(
Code
::
PiPlus
));
REQUIRE_FALSE
(
is_neutrino
(
Code
::
Oxygen
));
CHECK_FALSE
(
IsNeutrino
(
Code
::
Oxygen
));
REQUIRE
(
is_neutrino
(
Code
::
NuE
));
REQUIRE
(
is_neutrino
(
Code
::
NuMu
));
REQUIRE
(
is_neutrino
(
Code
::
NuTau
));
REQUIRE
(
is_neutrino
(
Code
::
NuEBar
));
REQUIRE
(
is_neutrino
(
Code
::
NuMuBar
));
REQUIRE
(
is_neutrino
(
Code
::
NuTauBar
));
}
}
SECTION
(
"Nuclei"
)
{
SECTION
(
"Nuclei"
)
{
CHECK_FALSE
(
IsNucleus
(
Code
::
Gamma
));
REQUIRE_FALSE
(
is_nucleus
(
Code
::
Gamma
));
CHECK
(
IsNucleus
(
Code
::
Argon
));
REQUIRE
(
is_nucleus
(
Code
::
Argon
));
CHECK_FALSE
(
IsNucleus
(
Code
::
Proton
));
REQUIRE_FALSE
(
is_nucleus
(
Code
::
Proton
));
CHECK
(
IsNucleus
(
Code
::
Hydrogen
));
REQUIRE
(
is_nucleus
(
Code
::
Hydrogen
));
CHECK
(
Argon
::
IsNucleus
());
REQUIRE
(
Argon
::
is_nucleus
());
CHECK_FALSE
(
EtaC
::
IsNucleus
());
REQUIRE_FALSE
(
EtaC
::
is_nucleus
());
CHECK
(
GetNucleusA
(
Code
::
Hydrogen
)
==
1
);
REQUIRE
(
nucleus_A
(
Code
::
Hydrogen
)
==
1
);
CHECK
(
GetNucleusA
(
Code
::
Tritium
)
==
3
);
REQUIRE
(
nucleus_A
(
Code
::
Tritium
)
==
3
);
CHECK
(
Hydrogen
::
GetNucleusZ
()
==
1
);
REQUIRE
(
Hydrogen
::
nucleus_Z
()
==
1
);
CHECK
(
Tritium
::
GetNucleusA
()
==
3
);
REQUIRE
(
Tritium
::
nucleus_A
()
==
3
);
// Nucleus is a generic object, it has no specific properties
REQUIRE_THROWS
(
nucleus_Z
(
Code
::
Nucleus
));
CHECK_THROWS
(
GetNucleusA
(
Code
::
Nucleus
));
REQUIRE_THROWS
(
nucleus_A
(
Code
::
Nucleus
));
CHECK_THROWS
(
GetNucleusZ
(
Code
::
Nucleus
));
CHECK_THROWS
(
GetMass
(
Code
::
Nucleus
));
CHECK_THROWS
(
GetCharge
(
Code
::
Nucleus
));
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment