Histogram complete

This commit is contained in:
darksnake 2017-07-03 12:50:43 +03:00
parent c75458515d
commit 00d885ee57
2 changed files with 32 additions and 5 deletions

View File

@ -1,6 +1,8 @@
package inr.numass.data
import groovy.transform.CompileStatic
import hep.dataforge.maths.histogram.Histogram
import hep.dataforge.maths.histogram.UnivariateHistogram
/**
* Created by darksnake on 27-Jun-17.
@ -24,7 +26,22 @@ class PointAnalyzer {
}
double cr = 1d / (totalT / totalN - t0);
return new Result(cr: cr, crErr: cr / Math.sqrt(totalN), num: totalN, t0: t0, loChannel: loChannel, upChannel: upChannel)
}
static Histogram histogram(RawNMPoint point, int loChannel = 0, int upChannel = 4000) {
List<Double> ts = new ArrayList<>();
NMEvent lastEvent = point.events[0];
for (int i = 1; i < point.events.size(); i++) {
NMEvent event = point.events[i];
double t = event.time - lastEvent.time;
if (t >= 0 && event.chanel <= upChannel && event.chanel >= loChannel) {
ts << t
}
lastEvent = event
}
return UnivariateHistogram.buildUniform(0d, 5e-4, 1e-6).fill(ts.stream().mapToDouble { it })
}
static class Result {

View File

@ -29,8 +29,19 @@ shell.eval {
NumassStorage storage = NumassStorageFactory.buildLocal(rootDir);
def hv = 14000;
def point = storage.provide("loader::set_2/rawPoint::$hv", RawNMPoint.class).get();
def hv = 15000;
def point = storage.provide("loader::set_5/rawPoint::$hv", RawNMPoint.class).get();
def histogram = PointAnalyzer.histogram(point,1000,1300).asTable();
plot.configure("histogram"){
yAxis(type:"log")
}
plot.plot(histogram, ["frame": "histogram","showLine": true, "showSymbol": false, "showErrors": false, "connectionType": "step"]){
adapter("x.value": "x", "y.value": "count")
}
def t0 = (1..150).collect { 5.5e-6 + 2e-7 * it }
@ -42,8 +53,7 @@ shell.eval {
plot.plot(plotPoints, ["name": hv])
plot.plot(title: "dead time", from: 5.5e-6, to: 2e-5) { point.cr * 1d / (1d - 6.55e-6 * point.cr) }
// plot.plot(title: "dead time", from: 5.5e-6, to: 2e-5) { point.cr * 1d / (1d - 6.55e-6 * point.cr) }
storage.close()
}