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
21a72942
Commit
21a72942
authored
2 years ago
by
Maximilian Reininghaus
Committed by
Nikos Karastathis
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
implemented EMThinning
parent
c9ce6093
No related branches found
No related tags found
1 merge request
!466
Resolve "Implement thinning algorithms"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
corsika/detail/modules/thinning/EMThinning.inl
+62
-10
62 additions, 10 deletions
corsika/detail/modules/thinning/EMThinning.inl
corsika/modules/thinning/EMThinning.hpp
+23
-18
23 additions, 18 deletions
corsika/modules/thinning/EMThinning.hpp
with
85 additions
and
28 deletions
corsika/detail/modules/thinning/EMThinning.inl
+
62
−
10
View file @
21a72942
...
...
@@ -13,17 +13,69 @@
namespace
corsika
{
EMThinning
::
EMThinning
(
HEPEnergyType
threshold
,
double
maxWeight
)
:
threshold_
{
threshold
},
maxWeight_
{
maxWeight
}
{}
EMThinning
::
EMThinning
(
HEPEnergyType
threshold
,
double
maxWeight
)
:
threshold_
{
threshold
}
,
maxWeight_
{
maxWeight
}
{}
template
<
typename
TStackView
>
void
EMThinning
::
doSecondaries
(
TStackView
&
view
)
{
if
(
view
.
getSize
()
!=
2
)
return
;
auto
projectile
=
view
.
getProjectile
();
if
(
!
is_em
(
projectile
.
getPID
()))
return
;
double
const
parentWeight
=
projectile
.
getWeight
();
if
(
parentWeight
>=
maxWeight_
)
{
return
;
}
template
<
typename
TStackView
>
void
EMThinning
::
doSecondaries
(
TStackView
&
view
)
{
if
(
view
.
size
()
!=
2
)
return
;
auto
particle1
=
view
.
begin
();
auto
particle2
=
std
::
next
(
particle1
);
auto
particle2
=
++
(
view
.
begin
());
// skip non-EM interactions
if
(
!
is_em
(
particle1
.
getPID
())
||
!
is_em
(
particle2
.
getPID
()))
{
return
;
}
/* skip high-energy interactions
* We consider only the primary energy. A more sophisticated algorithm might
* sort out above-threshold secondaries and apply thinning only on the subset of
* those below the threshold.
*/
if
(
projectile
.
getEnergy
()
>
threshold_
)
{
return
;
}
corsika
::
HEPEnergyType
const
Esum
=
particle1
.
getEnergy
()
+
particle2
.
getEnergy
();
double
const
p1
=
particle1
.
getEnergy
()
/
Esum
;
double
const
p2
=
particle2
.
getEnergy
()
/
Esum
;
double
const
w1
=
parentWeight
/
p1
;
double
const
w2
=
parentWeight
/
p2
;
if
(
w1
<=
maxWeight_
&&
w2
<=
maxWeight_
)
{
// apply Hillas thinning
if
(
uniform_
(
rng_
)
<=
p1
)
{
// keep 1st with probability p1
particle2
.
setWeight
(
0
);
particle1
.
setWeight
(
w1
);
}
else
{
// keep 2nd
particle1
.
setWeight
(
0
);
particle2
.
setWeight
(
w2
);
}
}
else
{
// weight limitation kicks in, do statistical thinning
double
const
w1prime
=
std
::
min
(
w1
,
maxWeight_
);
double
const
w2prime
=
std
::
min
(
w2
,
maxWeight_
);
if
(
uniform_
(
rng_
)
*
w1prime
<=
parentWeight
)
{
// keep 1st
particle1
.
setWeight
(
w1prime
);
}
else
{
particle1
.
setWeight
(
0
);
}
if
(
uniform_
(
rng_
)
*
w2prime
<=
parentWeight
)
{
// keep 2nd
particle2
.
setWeight
(
w2prime
);
}
else
{
particle2
.
setWeight
(
0
);
}
}
if
(.
getCode
())
corsika
::
HEPEnergyType
const
E0
=
}
// TODO: skip this for multithinning
for
(
auto
&
p
:
view
)
{
if
(
auto
const
w
=
p
.
getWeight
();
w
==
0
)
{
p
.
erase
();
}
}
}
}
}
// namespace corsika
This diff is collapsed.
Click to expand it.
corsika/modules/thinning/EMThinning.hpp
+
23
−
18
View file @
21a72942
...
...
@@ -8,36 +8,41 @@
#pragma once
#include
<random>
#include
<corsika/framework/core/PhysicalUnits.hpp>
#include
<corsika/framework/random/RNGManager.hpp>
#include
<corsika/framework/process/SecondariesProcess.hpp>
namespace
corsika
{
//! This process implements thinning for EM splitting processes (1 -> 2)
class
EMThinning
:
public
SecondariesProcess
<
EMThinning
>
{
public:
/**
* Construct a new EMThinning process.
*
* @param threshold: thinning applied below this energy
* @param maxWeight: maximum allowed weight
*/
EMThinning
(
HEPEnergyType
threshold
,
double
maxWeight
);
//! This process implements thinning for EM splitting processes (1 -> 2)
class
EMThinning
:
public
SecondariesProcess
<
EMThinning
>
{
public:
/**
* Construct a new EMThinning process.
*
* @param threshold: thinning applied below this energy
* @param maxWeight: maximum allowed weight
*/
EMThinning
(
HEPEnergyType
threshold
,
double
maxWeight
);
/**
* Apply thinning to secondaries. Only EM primaries with two EM secondaries are considered.
* Apply thinning to secondaries. Only EM primaries with two EM secondaries are
* considered.
*
* @tparam TStackView
*/
template
<
typename
TStackView
>
void
doSecondaries
(
TStackView
&
);
private:
HEPEnergyType
const
threshold_
;
double
const
maxWeight_
;
};
}
private:
default_prng_type
&
rng_
=
RNGManager
<>::
getInstance
().
getRandomStream
(
"thinning"
);
std
::
uniform_real_distribution
<
double
>
uniform_
{};
HEPEnergyType
const
threshold_
;
double
const
maxWeight_
;
};
}
// namespace corsika
#include
<corsika/detail/
proces
s/thinning/EMThinning.inl>
#include
<corsika/detail/
module
s/thinning/EMThinning.inl>
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