Numass statistical count rate
This commit is contained in:
parent
36db0c3811
commit
c08e52a398
@ -1,5 +1,5 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.2-5'
|
||||
ext.kotlin_version = '1.1.3'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -29,7 +29,7 @@ dependencies {
|
||||
|
||||
//graphics
|
||||
compile 'org.controlsfx:controlsfx:8.40.12'
|
||||
compile "no.tornado:tornadofx:1.7.5"
|
||||
compile "no.tornado:tornadofx:1.7.8"
|
||||
}
|
||||
|
||||
task installAll(type: Copy) {
|
||||
|
@ -65,13 +65,13 @@ class PKT8ViewConnection : DeviceViewConnection<PKT8Device>(), MeasurementListen
|
||||
private var plotButton: ToggleButton by singleAssign()
|
||||
private var logButton: ToggleButton by singleAssign()
|
||||
|
||||
private val logWindow = FragmentWindow(LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
})
|
||||
// private val logWindow = FragmentWindow(LogFragment().apply {
|
||||
// addLogHandler(device.logger)
|
||||
// })
|
||||
|
||||
// need those to have strong references to listeners
|
||||
private val plotView = CryoPlotView();
|
||||
private val plotWindow = FragmentWindow(FXFragment.buildFromNode(plotView.title) { plotView.root })
|
||||
// private val plotWindow = FragmentWindow(FXFragment.buildFromNode(plotView.title) { plotView.root })
|
||||
|
||||
override val root = borderpane {
|
||||
top {
|
||||
@ -92,12 +92,16 @@ class PKT8ViewConnection : DeviceViewConnection<PKT8Device>(), MeasurementListen
|
||||
|
||||
plotButton = togglebutton("Plot") {
|
||||
isSelected = false
|
||||
plotWindow.bindTo(this)
|
||||
FragmentWindow.build(this) { FXFragment.buildFromNode(plotView.title) { plotView.root } }
|
||||
}
|
||||
|
||||
logButton = togglebutton("Log") {
|
||||
isSelected = false
|
||||
logWindow.bindTo(this)
|
||||
FragmentWindow.build(this) {
|
||||
LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ class MspViewConnection() : DeviceViewConnection<MspDevice>(), DeviceListener, N
|
||||
}
|
||||
}
|
||||
|
||||
private val logWindow = FragmentWindow(LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
})
|
||||
// private val logWindow = FragmentWindow(LogFragment().apply {
|
||||
// addLogHandler(device.logger)
|
||||
// })
|
||||
|
||||
val filamentProperty = SimpleObjectProperty<Int>(this, "filament", 1).apply {
|
||||
addListener { _, oldValue, newValue ->
|
||||
@ -173,7 +173,9 @@ class MspViewConnection() : DeviceViewConnection<MspDevice>(), DeviceListener, N
|
||||
|
||||
togglebutton("Log") {
|
||||
isSelected = false
|
||||
logWindow.bindTo(this)
|
||||
FragmentWindow.build(this){LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ abstract class DeviceViewConnection<D : Device> : Component(), Connection, Devic
|
||||
}
|
||||
togglebutton("View") {
|
||||
isSelected = false
|
||||
FragmentWindow(FXFragment.buildFromNode(device.name) { fxNode }).bindTo(this)
|
||||
FragmentWindow.build(this){FXFragment.buildFromNode(device.name) { fxNode }}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ class VacCollectorViewConnection : DeviceViewConnection<VacCollectorDevice>() {
|
||||
setValue("thickness", 3)
|
||||
}
|
||||
|
||||
private val logWindow = FragmentWindow(LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
})
|
||||
// private val logWindow = FragmentWindow(LogFragment().apply {
|
||||
// addLogHandler(device.logger)
|
||||
// })
|
||||
|
||||
override val root = borderpane {
|
||||
top {
|
||||
@ -89,7 +89,9 @@ class VacCollectorViewConnection : DeviceViewConnection<VacCollectorDevice>() {
|
||||
separator(Orientation.VERTICAL)
|
||||
togglebutton("Log") {
|
||||
isSelected = false
|
||||
logWindow.bindTo(this)
|
||||
FragmentWindow.build(this){LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,35 +23,37 @@ import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darksnake, based on program by S.V.Zadorozhny, 1996
|
||||
*/
|
||||
public class NumassDataReader {
|
||||
public class LegacyDataReader {
|
||||
|
||||
private final InputStream stream;
|
||||
private String name;
|
||||
private double HVdev = 2.468555393226049;
|
||||
private boolean noUset = false;
|
||||
|
||||
public NumassDataReader(Binary file, Meta config) throws IOException {
|
||||
public LegacyDataReader(Binary file, Meta config) throws IOException {
|
||||
this(file.getStream(), config.getString(FileDataFactory.FILE_NAME_KEY), config);
|
||||
}
|
||||
|
||||
public NumassDataReader(File file) throws IOException {
|
||||
public LegacyDataReader(File file) throws IOException {
|
||||
this(new FileInputStream(file), file.getName(), Meta.empty());
|
||||
}
|
||||
|
||||
public NumassDataReader(String file, String fname, Meta config) throws FileNotFoundException {
|
||||
public LegacyDataReader(String file, String fname, Meta config) throws FileNotFoundException {
|
||||
this(new FileInputStream(file), fname, config);
|
||||
if ((fname == null) || (fname.isEmpty())) {
|
||||
name = file;
|
||||
}
|
||||
}
|
||||
|
||||
public NumassDataReader(InputStream is, String fname, Meta config) {
|
||||
public LegacyDataReader(InputStream is, String fname, Meta config) {
|
||||
this.stream = new BufferedInputStream(is);
|
||||
this.name = fname;
|
||||
HVdev = config.getDouble("HVdev", 2.468555393226049);
|
||||
@ -204,12 +206,14 @@ public class NumassDataReader {
|
||||
}
|
||||
|
||||
lab = readByte();
|
||||
|
||||
List<NMEvent> events = new ArrayList<>();
|
||||
while (lab == 0xBF) {
|
||||
skip(4);//badHV
|
||||
lab = readByte();
|
||||
}
|
||||
do {
|
||||
point.putEvent(readEvent(lab, timeDiv));
|
||||
events.add(readEvent(lab, timeDiv));
|
||||
lab = readByte();
|
||||
} while (lab != 0xAF);
|
||||
|
||||
@ -226,7 +230,6 @@ public class NumassDataReader {
|
||||
absoluteTime = absoluteTime.plusDays(1);
|
||||
}
|
||||
|
||||
point.setStartTime(absoluteTime.toInstant(ZoneOffset.UTC));
|
||||
|
||||
rx = readBlock(4);
|
||||
int Uread = rx[2] + 256 * rx[3];
|
||||
@ -234,15 +237,14 @@ public class NumassDataReader {
|
||||
|
||||
skip(21);
|
||||
|
||||
point.setLength(time_out);
|
||||
point.setUread(Uread / 10d / HVdev);
|
||||
double uset;
|
||||
if (noUset) {
|
||||
point.setUset(Uread / 10d / HVdev);
|
||||
uset = Uread / 10d / HVdev;
|
||||
} else {
|
||||
point.setUset(voltage / 10d);
|
||||
uset = voltage / 10d;
|
||||
}
|
||||
|
||||
return point;
|
||||
return new RawNMPoint(uset, Uread / 10d / HVdev, events, time_out, absoluteTime.toInstant(ZoneOffset.UTC));
|
||||
}
|
||||
|
||||
private long readTime() throws IOException {
|
@ -47,11 +47,11 @@ public class NMFile extends NamedMetaHolder implements NumassData {
|
||||
}
|
||||
|
||||
public static NMFile readStream(InputStream is, String fname, Meta config) throws IOException {
|
||||
return new NMFile(new NumassDataReader(is, fname, config).read());
|
||||
return new NMFile(new LegacyDataReader(is, fname, config).read());
|
||||
}
|
||||
|
||||
public static NMFile readFile(File file) throws IOException {
|
||||
return new NMFile(new NumassDataReader(file).read());
|
||||
return new NMFile(new LegacyDataReader(file).read());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.Metoid;
|
||||
import hep.dataforge.names.Named;
|
||||
import hep.dataforge.tables.Table;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Iterator;
|
||||
@ -29,6 +30,7 @@ public interface NumassData extends Named, Metoid, Iterable<NumassPoint> {
|
||||
|
||||
Stream<NumassPoint> stream();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
default Iterator<NumassPoint> iterator() {
|
||||
return stream().iterator();
|
||||
|
@ -45,7 +45,7 @@ public class NumassDataUtils {
|
||||
}
|
||||
int[] newArray = new int[first.getSpectrum().length];
|
||||
Arrays.setAll(newArray, i -> first.getSpectrum()[i] + second.getSpectrum()[i]);
|
||||
return new NMPoint(
|
||||
return new NumassPointImpl(
|
||||
first.getVoltage(),
|
||||
Instant.EPOCH,
|
||||
first.getLength() + second.getLength(),
|
||||
@ -56,7 +56,7 @@ public class NumassDataUtils {
|
||||
public static NumassPoint substractPoint(NumassPoint point, NumassPoint reference) {
|
||||
int[] array = new int[point.getSpectrum().length];
|
||||
Arrays.setAll(array, i -> Math.max(0, point.getSpectrum()[i] - reference.getSpectrum()[i]));
|
||||
return new NMPoint(
|
||||
return new NumassPointImpl(
|
||||
point.getVoltage(),
|
||||
point.getStartTime(),
|
||||
point.getLength(),
|
||||
|
@ -26,7 +26,7 @@ import java.util.stream.IntStream;
|
||||
/**
|
||||
* @author Darksnake
|
||||
*/
|
||||
public class NMPoint implements NumassPoint {
|
||||
public class NumassPointImpl implements NumassPoint {
|
||||
//TODO andThen to annotated and move some parameters to meta
|
||||
private final int[] spectrum;
|
||||
private Instant startTime;
|
||||
@ -34,7 +34,7 @@ public class NMPoint implements NumassPoint {
|
||||
private double pointLength;
|
||||
private double u;
|
||||
|
||||
public NMPoint(double u, Instant startTime, double pointLength, int[] spectrum) {
|
||||
public NumassPointImpl(double u, Instant startTime, double pointLength, int[] spectrum) {
|
||||
this.startTime = startTime;
|
||||
this.pointLength = pointLength;
|
||||
this.spectrum = spectrum;
|
@ -27,7 +27,7 @@ public class PointBuilders {
|
||||
)),0
|
||||
);
|
||||
|
||||
return new NMPoint(u, startTime, pointLength, spectrum);
|
||||
return new NumassPointImpl(u, startTime, pointLength, spectrum);
|
||||
}
|
||||
|
||||
private static int[] calculateSpectrum(RawNMPoint point) {
|
||||
@ -37,7 +37,7 @@ public class PointBuilders {
|
||||
|
||||
@NotNull
|
||||
public static NumassPoint readRawPoint(@NotNull RawNMPoint point) {
|
||||
return new NMPoint(point.getUset(), point.getStartTime(), point.getLength(), calculateSpectrum(point));
|
||||
return new NumassPointImpl(point.getUset(), point.getStartTime(), point.getLength(), calculateSpectrum(point));
|
||||
}
|
||||
|
||||
private static int[] count(IntStream stream, int maxChannel) {
|
||||
|
@ -82,7 +82,7 @@ public class RawNMFile extends NamedMetaHolder {
|
||||
for (RawNMPoint point : points) {
|
||||
if (point.getUset() == U) {
|
||||
if (res == null) {
|
||||
res = point.clone();
|
||||
res = point;
|
||||
} else {
|
||||
res = res.merge(point);
|
||||
}
|
||||
@ -104,7 +104,7 @@ public class RawNMFile extends NamedMetaHolder {
|
||||
for (RawNMPoint point : points) {
|
||||
if (point.getUread() == U) {
|
||||
if (res == null) {
|
||||
res = point.clone();
|
||||
res = point;
|
||||
} else {
|
||||
res = res.merge(point);
|
||||
}
|
||||
@ -120,17 +120,17 @@ public class RawNMFile extends NamedMetaHolder {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void putEvent(double U, short chanel, double time) {
|
||||
for (RawNMPoint point : this.getData()) {
|
||||
if (U == point.getUread()) {
|
||||
point.putEvent(new NMEvent(chanel, time));
|
||||
return;
|
||||
}
|
||||
}
|
||||
RawNMPoint newpoint = new RawNMPoint();
|
||||
newpoint.putEvent(new NMEvent(chanel, time));
|
||||
this.putPoint(newpoint);
|
||||
}
|
||||
// public void putEvent(double U, short chanel, double time) {
|
||||
// for (RawNMPoint point : this.getData()) {
|
||||
// if (U == point.getUread()) {
|
||||
// point.putEvent(new NMEvent(chanel, time));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// RawNMPoint newpoint = new RawNMPoint();
|
||||
// newpoint.putEvent(new NMEvent(chanel, time));
|
||||
// this.putPoint(newpoint);
|
||||
// }
|
||||
|
||||
public void putPoint(RawNMPoint point) {
|
||||
points.add(point);
|
||||
|
@ -21,14 +21,14 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Хранит информацию о спектре точки, но не об отдельных событиях.
|
||||
*
|
||||
*
|
||||
* @author Darksnake
|
||||
*/
|
||||
public class RawNMPoint implements Cloneable {
|
||||
public class RawNMPoint {
|
||||
|
||||
public static final int MAX_EVENTS_PER_POINT = 260000;
|
||||
public static int MAX_CHANEL = 4095;
|
||||
|
||||
|
||||
private Instant startTime;
|
||||
private final List<NMEvent> events;
|
||||
private double length;
|
||||
@ -65,24 +65,22 @@ public class RawNMPoint implements Cloneable {
|
||||
length = Double.NaN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RawNMPoint clone() {
|
||||
ArrayList<NMEvent> newevents = new ArrayList<>();
|
||||
for (NMEvent event : this.getEvents()) {
|
||||
newevents.add(event);
|
||||
}
|
||||
return new RawNMPoint(getUset(), getUread(), newevents, getLength());
|
||||
}
|
||||
// @Override
|
||||
// public RawNMPoint clone() {
|
||||
// ArrayList<NMEvent> newevents = new ArrayList<>();
|
||||
// newevents.addAll(this.getEvents());
|
||||
// return new RawNMPoint(getUset(), getUread(), newevents, getLength());
|
||||
// }
|
||||
|
||||
public Instant getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public double getCR() {
|
||||
public double getCr() {
|
||||
return getEventsCount() / getLength();
|
||||
}
|
||||
|
||||
public double getCRError() {
|
||||
public double getCrError() {
|
||||
return Math.sqrt(getEventsCount()) / getLength();
|
||||
}
|
||||
|
||||
@ -99,6 +97,7 @@ public class RawNMPoint implements Cloneable {
|
||||
|
||||
/**
|
||||
* Measurement time
|
||||
*
|
||||
* @return the tset
|
||||
*/
|
||||
public double getLength() {
|
||||
@ -131,18 +130,18 @@ public class RawNMPoint implements Cloneable {
|
||||
}
|
||||
|
||||
public RawNMPoint merge(RawNMPoint point) {
|
||||
RawNMPoint res = this.clone();
|
||||
List<NMEvent> events = new ArrayList<>(this.events);
|
||||
for (NMEvent newEvent : point.getEvents()) {
|
||||
res.putEvent(new NMEvent(newEvent.getChanel(), newEvent.getTime() + this.getLength()));
|
||||
events.add(new NMEvent(newEvent.getChanel(), newEvent.getTime() + this.getLength()));
|
||||
}
|
||||
res.length += point.getLength();
|
||||
res.uread = (this.uread + point.uread) / 2;
|
||||
return res;
|
||||
double length = this.length + point.length;
|
||||
double uread = (this.uread + point.uread) / 2;
|
||||
return new RawNMPoint(this.uset, uread, events, length, this.startTime);
|
||||
}
|
||||
|
||||
void putEvent(NMEvent event) {
|
||||
events.add(event);
|
||||
}
|
||||
// void putEvent(NMEvent event) {
|
||||
// events.add(event);
|
||||
// }
|
||||
|
||||
public RawNMPoint selectChanels(int from, int to) {
|
||||
assert to > from;
|
||||
@ -156,30 +155,30 @@ public class RawNMPoint implements Cloneable {
|
||||
return new RawNMPoint(getUset(), getUread(), res, getLength());
|
||||
}
|
||||
|
||||
void setStartTime(Instant absouteTime) {
|
||||
this.startTime = absouteTime;
|
||||
}
|
||||
// void setStartTime(Instant absouteTime) {
|
||||
// this.startTime = absouteTime;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param tset the tset to set
|
||||
// */
|
||||
// void setLength(double tset) {
|
||||
// this.length = tset;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param tset the tset to set
|
||||
*/
|
||||
void setLength(double tset) {
|
||||
this.length = tset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Uread the Uread to set
|
||||
*/
|
||||
void setUread(double Uread) {
|
||||
assert Uread >= 0;
|
||||
this.uread = Uread;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Uset the Uset to set
|
||||
*/
|
||||
void setUset(double Uset) {
|
||||
this.uset = Uset;
|
||||
}
|
||||
// /**
|
||||
// * @param Uread the Uread to set
|
||||
// */
|
||||
// void setUread(double Uread) {
|
||||
// assert Uread >= 0;
|
||||
// this.uread = Uread;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param Uset the Uset to set
|
||||
// */
|
||||
// void setUset(double Uset) {
|
||||
// this.uset = Uset;
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ import hep.dataforge.io.ColumnedDataReader;
|
||||
import hep.dataforge.io.envelopes.Envelope;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
import hep.dataforge.providers.Provider;
|
||||
import hep.dataforge.providers.Provides;
|
||||
import hep.dataforge.providers.ProvidesNames;
|
||||
import hep.dataforge.storage.api.ObjectLoader;
|
||||
import hep.dataforge.storage.api.Storage;
|
||||
import hep.dataforge.storage.filestorage.FileEnvelope;
|
||||
@ -49,13 +52,11 @@ import java.util.stream.Stream;
|
||||
*
|
||||
* @author darksnake
|
||||
*/
|
||||
public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Envelope>, NumassData {
|
||||
public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Envelope>, NumassData, Provider {
|
||||
|
||||
|
||||
public static NumassDataLoader fromFile(Storage storage, Path zipFile) throws IOException {
|
||||
throw new UnsupportedOperationException("TODO");
|
||||
// FileObject zipRoot = VFS.getManager().createFileSystem(zipFile);
|
||||
// return fromDir(storage, zipRoot, zipFile.getName().getBaseName());
|
||||
}
|
||||
|
||||
|
||||
@ -101,19 +102,6 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
||||
return new NumassDataLoader(storage, name, annotation, items);
|
||||
}
|
||||
|
||||
|
||||
// private static Envelope readFile(Path file) {
|
||||
// String fileName = file.getFileName().toString();
|
||||
// if (fileName.equals(META_FRAGMENT_NAME)
|
||||
// || fileName.equals(HV_FRAGMENT_NAME)
|
||||
// || fileName.startsWith(POINT_FRAGMENT_NAME)) {
|
||||
// return FileEnvelope.open(file, true);
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// //}
|
||||
// }
|
||||
|
||||
/**
|
||||
* "start_time": "2016-04-20T04:08:50",
|
||||
*
|
||||
@ -226,7 +214,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
||||
* @param envelope
|
||||
* @return
|
||||
*/
|
||||
public NumassPoint readPoint(Envelope envelope) {
|
||||
private NumassPoint readPoint(Envelope envelope) {
|
||||
return readPoint(envelope, PointBuilders::readRawPoint);
|
||||
}
|
||||
|
||||
@ -347,6 +335,26 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String defaultTarget() {
|
||||
return "nmPoint";
|
||||
}
|
||||
|
||||
@Provides("nmPoint")
|
||||
public Optional<NumassPoint> optPoint(String u) {
|
||||
return stream().filter(it -> it.getVoltage() == Double.parseDouble(u)).findFirst();
|
||||
}
|
||||
|
||||
@ProvidesNames("nmPoint")
|
||||
public Stream<String> listHV() {
|
||||
return stream().map(it -> Double.toString(it.getVoltage()));
|
||||
}
|
||||
|
||||
@Provides("rawPoint")
|
||||
public Optional<RawNMPoint> optRawPoint(String u) {
|
||||
return this.getPoints().map(this::readRawPoint).filter(it -> it.getUset() == Double.parseDouble(u)).findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return new NumassData using given transformation for each point
|
||||
*
|
||||
|
@ -0,0 +1,38 @@
|
||||
package inr.numass.data
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
/**
|
||||
* Created by darksnake on 27-Jun-17.
|
||||
*/
|
||||
@CompileStatic
|
||||
class PointAnalyzer {
|
||||
|
||||
static Result analyzePoint(RawNMPoint point, double t0 = 0, int loChannel = 0, int upChannel = 4000) {
|
||||
int totalN = 0
|
||||
double totalT = 0;
|
||||
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 >= t0 && event.chanel <= upChannel && event.chanel >= loChannel) {
|
||||
totalN++
|
||||
totalT += t
|
||||
}
|
||||
lastEvent = event
|
||||
}
|
||||
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 class Result {
|
||||
double cr;
|
||||
double crErr;
|
||||
long num;
|
||||
double t0;
|
||||
int loChannel;
|
||||
int upChannel;
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ package inr.numass.scripts
|
||||
|
||||
import hep.dataforge.grind.Grind
|
||||
import hep.dataforge.tables.DataPoint
|
||||
import inr.numass.data.NMPoint
|
||||
import inr.numass.data.NumassPointImpl
|
||||
import inr.numass.data.RawNMPoint
|
||||
import inr.numass.storage.NumassDataLoader
|
||||
import inr.numass.utils.NMEventGeneratorWithPulser
|
||||
@ -43,18 +43,18 @@ def data = NumassDataLoader.fromLocalDir(null, dataDir).getNMPoints()
|
||||
//)
|
||||
|
||||
//Simulation process
|
||||
Map<String, List<NMPoint>> res = [:]
|
||||
Map<String, List<NumassPointImpl>> res = [:]
|
||||
|
||||
List<NMPoint> generated = new ArrayList<>();
|
||||
List<NMPoint> registered = new ArrayList<>();
|
||||
List<NMPoint> firstIteration = new ArrayList<>();
|
||||
List<NMPoint> secondIteration = new ArrayList<>();
|
||||
List<NMPoint> pileup = new ArrayList<>();
|
||||
List<NumassPointImpl> generated = new ArrayList<>();
|
||||
List<NumassPointImpl> registered = new ArrayList<>();
|
||||
List<NumassPointImpl> firstIteration = new ArrayList<>();
|
||||
List<NumassPointImpl> secondIteration = new ArrayList<>();
|
||||
List<NumassPointImpl> pileup = new ArrayList<>();
|
||||
|
||||
lowerChannel = 400;
|
||||
upperChannel = 1800;
|
||||
|
||||
PileUpSimulator buildSimulator(NMPoint point, double cr, NMPoint reference = null, boolean extrapolate = true, double scale = 1d) {
|
||||
PileUpSimulator buildSimulator(NumassPointImpl point, double cr, NumassPointImpl reference = null, boolean extrapolate = true, double scale = 1d) {
|
||||
def cfg = Grind.buildMeta(cr: cr) {
|
||||
pulser(mean: 3450, sigma: 86.45, freq: 66.43)
|
||||
}
|
||||
@ -88,7 +88,7 @@ PileUpSimulator buildSimulator(NMPoint point, double cr, NMPoint reference = nul
|
||||
return new PileUpSimulator(point.length * scale, rnd, generator).withUset(point.voltage).generate();
|
||||
}
|
||||
|
||||
double adjustCountRate(PileUpSimulator simulator, NMPoint point) {
|
||||
double adjustCountRate(PileUpSimulator simulator, NumassPointImpl point) {
|
||||
double generatedInChannel = simulator.generated().getCountInWindow(lowerChannel, upperChannel);
|
||||
double registeredInChannel = simulator.registered().getCountInWindow(lowerChannel, upperChannel);
|
||||
return (generatedInChannel / registeredInChannel) * (point.getCountInWindow(lowerChannel, upperChannel) / point.getLength());
|
||||
@ -100,7 +100,7 @@ data.forEach { point ->
|
||||
PileUpSimulator simulator = buildSimulator(point, cr);
|
||||
|
||||
//second iteration to exclude pileup overlap
|
||||
NMPoint pileupPoint = simulator.pileup();
|
||||
NumassPointImpl pileupPoint = simulator.pileup();
|
||||
firstIteration.add(simulator.registered());
|
||||
|
||||
//updating count rate
|
||||
|
@ -0,0 +1,49 @@
|
||||
package inr.numass.scripts
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.grind.GrindShell
|
||||
import hep.dataforge.grind.helpers.PlotHelper
|
||||
import hep.dataforge.plots.fx.FXPlotManager
|
||||
import hep.dataforge.tables.MapPoint
|
||||
import inr.numass.NumassPlugin
|
||||
import inr.numass.data.PointAnalyzer
|
||||
import inr.numass.data.RawNMPoint
|
||||
import inr.numass.storage.NumassStorage
|
||||
import inr.numass.storage.NumassStorageFactory
|
||||
|
||||
/**
|
||||
* Created by darksnake on 27-Jun-17.
|
||||
*/
|
||||
|
||||
|
||||
Context ctx = Global.instance()
|
||||
ctx.pluginManager().load(FXPlotManager)
|
||||
ctx.pluginManager().load(NumassPlugin.class)
|
||||
|
||||
GrindShell shell = new GrindShell(ctx)
|
||||
|
||||
shell.eval {
|
||||
PlotHelper plot = plots
|
||||
File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_1")
|
||||
|
||||
NumassStorage storage = NumassStorageFactory.buildLocal(rootDir);
|
||||
|
||||
def hv = 15000;
|
||||
def point = storage.provide("loader::set_2/rawPoint::$hv", RawNMPoint.class).get();
|
||||
|
||||
def t0 = (1..150).collect { 5.5e-6 + 2e-7 * it }
|
||||
|
||||
def plotPoints = t0.collect {
|
||||
def result = PointAnalyzer.analyzePoint(point, it,500,3100)
|
||||
MapPoint.fromMap("x.value": it, "y.value": result.cr, "y.err": result.crErr);
|
||||
}
|
||||
//def cr = t0.collect { PointAnalyzer.analyzePoint(point, it).cr }
|
||||
|
||||
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) }
|
||||
|
||||
storage.close()
|
||||
}
|
@ -9,9 +9,9 @@ package inr.numass.scripts
|
||||
import hep.dataforge.io.ColumnedDataWriter
|
||||
import hep.dataforge.storage.commons.StorageUtils
|
||||
import hep.dataforge.tables.Table
|
||||
import inr.numass.data.NMPoint
|
||||
import inr.numass.data.NumassData
|
||||
import inr.numass.data.NumassDataUtils
|
||||
import inr.numass.data.NumassPointImpl
|
||||
import inr.numass.storage.NumassStorage
|
||||
import inr.numass.storage.NumassStorageFactory
|
||||
import inr.numass.utils.UnderflowCorrection
|
||||
@ -23,7 +23,7 @@ File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_1")
|
||||
|
||||
NumassStorage storage = NumassStorageFactory.buildLocal(rootDir);
|
||||
|
||||
Collection<NMPoint> data = NumassDataUtils.joinSpectra(
|
||||
Collection<NumassPointImpl> data = NumassDataUtils.joinSpectra(
|
||||
StorageUtils.loaderStream(storage)
|
||||
.filter { it.key.matches("set_.{1,3}") }
|
||||
.map {
|
||||
@ -55,8 +55,8 @@ data = NumassDataUtils.substractReferencePoint(data, 18600d);
|
||||
// }
|
||||
//}
|
||||
|
||||
def printPoint(Iterable<NMPoint> data, List<Double> us, int binning = 20, normalize = true) {
|
||||
List<NMPoint> points = data.findAll { it.voltage in us }.sort { it.voltage }
|
||||
def printPoint(Iterable<NumassPointImpl> data, List<Double> us, int binning = 20, normalize = true) {
|
||||
List<NumassPointImpl> points = data.findAll { it.voltage in us }.sort { it.voltage }
|
||||
|
||||
Map spectra = points.first().getMap(binning, normalize).collectEntries { key, value ->
|
||||
[key, [value]]
|
||||
|
@ -20,8 +20,7 @@ import hep.dataforge.data.binary.Binary;
|
||||
import hep.dataforge.io.BasicIOManager;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.names.Name;
|
||||
import inr.numass.data.NumassDataReader;
|
||||
import inr.numass.data.NumassPawReader;
|
||||
import inr.numass.data.LegacyDataReader;
|
||||
import inr.numass.data.RawNMFile;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.output.TeeOutputStream;
|
||||
@ -40,7 +39,7 @@ public class NumassIO extends BasicIOManager {
|
||||
public static final String NUMASS_OUTPUT_CONTEXT_KEY = "numass.outputDir";
|
||||
|
||||
public static RawNMFile readAsDat(Binary source, Meta config) throws IOException {
|
||||
return new NumassDataReader(source, config).read();
|
||||
return new LegacyDataReader(source, config).read();
|
||||
}
|
||||
|
||||
// private File getOutputDir() {
|
||||
@ -53,18 +52,15 @@ public class NumassIO extends BasicIOManager {
|
||||
//
|
||||
// }
|
||||
|
||||
public static RawNMFile readAsPaw(Binary source, Meta config) throws IOException {
|
||||
return new NumassPawReader().readPaw(source, config.getString(FileDataFactory.FILE_NAME_KEY));
|
||||
}
|
||||
// public static RawNMFile readAsPaw(Binary source, Meta config) throws IOException {
|
||||
// return new NumassPawReader().readPaw(source, config.getString(FileDataFactory.FILE_NAME_KEY));
|
||||
// }
|
||||
|
||||
public static RawNMFile getNumassData(Binary binary, Meta config) {
|
||||
try {
|
||||
RawNMFile dataFile;
|
||||
String extension = FilenameUtils.getExtension(config.getString(FileDataFactory.FILE_NAME_KEY)).toLowerCase();
|
||||
switch (extension) {
|
||||
case "paw":
|
||||
dataFile = readAsPaw(binary, config);
|
||||
break;
|
||||
case "dat":
|
||||
dataFile = readAsDat(binary, config);
|
||||
break;
|
||||
|
@ -53,7 +53,7 @@ public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
|
||||
|
||||
RawNMFile res = new RawNMFile(source.getName(), source.getHead());
|
||||
source.getData().stream().map((point) -> {
|
||||
double cr = point.selectChanels(lower, upper).getCR();
|
||||
double cr = point.selectChanels(lower, upper).getCr();
|
||||
if (cr < maxCR) {
|
||||
DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point);
|
||||
|
||||
|
@ -4,9 +4,9 @@ import hep.dataforge.actions.ManyToOneAction;
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.description.TypedActionDef;
|
||||
import hep.dataforge.meta.Laminate;
|
||||
import inr.numass.data.NMPoint;
|
||||
import inr.numass.data.NumassData;
|
||||
import inr.numass.data.NumassPoint;
|
||||
import inr.numass.data.NumassPointImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@ -29,7 +29,7 @@ public class JoinNumassDataAction extends ManyToOneAction<NumassData, NumassData
|
||||
if (p1.getVoltage() != p2.getVoltage()) {
|
||||
throw new RuntimeException("Can't sum points with different Uset");
|
||||
}
|
||||
return new NMPoint(
|
||||
return new NumassPointImpl(
|
||||
(p1.getVoltage() + p2.getVoltage()) / 2,
|
||||
p1.getStartTime(),
|
||||
p1.getLength() + p2.getLength(),
|
||||
|
@ -204,7 +204,7 @@ public class PrepareDataAction extends OneToOneAction<NumassData, Table> {
|
||||
double framelength = meta.getDouble("framelength", 1);
|
||||
double maxCR = meta.getDouble("maxcr", 500d);
|
||||
|
||||
double cr = point.selectChanels(lower, upper).getCR();
|
||||
double cr = point.selectChanels(lower, upper).getCr();
|
||||
if (cr < maxCR) {
|
||||
DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point);
|
||||
return PointBuilders.readRawPoint(report.getPoint());
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Alexander Nozik.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package inr.numass.data;
|
||||
|
||||
import hep.dataforge.data.binary.Binary;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darksnake
|
||||
*/
|
||||
public class NumassPawReader {
|
||||
|
||||
public RawNMFile readPaw(Binary file, String name) throws IOException{
|
||||
Locale.setDefault(Locale.US);
|
||||
return readPaw(file.getStream(), name);
|
||||
}
|
||||
|
||||
public RawNMFile readPaw(String filePath) throws FileNotFoundException{
|
||||
return readPaw(new FileInputStream(filePath), filePath);
|
||||
}
|
||||
|
||||
|
||||
private RawNMFile readPaw(InputStream stream, String fileName) {
|
||||
Scanner s = new Scanner(stream);
|
||||
RawNMFile result = new RawNMFile(fileName);
|
||||
|
||||
while (s.hasNext()) {
|
||||
long eventNum = s.nextLong();
|
||||
double time = s.nextDouble();
|
||||
short chanel = s.nextShort();
|
||||
short timeTotal = s.nextShort();
|
||||
double U = s.nextDouble();
|
||||
|
||||
// NumassEvent event = new NumassEvent(chanel, time);
|
||||
result.putEvent(U, chanel, time);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
@ -87,7 +87,7 @@ public class FrameAnalizer implements Debuncher {
|
||||
}
|
||||
|
||||
private DebunchReport debunch(RawNMPoint point, double prob, double frameShift, double frameLength) {
|
||||
double cr = point.selectChanels(lowerChanel, upperChanel).getCR();
|
||||
double cr = point.selectChanels(lowerChanel, upperChanel).getCr();
|
||||
return debunch(point, cr, prob, frameShift, frameLength);
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class NumassPrepareTask extends AbstractTask<Table> {
|
||||
// double framelength = meta.getDouble("framelength", 1);
|
||||
// double maxCR = meta.getDouble("maxcr", 500d);
|
||||
//
|
||||
// double cr = point.selectChanels(lower, upper).getCR();
|
||||
// double cr = point.selectChanels(lower, upper).getCr();
|
||||
// if (cr < maxCR) {
|
||||
// DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point);
|
||||
// return new NMPoint(report.getPoint());
|
||||
|
@ -14,6 +14,7 @@ import hep.dataforge.storage.filestorage.FileStorageFactory;
|
||||
import inr.numass.storage.NumassStorage;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
@ -32,7 +33,7 @@ public class TestServer {
|
||||
|
||||
ServerManager serverManager = context.pluginManager().load(ServerManager.class);
|
||||
|
||||
String path = "D:/temp/test";
|
||||
File path = new File("/D:/temp/test");
|
||||
context.getLogger().info("Starting test numass storage servlet in '{}'", path);
|
||||
|
||||
NumassStorage storage = new NumassStorage(context, FileStorageFactory.buildStorageMeta(path, true, true));
|
||||
|
@ -1,5 +1,5 @@
|
||||
plugins{
|
||||
id "org.jetbrains.kotlin.jvm" version '1.1.2-5'
|
||||
id "org.jetbrains.kotlin.jvm" version '1.1.3'
|
||||
id "application"
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ dependencies {
|
||||
compile 'com.jcraft:jsch:0.1.54'
|
||||
|
||||
compile 'org.controlsfx:controlsfx:8.40.12'
|
||||
compile "no.tornado:tornadofx:1.7.5"
|
||||
compile "no.tornado:tornadofx:1.7.8"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
Loading…
Reference in New Issue
Block a user