diff --git a/numass-main/src/main/groovy/inr/numass/scripts/CountRateSummary.groovy b/numass-main/src/main/groovy/inr/numass/scripts/CountRateSummary.groovy index a5f756bd..c6c5df40 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/CountRateSummary.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/CountRateSummary.groovy @@ -14,7 +14,7 @@ import java.nio.file.Paths Workspace numass = FileBasedWorkspace.build(Paths.get("D:/Work/Numass/sterile2016_10/workspace.groovy")) -numass.runTask("prepare", "fill_1_all").forEachDataWithType(Table) { +numass.runTask("prepare", "fill_1_all").forEachData(Table) { Table table = it.get(); def dp18 = table.find { it["Uset"] == 18000 } def dp17 = table.find { it["Uset"] == 17000 } diff --git a/numass-main/src/main/groovy/inr/numass/scripts/times/Histogram.groovy b/numass-main/src/main/groovy/inr/numass/scripts/times/Histogram.groovy new file mode 100644 index 00000000..6b544009 --- /dev/null +++ b/numass-main/src/main/groovy/inr/numass/scripts/times/Histogram.groovy @@ -0,0 +1,38 @@ +package inr.numass.scripts.times + +import hep.dataforge.context.Context +import hep.dataforge.context.Global +import hep.dataforge.grind.GrindShell +import hep.dataforge.io.ColumnedDataWriter +import hep.dataforge.maths.histogram.SimpleHistogram +import hep.dataforge.meta.Meta +import hep.dataforge.plots.fx.FXPlotManager +import inr.numass.NumassPlugin +import inr.numass.data.analyzers.TimeAnalyzer +import inr.numass.data.api.NumassSet +import inr.numass.data.storage.NumassStorage +import inr.numass.data.storage.NumassStorageFactory + +Context ctx = Global.instance() +ctx.pluginManager().load(FXPlotManager) +ctx.pluginManager().load(NumassPlugin) + +new GrindShell(ctx).eval { + File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_2") + + NumassStorage storage = NumassStorageFactory.buildLocal(rootDir); + + def set = "set_3" + def hv = 14000 + def loader = storage.provide("loader::$set", NumassSet.class).get(); + def point = loader.optPoint(hv).get() + + def table = new SimpleHistogram([0d, 0d] as Double[], [2d, 100d] as Double[]) + .fill(new TimeAnalyzer().getEventsWithDelay(point, Meta.empty()).map { + [it.value / 1000, it.key.chanel] as Double[] + }).asTable() + + ColumnedDataWriter.writeTable(System.out, table, "hist") + + storage.close() +} \ No newline at end of file diff --git a/numass-main/src/main/groovy/inr/numass/scripts/times/TestPointAnalyzer.groovy b/numass-main/src/main/groovy/inr/numass/scripts/times/TestPointAnalyzer.groovy index 7445d44c..5515301a 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/times/TestPointAnalyzer.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/times/TestPointAnalyzer.groovy @@ -2,13 +2,14 @@ package inr.numass.scripts.times import hep.dataforge.context.Context import hep.dataforge.context.Global +import hep.dataforge.data.DataSet +import hep.dataforge.grind.Grind import hep.dataforge.grind.GrindShell -import hep.dataforge.grind.helpers.PlotHelper +import hep.dataforge.meta.Meta import hep.dataforge.plots.fx.FXPlotManager -import hep.dataforge.tables.ValueMap +import hep.dataforge.storage.commons.StorageUtils import inr.numass.NumassPlugin -import inr.numass.data.PointAnalyzer -import inr.numass.data.api.NumassAnalyzer +import inr.numass.actions.TimeAnalyzedAction import inr.numass.data.api.NumassPoint import inr.numass.data.api.NumassSet import inr.numass.data.storage.NumassStorage @@ -24,55 +25,36 @@ ctx.pluginManager().load(FXPlotManager) ctx.pluginManager().load(NumassPlugin.class) new GrindShell(ctx).eval { - PlotHelper plot = plots - File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_3") + File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_2") NumassStorage storage = NumassStorageFactory.buildLocal(rootDir); + Meta meta = Grind.buildMeta(binNum: 200) { + window(lo: 500, up: 1800) + } + +// def set = "set_43" +// def loader = storage.provide("loader::$set", NumassSet.class).get(); +// def data = NumassUtils.pointsToNode(loader).filter { name, data -> +// return data.meta().getDouble("voltage",0) < 15000 +// }; + - def set = "set_43" def hv = 14000; - def loader = storage.provide("loader::$set", NumassSet.class).get(); - def point = loader.provide("$hv", NumassPoint.class).get() + def dataBuilder = DataSet.builder(NumassPoint) - def loChannel = 450; - def upChannel = 3100; - - def histogram = PointAnalyzer.histogram(point, loChannel, upChannel, 1, 500).asTable(); - - println "finished histogram calculation..." - - plot.configure("histogram") { - xAxis(axisTitle: "delay", axisUnits: "us") - yAxis(type: "log") + StorageUtils.loaderStream(storage, false) + .filter { it.value instanceof NumassSet } + .forEach { pair -> + (pair.value as NumassSet).optPoint(hv).ifPresent { + dataBuilder.putData(pair.key, it, it.meta); + } } + def data = dataBuilder.build() - plot.plot(name: "test", frame: "histogram", showLine: true, showSymbol: false, showErrors: false, connectionType: "step", histogram, { - adapter("x.value": "x", "y.value": "count") - }) - - def trueCR = PointAnalyzer.analyze(point, t0: 30e3, "window.lo": loChannel, "window.up": upChannel).getDouble("cr") - - println "The expected count rate for 30 us delay is $trueCR" - - def t0 = (1..150).collect { 500 * it } - - def statPlotPoints = t0.collect { - def result = PointAnalyzer.analyze(point, t0: it, "window.lo": loChannel, "window.up": upChannel) - ValueMap.ofMap("x": it / 1000, "y": result.getDouble("cr"), "y.err": result.getDouble(NumassAnalyzer.COUNT_RATE_ERROR_KEY)); - } - plot.plot(name: "total", frame: "stat-method", showLine: true, statPlotPoints) - -// def delta = 5e-6 -// def discrepancyPlotPoints = (1..20).collect { delta * it }.collect { -// def t1 = it -// def t2 = it + delta -// def result = PointAnalyzer.count(point, t1, t2, loChannel, upChannel) - (Math.exp(-trueCR * t1) - Math.exp(-trueCR * t2)) * point.length * trueCR -// ValueMap.ofMap("x.value": it + delta / 2, "y.value": result); -// } -// -// plot.plot(name: hv, frame: "discrepancy", discrepancyPlotPoints) + def result = new TimeAnalyzedAction().run(ctx, data, meta); + result.computeAll(); storage.close() } \ No newline at end of file diff --git a/numass-main/src/main/groovy/inr/numass/scripts/times/TestProto.groovy b/numass-main/src/main/groovy/inr/numass/scripts/times/TestProto.groovy index 79a82d51..90148f45 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/times/TestProto.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/times/TestProto.groovy @@ -44,7 +44,7 @@ new GrindShell(ctx).eval { println "The expected count rate for 30 us delay is $trueCR" - def t0 = (1..150).collect { 1000 * it } + def t0 = (1..150).collect { 420 * it } def statPlotPoints = t0.collect { diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java index 67936fad..02315ea8 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java @@ -49,7 +49,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask