IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
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
Model registry
Operate
Environments
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
Air Shower Physics
corsika
Commits
d00f5efa
Commit
d00f5efa
authored
4 years ago
by
Felix Riehn
Committed by
ralfulrich
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
use global particle thresholds in ParticleCut
parent
007626fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!303
Resolve "advanced ParticleCut process"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
corsika/detail/modules/ParticleCut.inl
+61
-27
61 additions, 27 deletions
corsika/detail/modules/ParticleCut.inl
corsika/modules/ParticleCut.hpp
+9
-8
9 additions, 8 deletions
corsika/modules/ParticleCut.hpp
tests/modules/testParticleCut.cpp
+9
-1
9 additions, 1 deletion
tests/modules/testParticleCut.cpp
with
79 additions
and
36 deletions
corsika/detail/modules/ParticleCut.inl
+
61
−
27
View file @
d00f5efa
...
...
@@ -15,44 +15,80 @@ namespace corsika {
ParticleCut
::
ParticleCut
(
const
HEPEnergyType
eEleCut
,
const
HEPEnergyType
ePhoCut
,
const
HEPEnergyType
eHadCut
,
const
HEPEnergyType
eMuCut
,
bool
inv
)
:
electron_energy_cut_
(
eEleCut
)
,
photon_energy_cut_
(
ePhoCut
)
,
had_energy_cut_
(
eHadCut
)
,
mu_energy_cut_
(
eMuCut
)
,
doCutEm_
(
false
)
:
doCutEm_
(
false
)
,
doCutInv_
(
inv
)
,
energy_
(
0
_GeV
)
,
em_energy_
(
0
_GeV
)
,
em_count_
(
0
)
,
inv_energy_
(
0
_GeV
)
,
inv_count_
(
0
)
{}
,
inv_count_
(
0
)
{
for
(
auto
p
:
get_all_particles
())
if
(
is_hadron
(
p
))
set_energy_threshold
(
p
,
eHadCut
);
else
if
(
is_muon
(
p
))
set_energy_threshold
(
p
,
eMuCut
);
else
if
(
p
==
Code
::
Electron
||
p
==
Code
::
Positron
)
set_energy_threshold
(
p
,
eEleCut
);
else
if
(
p
==
Code
::
Gamma
)
set_energy_threshold
(
p
,
ePhoCut
);
else
if
(
p
==
Code
::
Nucleus
)
// nuclei have same threshold as hadrons on the nucleon level.
set_energy_threshold
(
p
,
eHadCut
);
CORSIKA_LOG_DEBUG
(
"setting thresholds: electrons = {} GeV, photons = {} GeV, hadrons = {} GeV, "
"muons = {} GeV"
,
eEleCut
/
1
_GeV
,
ePhoCut
/
1
_GeV
,
eHadCut
/
1
_GeV
,
eMuCut
/
1
_GeV
);
printThresholds
();
}
ParticleCut
::
ParticleCut
(
const
HEPEnergyType
eHadCut
,
const
HEPEnergyType
eMuCut
,
bool
inv
)
:
electron_energy_cut_
(
0
_eV
)
,
photon_energy_cut_
(
0
_eV
)
,
had_energy_cut_
(
eHadCut
)
,
mu_energy_cut_
(
eMuCut
)
,
doCutEm_
(
true
)
:
doCutEm_
(
true
)
,
doCutInv_
(
inv
)
,
energy_
(
0
_GeV
)
,
em_energy_
(
0
_GeV
)
,
em_count_
(
0
)
,
inv_energy_
(
0
_GeV
)
,
inv_count_
(
0
)
{}
,
inv_count_
(
0
)
{
for
(
auto
p
:
get_all_particles
())
if
(
is_hadron
(
p
))
set_energy_threshold
(
p
,
eHadCut
);
else
if
(
is_muon
(
p
))
set_energy_threshold
(
p
,
eMuCut
);
CORSIKA_LOG_DEBUG
(
"setting thresholds: hadrons = {} GeV, "
"muons = {} GeV"
,
eHadCut
/
1
_GeV
,
eMuCut
/
1
_GeV
);
printThresholds
();
}
ParticleCut
::
ParticleCut
(
const
HEPEnergyType
eCut
,
bool
em
,
bool
inv
)
:
electron_energy_cut_
(
eCut
)
,
photon_energy_cut_
(
eCut
)
,
had_energy_cut_
(
eCut
)
,
mu_energy_cut_
(
eCut
)
,
doCutEm_
(
em
)
:
doCutEm_
(
em
)
,
doCutInv_
(
inv
)
,
energy_
(
0
_GeV
)
,
em_energy_
(
0
_GeV
)
,
em_count_
(
0
)
,
inv_energy_
(
0
_GeV
)
,
inv_count_
(
0
)
{
for
(
auto
p
:
get_all_particles
())
set_energy_threshold
(
p
,
eCut
);
CORSIKA_LOG_DEBUG
(
"setting threshold for all particles to {} GeV"
,
eCut
/
1
_GeV
);
printThresholds
();
}
ParticleCut
::
ParticleCut
(
std
::
unordered_map
<
Code
const
,
HEPEnergyType
const
>
const
&
eCuts
,
bool
em
,
bool
inv
)
:
doCutEm_
(
em
)
,
doCutInv_
(
inv
)
,
energy_
(
0
_GeV
)
,
em_energy_
(
0
_GeV
)
,
em_count_
(
0
)
,
inv_energy_
(
0
_GeV
)
,
inv_count_
(
0
)
{}
,
inv_count_
(
0
)
{
set_energy_thresholds
(
eCuts
);
CORSIKA_LOG_DEBUG
(
"setting threshold particles individually"
);
printThresholds
();
}
template
<
typename
TParticle
>
bool
ParticleCut
::
isBelowEnergyCut
(
TParticle
const
&
vP
)
const
{
...
...
@@ -62,16 +98,9 @@ namespace corsika {
if
(
pid
==
Code
::
Nucleus
)
{
// calculate energy per nucleon
auto
const
ElabNuc
=
energyLab
/
vP
.
getNuclearA
();
return
(
ElabNuc
<
had_energy_cut_
);
}
else
if
(
pid
==
Code
::
Gamma
)
{
return
(
energyLab
<
photon_energy_cut_
);
}
else
if
(
pid
==
Code
::
Electron
||
pid
==
Code
::
Positron
)
{
return
(
energyLab
<
electron_energy_cut_
);
}
else
if
(
is_muon
(
pid
))
{
return
(
energyLab
<
mu_energy_cut_
);
return
(
ElabNuc
<
get_energy_threshold
(
pid
));
}
else
{
// assuming the rest are hadrons
return
(
energyLab
<
had_energy_cut_
);
return
(
energyLab
<
get_energy_threshold
(
pid
));
}
}
...
...
@@ -125,6 +154,11 @@ namespace corsika {
return
ProcessReturn
::
Ok
;
}
void
ParticleCut
::
printThresholds
()
{
for
(
auto
p
:
get_all_particles
())
CORSIKA_LOG_DEBUG
(
"energy threshold for particle {} is {} GeV"
,
p
,
get_energy_threshold
(
p
)
/
1
_GeV
);
}
void
ParticleCut
::
showResults
()
{
CORSIKA_LOG_INFO
(
" ******************************
\n
"
...
...
This diff is collapsed.
Click to expand it.
corsika/modules/ParticleCut.hpp
+
9
−
8
View file @
d00f5efa
...
...
@@ -42,6 +42,10 @@ namespace corsika {
//! discarded altogether.
ParticleCut
(
const
HEPEnergyType
eCut
,
bool
em
,
bool
inv
);
//! threshold for specific particles redefined. EM and invisible particles can be set
//! to be discarded altogether.
ParticleCut
(
std
::
unordered_map
<
Code
const
,
HEPEnergyType
const
>
const
&
eCuts
,
bool
em
,
bool
inv
);
void
doSecondaries
(
corsika
::
setup
::
StackView
&
);
ProcessReturn
doContinuous
(
corsika
::
setup
::
Stack
::
particle_type
&
vParticle
,
corsika
::
setup
::
Trajectory
const
&
vTrajectory
);
...
...
@@ -50,13 +54,14 @@ namespace corsika {
return
meter
*
std
::
numeric_limits
<
double
>::
infinity
();
}
void
printThresholds
();
void
showResults
();
void
reset
();
HEPEnergyType
getElectronECut
()
const
{
return
electron_energy_cut_
;
}
HEPEnergyType
getPhotonECut
()
const
{
return
photon
_energy_
cut_
;
}
HEPEnergyType
getMuonECut
()
const
{
return
mu
_energy_
cut_
;
}
HEPEnergyType
getHadronECut
()
const
{
return
had
_energy_
cut_
;
}
HEPEnergyType
getElectronECut
()
const
{
return
get_energy_threshold
(
Code
::
Electron
)
;
}
HEPEnergyType
getPhotonECut
()
const
{
return
get
_energy_
threshold
(
Code
::
Gamma
)
;
}
HEPEnergyType
getMuonECut
()
const
{
return
get
_energy_
threshold
(
Code
::
MuPlus
)
;
}
HEPEnergyType
getHadronECut
()
const
{
return
get
_energy_
threshold
(
Code
::
Proton
)
;
}
HEPEnergyType
getInvEnergy
()
const
{
return
inv_energy_
;
}
HEPEnergyType
getCutEnergy
()
const
{
return
energy_
;
}
HEPEnergyType
getEmEnergy
()
const
{
return
em_energy_
;
}
...
...
@@ -71,10 +76,6 @@ namespace corsika {
bool
isBelowEnergyCut
(
TParticle
const
&
)
const
;
private
:
HEPEnergyType
electron_energy_cut_
;
HEPEnergyType
photon_energy_cut_
;
HEPEnergyType
had_energy_cut_
;
HEPEnergyType
mu_energy_cut_
;
bool
doCutEm_
;
bool
doCutInv_
;
HEPEnergyType
energy_
=
0
*
electronvolt
;
...
...
This diff is collapsed.
Click to expand it.
tests/modules/testParticleCut.cpp
+
9
−
1
View file @
d00f5efa
...
...
@@ -25,7 +25,7 @@ using namespace corsika;
TEST_CASE
(
"ParticleCut"
,
"[processes]"
)
{
logging
::
set_level
(
logging
::
level
::
info
);
corsika_logger
->
set_pattern
(
"[%n:%^%-8l%$]
custom pattern:
%v"
);
corsika_logger
->
set_pattern
(
"[%n:%^%-8l%$] %v"
);
feenableexcept
(
FE_INVALID
);
using
EnvType
=
setup
::
Environment
;
...
...
@@ -171,6 +171,14 @@ TEST_CASE("ParticleCut", "[processes]") {
CHECK
(
view
.
getSize
()
==
5
);
}
SECTION
(
"cut low energy: reset thresholds of arbitrary set of particles"
)
{
ParticleCut
cut
({{
Code
::
Electron
,
5
_MeV
},
{
Code
::
Positron
,
50
_MeV
}},
false
,
true
);
CHECK
(
get_energy_threshold
(
Code
::
Electron
)
!=
get_energy_threshold
(
Code
::
Positron
));
CHECK_FALSE
(
get_energy_threshold
(
Code
::
Electron
)
==
Electron
::
mass
);
// test default values still correct
CHECK
(
get_energy_threshold
(
Code
::
Proton
)
==
5
_GeV
);
}
SECTION
(
"cut on time"
)
{
ParticleCut
cut
(
20
_GeV
,
false
,
false
);
const
TimeType
too_late
=
1
_s
;
...
...
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