From 6b269625c948a944f4883e975421db6fc9de9f15 Mon Sep 17 00:00:00 2001 From: darksnake Date: Thu, 30 Jun 2016 13:09:30 +0300 Subject: [PATCH] [no commit message] --- .../src/main/java/inr/numass/utils/EventChainGenerator.java | 1 + .../src/main/java/inr/numass/utils/NMEventGenerator.java | 4 ++-- .../src/main/java/inr/numass/utils/PileUpSimulator.java | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/numass-main/src/main/java/inr/numass/utils/EventChainGenerator.java b/numass-main/src/main/java/inr/numass/utils/EventChainGenerator.java index ab42e046..cf22d621 100644 --- a/numass-main/src/main/java/inr/numass/utils/EventChainGenerator.java +++ b/numass-main/src/main/java/inr/numass/utils/EventChainGenerator.java @@ -21,6 +21,7 @@ import static java.lang.Math.max; import java.util.ArrayList; import java.util.List; import java.util.Map; +import static java.lang.Math.max; /** * Utility class for pile-up simulation diff --git a/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java b/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java index f97bf756..014919bc 100644 --- a/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java +++ b/numass-main/src/main/java/inr/numass/utils/NMEventGenerator.java @@ -122,10 +122,10 @@ public class NMEventGenerator { chanel = 1600; } - return new NMEvent(chanel, prev == null ? 0 : prev.getTime() + nextExp(1 / cr)); + return new NMEvent(chanel, prev == null ? 0 : prev.getTime() + nextExpDecay(1 / cr)); } - public double nextExp(double mean) { + public double nextExpDecay(double mean) { double rand = this.nextUniform(); return -mean * Math.log(1 - rand); } diff --git a/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java b/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java index 4d42d5c9..7ed78e6f 100644 --- a/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java +++ b/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java @@ -118,7 +118,7 @@ public class PileUpSimulator { //flag that shows that previous event was pileup //not counting double pileups if (current != null) { - double delay = (next.getTime() - current.getTime()) / us; + double delay = (next.getTime() - current.getTime()) / us; //time between events in microseconds if (nextEventRegistered(delay)) { //just register new event registred.add(next.clone()); @@ -131,9 +131,10 @@ public class PileUpSimulator { registred.remove(registred.size() - 1); registred.add(newEvent.clone()); pileup.add(newEvent.clone()); - pileupFlag = true; + pileupFlag = true; // up the flag to avoid secondary pileup } else { // second event not registered + pileupFlag = false; } } else { //register first event