Plugin resolution
This commit is contained in:
parent
a768e63831
commit
8811901e67
@ -9,7 +9,6 @@ package inr.numass.scripts
|
||||
import hep.dataforge.grind.Grind
|
||||
import hep.dataforge.tables.DataPoint
|
||||
import inr.numass.storage.NMPoint
|
||||
import inr.numass.storage.NumassData
|
||||
import inr.numass.storage.NumassDataLoader
|
||||
import inr.numass.storage.RawNMPoint
|
||||
import inr.numass.utils.NMEventGeneratorWithPulser
|
||||
@ -20,13 +19,28 @@ import org.apache.commons.math3.random.JDKRandomGenerator
|
||||
|
||||
rnd = new JDKRandomGenerator();
|
||||
|
||||
//Loading data
|
||||
////Loading data
|
||||
File dataDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1\\set_28")
|
||||
//File dataDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_2_wide\\set_7")
|
||||
if (!dataDir.exists()) {
|
||||
println "dataDir directory does not exist"
|
||||
}
|
||||
NumassData data = NumassDataLoader.fromLocalDir(null, dataDir)
|
||||
def data = NumassDataLoader.fromLocalDir(null, dataDir).getNMPoints()
|
||||
|
||||
//File rootDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1")
|
||||
////File rootDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_2_wide")
|
||||
////File rootDir = new File("D:\\Work\\Numass\\data\\2017_01\\Fill_2_wide")
|
||||
//
|
||||
//NumassStorage storage = NumassStorage.buildLocalNumassRoot(rootDir, true);
|
||||
//
|
||||
//Collection<NMPoint> data = NumassDataUtils.joinSpectra(
|
||||
// StorageUtils.loaderStream(storage)
|
||||
// .filter { it.key.matches("set_3.") }
|
||||
// .map {
|
||||
// println "loading ${it.key}"
|
||||
// it.value
|
||||
// }
|
||||
//)
|
||||
|
||||
//Simulation process
|
||||
Map<String, List<NMPoint>> res = [:]
|
||||
@ -80,7 +94,7 @@ double adjustCountRate(PileUpSimulator simulator, NMPoint point) {
|
||||
return (generatedInChannel / registeredInChannel) * (point.getCountInWindow(lowerChannel, upperChannel) / point.getLength());
|
||||
}
|
||||
|
||||
data.NMPoints.forEach { point ->
|
||||
data.forEach { point ->
|
||||
double cr = TritiumUtils.countRateWithDeadTime(point, lowerChannel, upperChannel, 6.55e-6);
|
||||
|
||||
PileUpSimulator simulator = buildSimulator(point, cr);
|
||||
@ -103,7 +117,7 @@ data.NMPoints.forEach { point ->
|
||||
registered.add(simulator.registered());
|
||||
pileup.add(simulator.pileup());
|
||||
}
|
||||
res.put("original", data.NMPoints);
|
||||
res.put("original", data);
|
||||
res.put("generated", generated);
|
||||
res.put("registered", registered);
|
||||
// res.put("firstIteration", new SimulatedPoint("firstIteration", firstIteration));
|
||||
@ -115,7 +129,7 @@ def keys = res.keySet();
|
||||
//print spectra for selected point
|
||||
double u = 16500d;
|
||||
|
||||
List<Map> points = res.values().collect { it.find { it.uset == u }.getMapWithBinning(20, false) }
|
||||
List<Map> points = res.values().collect { it.find { it.uset == u }.getMapWithBinning(20, true) }
|
||||
|
||||
println "\n Spectrum example for U = ${u}\n"
|
||||
|
||||
@ -133,9 +147,9 @@ print keys.collect { it + "[total]" }.join("\t") + "\t"
|
||||
print keys.collect { it + "[pulse]" }.join("\t") + "\t"
|
||||
println keys.join("\t")
|
||||
|
||||
for (int i = 0; i < data.getNMPoints().size(); i++) {
|
||||
print "${data.getNMPoints().get(i).getUset()}\t"
|
||||
print "${data.getNMPoints().get(i).getLength()}\t"
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
print "${data.get(i).getUset()}\t"
|
||||
print "${data.get(i).getLength()}\t"
|
||||
print keys.collect { res[it].get(i).getEventsCount() }.join("\t") + "\t"
|
||||
print keys.collect { res[it].get(i).getCountInWindow(3100, 3800) }.join("\t") + "\t"
|
||||
println keys.collect { res[it].get(i).getCountInWindow(400, 3100) }.join("\t")
|
||||
|
@ -52,7 +52,7 @@ data = NumassDataUtils.substractReferencePoint(data, 18600d);
|
||||
// }
|
||||
//}
|
||||
|
||||
def printPoint(Iterable<NMPoint> data, List us, int binning = 20, normalize = false) {
|
||||
def printPoint(Iterable<NMPoint> data, List us, int binning = 20, normalize = true) {
|
||||
List<NMPoint> points = data.findAll { it.uset in us }.sort { it.uset }
|
||||
|
||||
Map spectra = points.first().getMapWithBinning(binning, normalize).collectEntries { key, value ->
|
||||
|
@ -54,7 +54,7 @@ public class Numass {
|
||||
.ln();
|
||||
|
||||
|
||||
for (ActionDescriptor descriptor : context.getPlugin(ActionManager.class).list()) {
|
||||
for (ActionDescriptor descriptor : context.getFeature(ActionManager.class).list()) {
|
||||
builder
|
||||
.addText("\t")
|
||||
.addContent(
|
||||
|
@ -26,7 +26,7 @@ public class PileUpSimulator {
|
||||
private final RandomGenerator rnd;
|
||||
private final List<NMEvent> generated = new ArrayList<>();
|
||||
private final List<NMEvent> pileup = new ArrayList<>();
|
||||
private final List<NMEvent> registred = new ArrayList<>();
|
||||
private final List<NMEvent> registered = new ArrayList<>();
|
||||
private Supplier<NMEvent> generator;
|
||||
private double uSet = 0;
|
||||
private AtomicInteger doublePileup = new AtomicInteger(0);
|
||||
@ -58,7 +58,7 @@ public class PileUpSimulator {
|
||||
}
|
||||
|
||||
public NMPoint registered() {
|
||||
return new NMPoint(new RawNMPoint(uSet, registred, pointLength));
|
||||
return new NMPoint(new RawNMPoint(uSet, registered, pointLength));
|
||||
}
|
||||
|
||||
public NMPoint pileup() {
|
||||
@ -89,7 +89,7 @@ public class PileUpSimulator {
|
||||
* @return
|
||||
*/
|
||||
private boolean pileup(double delay) {
|
||||
double prob = 1d / (1d + Math.pow(delay / 2.5, 42.96));
|
||||
double prob = 1d / (1d + Math.pow(delay / (2.5 + 0.2), 42.96));
|
||||
return random(prob);
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public class PileUpSimulator {
|
||||
double delay = (next.getTime() - lastRegisteredTime) / us; //time between events in microseconds
|
||||
if (nextEventRegistered(next.getChanel(), delay)) {
|
||||
//just register new event
|
||||
registred.add(next);
|
||||
registered.add(next);
|
||||
lastRegisteredTime = next.getTime();
|
||||
pileupFlag = false;
|
||||
} else if (pileup(delay)) {
|
||||
@ -137,8 +137,8 @@ public class PileUpSimulator {
|
||||
short newChannel = pileupChannel(delay, next.getChanel(), next.getChanel());
|
||||
NMEvent newEvent = new NMEvent(newChannel, next.getTime());
|
||||
//replace already registered event by event with new channel
|
||||
registred.remove(registred.size() - 1);
|
||||
registred.add(newEvent);
|
||||
registered.remove(registered.size() - 1);
|
||||
registered.add(newEvent);
|
||||
pileup.add(newEvent);
|
||||
//do not change DAQ close time
|
||||
pileupFlag = true; // up the flag to avoid secondary pileup
|
||||
@ -149,7 +149,7 @@ public class PileUpSimulator {
|
||||
}
|
||||
} else {
|
||||
//register first event
|
||||
registred.add(next);
|
||||
registered.add(next);
|
||||
lastRegisteredTime = next.getTime();
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
||||
}
|
||||
|
||||
private WorkManager getWorkManager(){
|
||||
return context.getPlugin(WorkManager.class);
|
||||
return context.getFeature(WorkManager.class);
|
||||
}
|
||||
|
||||
public void loadData(NumassData data) {
|
||||
|
Loading…
Reference in New Issue
Block a user