From 8811901e6744a04aaa2fde33d6ce47de3bcc17f3 Mon Sep 17 00:00:00 2001 From: darksnake Date: Thu, 30 Mar 2017 16:57:02 +0300 Subject: [PATCH] Plugin resolution --- .../inr/numass/scripts/SimulatePileup.groovy | 32 +++++++++++++------ .../inr/numass/scripts/Underflow.groovy | 2 +- .../src/main/java/inr/numass/Numass.java | 2 +- .../inr/numass/utils/PileUpSimulator.java | 14 ++++---- .../viewer/NumassLoaderViewComponent.java | 2 +- 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy b/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy index 049c97db..3b513752 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy @@ -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 data = NumassDataUtils.joinSpectra( +// StorageUtils.loaderStream(storage) +// .filter { it.key.matches("set_3.") } +// .map { +// println "loading ${it.key}" +// it.value +// } +//) //Simulation process Map> 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 points = res.values().collect { it.find { it.uset == u }.getMapWithBinning(20, false) } +List 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") diff --git a/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy b/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy index 69b60cb7..63f349dc 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/Underflow.groovy @@ -52,7 +52,7 @@ data = NumassDataUtils.substractReferencePoint(data, 18600d); // } //} -def printPoint(Iterable data, List us, int binning = 20, normalize = false) { +def printPoint(Iterable data, List us, int binning = 20, normalize = true) { List points = data.findAll { it.uset in us }.sort { it.uset } Map spectra = points.first().getMapWithBinning(binning, normalize).collectEntries { key, value -> diff --git a/numass-main/src/main/java/inr/numass/Numass.java b/numass-main/src/main/java/inr/numass/Numass.java index 2b1a833e..a886f6d7 100644 --- a/numass-main/src/main/java/inr/numass/Numass.java +++ b/numass-main/src/main/java/inr/numass/Numass.java @@ -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( 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 46c0b369..5e235a07 100644 --- a/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java +++ b/numass-main/src/main/java/inr/numass/utils/PileUpSimulator.java @@ -26,7 +26,7 @@ public class PileUpSimulator { private final RandomGenerator rnd; private final List generated = new ArrayList<>(); private final List pileup = new ArrayList<>(); - private final List registred = new ArrayList<>(); + private final List registered = new ArrayList<>(); private Supplier 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(); } } diff --git a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java b/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java index 08289b51..a44c2bc7 100644 --- a/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java +++ b/numass-viewer/src/main/java/inr/numass/viewer/NumassLoaderViewComponent.java @@ -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) {