IAP GITLAB

Skip to content
Snippets Groups Projects
Commit d8c2ad4a authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan: Committed by Nikos Karastathis
Browse files

don't forget parent weight

parent 07b5621c
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !466. Comments created here will be created in the context of that merge request.
...@@ -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, maxWeightFactor);
double const w2prime = std::min(w2, maxWeight_); double const w2prime = std::min(w2, maxWeightFactor);
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(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment