[no commit message]
This commit is contained in:
parent
690254d0be
commit
bbefa9d990
@ -23,40 +23,40 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Utility class for pile-up simulation
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public final class EventChainGenerator {
|
public final class EventChainGenerator {
|
||||||
|
|
||||||
private final static double us = 1e-6;
|
private final static double us = 1e-6;//microsecond
|
||||||
|
|
||||||
private double blockStartTime = 0;
|
private double blockStartTime = 0;
|
||||||
|
|
||||||
private final List<NMEvent> generatedChain = new ArrayList<>();
|
private final List<NMEvent> generatedChain = new ArrayList<>();
|
||||||
private final EventGenerator generator;
|
private final NMEventGenerator generator;
|
||||||
private final double length;
|
private final double length;
|
||||||
private final List<NMEvent> pileupChain = new ArrayList<>();
|
private final List<NMEvent> pileupChain = new ArrayList<>();
|
||||||
|
|
||||||
private final List<NMEvent> registredChain = new ArrayList<>();
|
private final List<NMEvent> registredChain = new ArrayList<>();
|
||||||
|
|
||||||
public EventChainGenerator(double cr, double length) {
|
public EventChainGenerator(double cr, double length) {
|
||||||
generator = new EventGenerator(cr);
|
generator = new NMEventGenerator(cr);
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventChainGenerator(double cr, double length, RawNMPoint source, int minChanel, int maxChanel) {
|
public EventChainGenerator(double cr, double length, RawNMPoint source, int minChanel, int maxChanel) {
|
||||||
generator = new EventGenerator(cr);
|
generator = new NMEventGenerator(cr);
|
||||||
this.generator.loadFromPoint(source, minChanel, maxChanel);
|
this.generator.loadSpectrum(source, minChanel, maxChanel);
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventChainGenerator(double cr, double length, Map<Double,Double> spectrum, int minChanel, int maxChanel) {
|
public EventChainGenerator(double cr, double length, Map<Double,Double> spectrum, int minChanel, int maxChanel) {
|
||||||
generator = new EventGenerator(cr);
|
generator = new NMEventGenerator(cr);
|
||||||
this.generator.loadFromSpectrum(spectrum, minChanel, maxChanel);
|
this.generator.loadSpectrum(spectrum, minChanel, maxChanel);
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package inr.numass.generators;
|
package inr.numass.generators;
|
||||||
|
|
||||||
import inr.numass.storage.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
|
import inr.numass.storage.NMPoint;
|
||||||
import inr.numass.storage.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -26,12 +27,12 @@ import org.apache.commons.math3.random.EmpiricalDistribution;
|
|||||||
import org.apache.commons.math3.random.JDKRandomGenerator;
|
import org.apache.commons.math3.random.JDKRandomGenerator;
|
||||||
import org.apache.commons.math3.random.RandomGenerator;
|
import org.apache.commons.math3.random.RandomGenerator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A generator for Numass events with given energy spectrum
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class EventGenerator {
|
public class NMEventGenerator {
|
||||||
|
|
||||||
double cr;
|
double cr;
|
||||||
// UnivariateFunction signalShape;
|
// UnivariateFunction signalShape;
|
||||||
@ -39,18 +40,16 @@ public class EventGenerator {
|
|||||||
|
|
||||||
private final RandomGenerator generator;
|
private final RandomGenerator generator;
|
||||||
|
|
||||||
public EventGenerator(double cr) {
|
public NMEventGenerator(double cr) {
|
||||||
this.cr = cr;
|
this.cr = cr;
|
||||||
generator = new JDKRandomGenerator();
|
generator = new JDKRandomGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromPoint(RawNMPoint point,int minChanel, int maxChanel){
|
public void loadSpectrum(RawNMPoint point, int minChanel, int maxChanel) {
|
||||||
List<Short> shorts = new ArrayList<>();
|
List<Short> shorts = new ArrayList<>();
|
||||||
for (NMEvent event : point.getEvents()) {
|
point.getEvents().stream()
|
||||||
if((event.getChanel()>minChanel)&&(event.getChanel()<maxChanel)) {
|
.filter((event) -> ((event.getChanel() > minChanel) && (event.getChanel() < maxChanel)))
|
||||||
shorts.add(event.getChanel());
|
.forEach((event) -> shorts.add(event.getChanel()));
|
||||||
}
|
|
||||||
}
|
|
||||||
double[] doubles = new double[shorts.size()];
|
double[] doubles = new double[shorts.size()];
|
||||||
|
|
||||||
for (int i = 0; i < shorts.size(); i++) {
|
for (int i = 0; i < shorts.size(); i++) {
|
||||||
@ -63,7 +62,7 @@ public class EventGenerator {
|
|||||||
distribution = d;
|
distribution = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromSpectrum(Map<Double,Double> spectrum, int minChanel, int maxChanel){
|
public void loadSpectrum(Map<Double, Double> spectrum, int minChanel, int maxChanel) {
|
||||||
assert minChanel > 0;
|
assert minChanel > 0;
|
||||||
assert maxChanel < RawNMPoint.MAX_CHANEL;
|
assert maxChanel < RawNMPoint.MAX_CHANEL;
|
||||||
|
|
||||||
@ -78,14 +77,28 @@ public class EventGenerator {
|
|||||||
distribution = new EnumeratedRealDistribution(chanels, values);
|
distribution = new EnumeratedRealDistribution(chanels, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NMEvent nextEvent(NMEvent prev) {
|
public void loadSpectrum(NMPoint point, int minChanel, int maxChanel) {
|
||||||
//пока без канала
|
assert minChanel > 0;
|
||||||
short chanel = 1600;
|
assert maxChanel < RawNMPoint.MAX_CHANEL;
|
||||||
|
|
||||||
if(distribution!=null){
|
double[] chanels = new double[RawNMPoint.MAX_CHANEL];
|
||||||
chanel = (short) distribution.sample();
|
double[] values = new double[RawNMPoint.MAX_CHANEL];
|
||||||
|
for (int i = 0; i < RawNMPoint.MAX_CHANEL; i++) {
|
||||||
|
chanels[i] = i;
|
||||||
|
values[i] = point.getCountInChanel(i);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
distribution = new EnumeratedRealDistribution(chanels, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NMEvent nextEvent(NMEvent prev) {
|
||||||
|
short chanel;
|
||||||
|
|
||||||
|
if (distribution != null) {
|
||||||
|
chanel = (short) distribution.sample();
|
||||||
|
} else {
|
||||||
|
chanel = 1600;
|
||||||
|
}
|
||||||
|
|
||||||
return new NMEvent(chanel, prev.getTime() + nextExp(1 / cr));
|
return new NMEvent(chanel, prev.getTime() + nextExp(1 / cr));
|
||||||
}
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package inr.numass.utils;
|
||||||
|
|
||||||
|
import inr.numass.generators.NMEventGenerator;
|
||||||
|
import inr.numass.storage.NMEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexander Nozik <altavir@gmail.com>
|
||||||
|
*/
|
||||||
|
public class PileUpSimulator {
|
||||||
|
|
||||||
|
private NMEventGenerator generator;
|
||||||
|
private final List<NMEvent> generated = new ArrayList<>();
|
||||||
|
private final List<NMEvent> pileup = new ArrayList<>();
|
||||||
|
private final List<NMEvent> registred = new ArrayList<>();
|
||||||
|
|
||||||
|
private Function<Double, Double> firstEventSurvivalProb;
|
||||||
|
private Function<Double, Double> secondEventSurvivalProb;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user