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
f6ed04ca
Commit
f6ed04ca
authored
2 years ago
by
Maximilian Reininghaus
Committed by
Nikos Karastathis
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
don't forget parent weight
parent
bdac768d
No related branches found
No related tags found
1 merge request
!466
Resolve "Implement thinning algorithms"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
corsika/detail/modules/thinning/EMThinning.inl
+13
-8
13 additions, 8 deletions
corsika/detail/modules/thinning/EMThinning.inl
with
13 additions
and
8 deletions
corsika/detail/modules/thinning/EMThinning.inl
+
13
−
8
View file @
f6ed04ca
...
@@ -45,33 +45,38 @@ namespace corsika {
...
@@ -45,33 +45,38 @@ namespace corsika {
double
const
p1
=
particle1
.
getEnergy
()
/
Esum
;
double
const
p1
=
particle1
.
getEnergy
()
/
Esum
;
double
const
p2
=
particle2
.
getEnergy
()
/
Esum
;
double
const
p2
=
particle2
.
getEnergy
()
/
Esum
;
// weight factors
double
const
w1
=
parentWeight
/
p1
;
double
const
w1
=
parentWeight
/
p1
;
double
const
w2
=
parentWeight
/
p2
;
double
const
w2
=
parentWeight
/
p2
;
if
(
w1
<=
maxWeight_
&&
w2
<=
maxWeight_
)
{
// apply Hillas thinning
// max. allowed weight factor
if
(
uniform_
(
rng_
)
<=
p1
)
{
// keep 1st with probability p1
double
const
maxWeightFactor
=
maxWeight_
/
parentWeight
;
if
(
w1
<=
maxWeightFactor
&&
w2
<=
maxWeightFactor
)
{
// apply Hillas thinning
if
(
uniform_
(
rng_
)
<=
p1
)
{
// keep 1st with probability p1
particle2
.
setWeight
(
0
);
particle2
.
setWeight
(
0
);
particle1
.
setWeight
(
w1
);
particle1
.
setWeight
(
w1
*
parentWeight
);
}
else
{
// keep 2nd
}
else
{
// keep 2nd
particle1
.
setWeight
(
0
);
particle1
.
setWeight
(
0
);
particle2
.
setWeight
(
w2
);
particle2
.
setWeight
(
w2
*
parentWeight
);
}
}
}
else
{
// weight limitation kicks in, do statistical thinning
}
else
{
// weight limitation kicks in, do statistical thinning
double
const
w1prime
=
std
::
min
(
w1
,
maxWeight
_
);
double
const
w1prime
=
std
::
min
(
w1
,
maxWeight
Factor
);
double
const
w2prime
=
std
::
min
(
w2
,
maxWeight
_
);
double
const
w2prime
=
std
::
min
(
w2
,
maxWeight
Factor
);
if
(
uniform_
(
rng_
)
*
w1prime
<=
parentWeight
)
{
// keep 1st
if
(
uniform_
(
rng_
)
*
w1prime
<=
parentWeight
)
{
// keep 1st
particle1
.
setWeight
(
w1prime
);
particle1
.
setWeight
(
w1prime
*
parentWeight
);
}
else
{
}
else
{
particle1
.
setWeight
(
0
);
particle1
.
setWeight
(
0
);
}
}
if
(
uniform_
(
rng_
)
*
w2prime
<=
parentWeight
)
{
// keep 2nd
if
(
uniform_
(
rng_
)
*
w2prime
<=
parentWeight
)
{
// keep 2nd
particle2
.
setWeight
(
w2prime
);
particle2
.
setWeight
(
w2prime
*
parentWeight
);
}
else
{
}
else
{
particle2
.
setWeight
(
0
);
particle2
.
setWeight
(
0
);
}
}
}
}
// erase discared particles
// TODO: skip this for multithinning
// TODO: skip this for multithinning
for
(
auto
&
p
:
view
)
{
for
(
auto
&
p
:
view
)
{
if
(
auto
const
w
=
p
.
getWeight
();
w
==
0
)
{
p
.
erase
();
}
if
(
auto
const
w
=
p
.
getWeight
();
w
==
0
)
{
p
.
erase
();
}
...
...
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