diff --git a/numass-client/src/main/java/inr/numass/client/NumassClient.java b/numass-client/src/main/java/inr/numass/client/NumassClient.java index 37ae7b13..a7f13539 100644 --- a/numass-client/src/main/java/inr/numass/client/NumassClient.java +++ b/numass-client/src/main/java/inr/numass/client/NumassClient.java @@ -24,8 +24,8 @@ import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; import hep.dataforge.storage.commons.MessageFactory; import hep.dataforge.storage.commons.StorageUtils; -import hep.dataforge.tables.DataPoint; import hep.dataforge.values.Value; +import hep.dataforge.values.Values; import inr.numass.storage.NumassStorage; import org.slf4j.LoggerFactory; import org.zeroturnaround.zip.ZipUtil; @@ -251,7 +251,7 @@ public class NumassClient implements AutoCloseable, Responder { * @param points * @return */ - public Envelope sendDataPoints(String shelf, String loaderName, Collection points) { + public Envelope sendDataPoints(String shelf, String loaderName, Collection points) { throw new UnsupportedOperationException(); } diff --git a/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java index 72bde81c..18d222c9 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/control/cryotemp/PKT8Device.java @@ -34,10 +34,10 @@ import hep.dataforge.meta.Meta; import hep.dataforge.storage.api.PointLoader; import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.commons.LoaderFactory; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.TableFormat; import hep.dataforge.tables.TableFormatBuilder; import hep.dataforge.utils.DateTimeUtils; +import hep.dataforge.values.Values; import inr.numass.control.StorageHelper; import java.time.Duration; @@ -136,7 +136,7 @@ public class PKT8Device extends PortSensor { collector = new RegularPointCollector( duration, channels.values().stream().map(PKT8Channel::getName).collect(Collectors.toList()), - (DataPoint dp) -> { + (Values dp) -> { getLogger().debug("Point measurement complete. Pushing..."); storageHelper.push(dp); }); diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java index 3252da44..07727131 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/MspDevice.java @@ -39,11 +39,11 @@ import hep.dataforge.meta.Meta; import hep.dataforge.storage.api.PointLoader; import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.commons.LoaderFactory; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.TableFormat; import hep.dataforge.tables.TableFormatBuilder; import hep.dataforge.utils.DateTimeUtils; import hep.dataforge.values.Value; +import hep.dataforge.values.Values; import inr.numass.control.StorageHelper; import java.time.Duration; @@ -61,7 +61,7 @@ import java.util.function.Consumer; @StateDef(value = @ValueDef(name = "filament", info = "The number of filament in use"), writable = true) @StateDef(value = @ValueDef(name = "filamentOn", info = "Mass-spectrometer filament on"), writable = true) @StateDef(@ValueDef(name = "filamentStatus", info = "Filament status")) -public class MspDevice extends Sensor implements PortHandler.PortController { +public class MspDevice extends Sensor implements PortHandler.PortController { public static final String MSP_DEVICE_TYPE = "msp"; private static final Duration TIMEOUT = Duration.ofMillis(200); @@ -409,7 +409,7 @@ public class MspDevice extends Sensor implements PortHandler.PortCont } } - public class PeakJumpMeasurement extends AbstractMeasurement implements Consumer { + public class PeakJumpMeasurement extends AbstractMeasurement implements Consumer { private RegularPointCollector collector = new RegularPointCollector(getAveragingDuration(), this::result); private StorageHelper helper = new StorageHelper(MspDevice.this, this::makeLoader); @@ -499,7 +499,7 @@ public class MspDevice extends Sensor implements PortHandler.PortCont } @Override - protected synchronized void result(DataPoint result, Instant time) { + protected synchronized void result(Values result, Instant time) { super.result(result, time); helper.push(result); } diff --git a/numass-control/src/main/kotlin/inr/numass/control/StorageHelper.kt b/numass-control/src/main/kotlin/inr/numass/control/StorageHelper.kt index 6493e52d..ed5ad324 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/StorageHelper.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/StorageHelper.kt @@ -4,7 +4,7 @@ import hep.dataforge.control.connections.StorageConnection import hep.dataforge.control.devices.AbstractDevice import hep.dataforge.exceptions.StorageException import hep.dataforge.storage.api.PointLoader -import hep.dataforge.tables.DataPoint +import hep.dataforge.values.Values import java.util.* import java.util.function.Function @@ -15,7 +15,7 @@ import java.util.function.Function class StorageHelper(private val device: AbstractDevice, private val loaderFactory: Function) : AutoCloseable { private val loaderMap = HashMap() - fun push(point: DataPoint) { + fun push(point: Values) { if (!device.hasState("storing") || device.getState("storing").booleanValue()) { device.forEachConnection("storage", StorageConnection::class.java) { connection -> val pl = loaderMap.computeIfAbsent(connection, loaderFactory) diff --git a/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java index 872c62b1..5fa20d8a 100644 --- a/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java +++ b/numass-control/vac/src/main/java/inr/numass/control/readvac/VacCollectorDevice.java @@ -21,12 +21,12 @@ import hep.dataforge.exceptions.ControlException; import hep.dataforge.meta.Meta; import hep.dataforge.storage.api.PointLoader; import hep.dataforge.storage.commons.LoaderFactory; -import hep.dataforge.tables.DataPoint; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.TableFormatBuilder; +import hep.dataforge.tables.ValueMap; import hep.dataforge.utils.DateTimeUtils; import hep.dataforge.values.Value; import hep.dataforge.values.ValueType; +import hep.dataforge.values.Values; import inr.numass.control.StorageHelper; import java.time.Duration; @@ -50,7 +50,7 @@ import static hep.dataforge.control.devices.PortSensor.CONNECTED_STATE; value = @ValueDef(name = "storing", info = "Define if this device is currently writes to storage"), writable = true ) -public class VacCollectorDevice extends Sensor { +public class VacCollectorDevice extends Sensor { private Map> sensorMap = new LinkedHashMap<>(); private StorageHelper helper = new StorageHelper(VacCollectorDevice.this, this::buildLoader); @@ -86,7 +86,7 @@ public class VacCollectorDevice extends Sensor { //TODO add dot path notation for states @Override - protected Measurement createMeasurement() { + protected Measurement createMeasurement() { //TODO use meta return new VacuumMeasurement(); } @@ -132,7 +132,7 @@ public class VacCollectorDevice extends Sensor { return Duration.parse(meta().getString("averagingDuration", "PT30S")); } - private class VacuumMeasurement extends AbstractMeasurement { + private class VacuumMeasurement extends AbstractMeasurement { private final ValueCollector collector = new RegularPointCollector(getAveragingDuration(), this::result); private ScheduledExecutorService executor; @@ -167,13 +167,13 @@ public class VacCollectorDevice extends Sensor { @Override - protected synchronized void result(DataPoint result, Instant time) { + protected synchronized void result(Values result, Instant time) { super.result(result, time); helper.push(result); } - private DataPoint terminator() { - MapPoint.Builder p = new MapPoint.Builder(); + private Values terminator() { + ValueMap.Builder p = new ValueMap.Builder(); p.putValue("timestamp", DateTimeUtils.now()); sensorMap.keySet().forEach((n) -> { p.putValue(n, null); diff --git a/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java b/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java index 102ede04..f673c804 100644 --- a/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java +++ b/numass-core/src/main/java/inr/numass/data/NumassDataUtils.java @@ -1,8 +1,8 @@ package inr.numass.data; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; import hep.dataforge.tables.Table; +import hep.dataforge.values.Values; import java.time.Instant; import java.util.Arrays; @@ -81,7 +81,7 @@ public class NumassDataUtils { public static Table setHVScale(ListTable data, double beta) { SpectrumDataAdapter reader = adapter(); ListTable.Builder res = new ListTable.Builder(data.getFormat()); - for (DataPoint dp : data) { + for (Values dp : data) { double corrFactor = 1 + beta; res.row(reader.buildSpectrumDataPoint(reader.getX(dp).doubleValue() * corrFactor, reader.getCount(dp), reader.getTime(dp))); } @@ -106,7 +106,7 @@ public class NumassDataUtils { public static Table correctForDeadTime(ListTable data, SpectrumDataAdapter adapter, double dtime) { // SpectrumDataAdapter adapter = adapter(); ListTable.Builder res = new ListTable.Builder(data.getFormat()); - for (DataPoint dp : data) { + for (Values dp : data) { double corrFactor = 1 / (1 - dtime * adapter.getCount(dp) / adapter.getTime(dp)); res.row(adapter.buildSpectrumDataPoint(adapter.getX(dp).doubleValue(), (long) (adapter.getCount(dp) * corrFactor), adapter.getTime(dp))); } diff --git a/numass-core/src/main/java/inr/numass/data/NumassPoint.java b/numass-core/src/main/java/inr/numass/data/NumassPoint.java index 24fb067b..608e4371 100644 --- a/numass-core/src/main/java/inr/numass/data/NumassPoint.java +++ b/numass-core/src/main/java/inr/numass/data/NumassPoint.java @@ -1,7 +1,7 @@ package inr.numass.data; -import hep.dataforge.tables.DataPoint; -import hep.dataforge.tables.MapPoint; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import java.time.Instant; import java.util.LinkedHashMap; @@ -21,7 +21,7 @@ public interface NumassPoint { int getCountInWindow(int from, int to); - List getData(); + List getData(); long getTotalCount(); @@ -49,9 +49,9 @@ public interface NumassPoint { return res; } - default List getData(int binning, boolean normalize) { + default List getData(int binning, boolean normalize) { return getMap(binning, normalize).entrySet().stream() - .map(entry -> new MapPoint(dataNames, entry.getKey(), entry.getValue())) + .map(entry -> new ValueMap(dataNames, entry.getKey(), entry.getValue())) .collect(Collectors.toList()); } diff --git a/numass-core/src/main/java/inr/numass/data/NumassPointImpl.java b/numass-core/src/main/java/inr/numass/data/NumassPointImpl.java index 2749cfda..3d97401c 100644 --- a/numass-core/src/main/java/inr/numass/data/NumassPointImpl.java +++ b/numass-core/src/main/java/inr/numass/data/NumassPointImpl.java @@ -15,8 +15,8 @@ */ package inr.numass.data; -import hep.dataforge.tables.DataPoint; -import hep.dataforge.tables.MapPoint; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import java.time.Instant; import java.util.ArrayList; @@ -72,10 +72,10 @@ public class NumassPointImpl implements NumassPoint { } @Override - public List getData() { - List data = new ArrayList<>(); + public List getData() { + List data = new ArrayList<>(); for (int i = 0; i < RawNMPoint.MAX_CHANEL; i++) { - data.add(new MapPoint(dataNames, i, spectrum[i])); + data.add(new ValueMap(dataNames, i, spectrum[i])); } return data; } diff --git a/numass-core/src/main/java/inr/numass/data/SpectrumDataAdapter.java b/numass-core/src/main/java/inr/numass/data/SpectrumDataAdapter.java index 34f10cc5..94c9fb8f 100644 --- a/numass-core/src/main/java/inr/numass/data/SpectrumDataAdapter.java +++ b/numass-core/src/main/java/inr/numass/data/SpectrumDataAdapter.java @@ -19,11 +19,11 @@ import hep.dataforge.exceptions.DataFormatException; import hep.dataforge.exceptions.NameNotFoundException; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.tables.DataPoint; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.PointAdapter; +import hep.dataforge.tables.ValueMap; import hep.dataforge.tables.XYAdapter; import hep.dataforge.values.Value; +import hep.dataforge.values.Values; /** * @@ -59,29 +59,29 @@ public class SpectrumDataAdapter extends XYAdapter { ); } - public double getTime(DataPoint point) { + public double getTime(Values point) { return this.getFrom(point, POINT_LENGTH_NAME, 1d).doubleValue(); } - public DataPoint buildSpectrumDataPoint(double x, long count, double t) { - return new MapPoint(new String[]{nameFor(X_VALUE_KEY), nameFor(Y_VALUE_KEY), + public Values buildSpectrumDataPoint(double x, long count, double t) { + return new ValueMap(new String[]{nameFor(X_VALUE_KEY), nameFor(Y_VALUE_KEY), nameFor(POINT_LENGTH_NAME)}, x, count, t); } - public DataPoint buildSpectrumDataPoint(double x, long count, double countErr, double t) { - return new MapPoint(new String[]{nameFor(X_VALUE_KEY), nameFor(Y_VALUE_KEY), + public Values buildSpectrumDataPoint(double x, long count, double countErr, double t) { + return new ValueMap(new String[]{nameFor(X_VALUE_KEY), nameFor(Y_VALUE_KEY), nameFor(Y_ERROR_KEY), nameFor(POINT_LENGTH_NAME)}, x, count, countErr, t); } @Override - public boolean providesYError(DataPoint point) { + public boolean providesYError(Values point) { return true; } @Override - public Value getYerr(DataPoint point) throws NameNotFoundException { + public Value getYerr(Values point) throws NameNotFoundException { if (super.providesYError(point)) { return Value.of(super.getYerr(point).doubleValue() / getTime(point)); } else { @@ -94,12 +94,12 @@ public class SpectrumDataAdapter extends XYAdapter { } } - public long getCount(DataPoint point) { + public long getCount(Values point) { return super.getY(point).numberValue().longValue(); } @Override - public Value getY(DataPoint point) { + public Value getY(Values point) { return Value.of(super.getY(point).doubleValue() / getTime(point)); } diff --git a/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy b/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy index 02d27260..5bb948bb 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/DetectorSpectrumSubstraction.groovy @@ -8,8 +8,8 @@ package inr.numass.scripts import hep.dataforge.io.ColumnedDataWriter import hep.dataforge.tables.ListTable -import hep.dataforge.tables.MapPoint import hep.dataforge.tables.TableFormatBuilder +import hep.dataforge.tables.ValueMap import inr.numass.data.NumassData NumassData.metaClass.findPoint{double u -> @@ -28,19 +28,19 @@ Map dif(NumassData data1, NumassData data2, double uset){ def buildSet(NumassData data1, NumassData data2, double... points){ TableFormatBuilder builder = new TableFormatBuilder().addNumber("channel"); - List pointList = new ArrayList<>(); + List pointList = new ArrayList<>(); for(double point: points){ builder.addNumber(Double.toString(point)); Map dif = dif(data1, data2, point); if(pointList.isEmpty()){ for(Double channel : dif.keySet()){ - MapPoint p = new MapPoint(); + ValueMap p = new ValueMap(); p.putValue("channel",channel); pointList.add(p); } } - for(MapPoint mp:pointList){ + for(ValueMap mp:pointList){ double channel = mp.getValue("channel").doubleValue(); mp.putValue(Double.toString(point), dif.get(channel)); } 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 2363663f..109b4dce 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/SimulatePileup.groovy @@ -7,7 +7,7 @@ package inr.numass.scripts import hep.dataforge.grind.Grind -import hep.dataforge.tables.DataPoint +import hep.dataforge.values.Values import inr.numass.data.NumassPointImpl import inr.numass.data.RawNMPoint import inr.numass.storage.NumassDataLoader @@ -63,7 +63,7 @@ PileUpSimulator buildSimulator(NumassPointImpl point, double cr, NumassPointImpl if (extrapolate) { double[] chanels = new double[RawNMPoint.MAX_CHANEL]; double[] values = new double[RawNMPoint.MAX_CHANEL]; - DataPoint fitResult = new UnderflowCorrection().fitPoint(point, 400, 600, 1800, 20); numa + Values fitResult = new UnderflowCorrection().fitPoint(point, 400, 600, 1800, 20); numa def amp = fitResult.getDouble("amp") def sigma = fitResult.getDouble("expConst") @@ -74,7 +74,7 @@ PileUpSimulator buildSimulator(NumassPointImpl point, double cr, NumassPointImpl if (i < lowerChannel) { values[i] = point.getLength()*amp * Math.exp((i as double) / sigma) } else { - values[i] = Math.max(0, point.getCount(i) - (reference == null ? 0 : reference.getCount(i))); + values[i] = Math.max(0, point.getCount(i) - (reference == null ? 0 : reference.getCount(i)) as int); } } generator.loadSpectrum(chanels, values) @@ -88,7 +88,7 @@ PileUpSimulator buildSimulator(NumassPointImpl point, double cr, NumassPointImpl return new PileUpSimulator(point.length * scale, rnd, generator).withUset(point.voltage).generate(); } -double adjustCountRate(PileUpSimulator simulator, NumassPointImpl point) { +static 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()); diff --git a/numass-main/src/main/groovy/inr/numass/scripts/TestPointAnalyzer.groovy b/numass-main/src/main/groovy/inr/numass/scripts/TestPointAnalyzer.groovy index da6462e5..e1e85395 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/TestPointAnalyzer.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/TestPointAnalyzer.groovy @@ -5,7 +5,7 @@ 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 hep.dataforge.tables.ValueMap import inr.numass.NumassPlugin import inr.numass.data.PointAnalyzer import inr.numass.data.RawNMPoint @@ -36,7 +36,7 @@ shell.eval { def plotPoints = t0.collect { def result = PointAnalyzer.analyzePoint(point, it) - MapPoint.fromMap("x.value": it, "y.value": result.cr, "y.err": result.crErr); + ValueMap.fromMap("x.value": it, "y.value": result.cr, "y.err": result.crErr); } //def cr = t0.collect { PointAnalyzer.analyzePoint(point, it).cr } diff --git a/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java b/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java index 21a8a0be..cdb76ad8 100644 --- a/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java +++ b/numass-main/src/main/java/inr/numass/actions/AdjustErrorsAction.java @@ -10,10 +10,10 @@ import hep.dataforge.context.Context; import hep.dataforge.description.TypedActionDef; import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Meta; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import java.util.ArrayList; import java.util.List; @@ -28,15 +28,15 @@ public class AdjustErrorsAction extends OneToOneAction { @Override protected Table execute(Context context, String name, Table input, Laminate meta) { - List points = new ArrayList<>(); - for (DataPoint dp : input) { + List points = new ArrayList<>(); + for (Values dp : input) { points.add(evalPoint(meta, dp)); } return new ListTable(input.getFormat(), points); } - private DataPoint evalPoint(Meta meta, DataPoint dp) { + private Values evalPoint(Meta meta, Values dp) { if (meta.hasMeta("point")) { for (Meta pointMeta : meta.getMetaList("point")) { if (pointMeta.getDouble("Uset") == dp.getDouble("Uset")) { @@ -63,8 +63,8 @@ public class AdjustErrorsAction extends OneToOneAction { return dp; } - private DataPoint adjust(DataPoint dp, Meta config) { - MapPoint.Builder res = new MapPoint.Builder(dp); + private Values adjust(Values dp, Meta config) { + ValueMap.Builder res = new ValueMap.Builder(dp); if (dp.hasValue("CRerr")) { double instability = 0; if (dp.hasValue("CR")) { diff --git a/numass-main/src/main/java/inr/numass/actions/DebunchAction.java b/numass-main/src/main/java/inr/numass/actions/DebunchAction.java index f9d9419f..42f261e7 100644 --- a/numass-main/src/main/java/inr/numass/actions/DebunchAction.java +++ b/numass-main/src/main/java/inr/numass/actions/DebunchAction.java @@ -62,9 +62,7 @@ public class DebunchAction extends OneToOneAction { point = report.getPoint(); } return point; - }).forEach((point) -> { - res.putPoint(point); - }); + }).forEach(res::putPoint); report(context, name, "File {} completed", source.getName()); context.getChronicle(name).print(new PrintWriter(buildActionOutput(context, name))); diff --git a/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java b/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java index 15eea4a8..71f05e41 100644 --- a/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java +++ b/numass-main/src/main/java/inr/numass/actions/FindBorderAction.java @@ -22,8 +22,8 @@ import hep.dataforge.exceptions.ContentException; import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.meta.Laminate; import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; +import hep.dataforge.tables.ValueMap; import hep.dataforge.values.Value; import inr.numass.data.NMFile; import inr.numass.data.NumassData; @@ -125,7 +125,7 @@ public class FindBorderAction extends OneToOneAction { } } - dataBuilder.row(new MapPoint(map)); + dataBuilder.row(new ValueMap(map)); } } diff --git a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java index aefe6852..2e3101db 100644 --- a/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MergeDataAction.java @@ -25,6 +25,7 @@ import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Meta; import hep.dataforge.tables.*; +import hep.dataforge.values.Values; import java.io.OutputStream; import java.util.*; @@ -90,7 +91,7 @@ public class MergeDataAction extends ManyToOneAction { // return builder; // } - private DataPoint mergeDataPoints(DataPoint dp1, DataPoint dp2) { + private Values mergeDataPoints(Values dp1, Values dp2) { if (dp1 == null) { return dp2; } @@ -121,7 +122,7 @@ public class MergeDataAction extends ManyToOneAction { // абсолютные ошибки складываются квадратично double crErr = Math.sqrt(err1 * err1 * t1 * t1 + err2 * err2 * t2 * t2) / time; - MapPoint.Builder map = new MapPoint(parnames, Uset, Uread, time, total, wind, cr, crErr).builder(); + ValueMap.Builder map = new ValueMap(parnames, Uset, Uread, time, total, wind, cr, crErr).builder(); if (dp1.names().contains("relCR") && dp2.names().contains("relCR")) { double relCR = (dp1.getDouble("relCR") + dp2.getDouble("relCR")) / 2; @@ -134,12 +135,12 @@ public class MergeDataAction extends ManyToOneAction { private Table mergeDataSets(String name, Collection ds) { //Сливаем все точки в один набор данных - Map> points = new LinkedHashMap<>(); + Map> points = new LinkedHashMap<>(); for (Table d : ds) { if (!d.getFormat().names().contains(parnames)) { throw new IllegalArgumentException(); } - for (DataPoint dp : d) { + for (Values dp : d) { double uset = dp.getValue(parnames[0]).doubleValue(); if (!points.containsKey(uset)) { points.put(uset, new ArrayList<>()); @@ -148,11 +149,11 @@ public class MergeDataAction extends ManyToOneAction { } } - List res = new ArrayList<>(); + List res = new ArrayList<>(); points.entrySet().stream().map((entry) -> { - DataPoint curPoint = null; - for (DataPoint newPoint : entry.getValue()) { + Values curPoint = null; + for (Values newPoint : entry.getValue()) { curPoint = mergeDataPoints(curPoint, newPoint); } return curPoint; diff --git a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java index 1aea87c9..9ef47c53 100644 --- a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java @@ -23,8 +23,12 @@ import hep.dataforge.exceptions.ContentException; import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Meta; -import hep.dataforge.tables.*; +import hep.dataforge.tables.ListTable; +import hep.dataforge.tables.Table; +import hep.dataforge.tables.TableTransform; +import hep.dataforge.tables.ValueMap; import hep.dataforge.values.Value; +import hep.dataforge.values.Values; import javafx.util.Pair; import org.apache.commons.math3.analysis.interpolation.SplineInterpolator; import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction; @@ -50,7 +54,7 @@ public class MonitorCorrectAction extends OneToOneAction { private static final String[] monitorNames = {"Timestamp", "Total", "CR", "CRerr"}; - CopyOnWriteArrayList monitorPoints = new CopyOnWriteArrayList<>(); + CopyOnWriteArrayList monitorPoints = new CopyOnWriteArrayList<>(); //FIXME remove from state @Override @@ -58,7 +62,7 @@ public class MonitorCorrectAction extends OneToOneAction { double monitor = meta.getDouble("monitorPoint", Double.NaN); - TreeMap index = getMonitorIndex(monitor, sourceData); + TreeMap index = getMonitorIndex(monitor, sourceData); if (index.isEmpty()) { context.getChronicle(name).reportError("No monitor points found"); return sourceData; @@ -67,7 +71,7 @@ public class MonitorCorrectAction extends OneToOneAction { double totalAv = 0; String head = ""; head += String.format("%20s\t%10s\t%s%n", "Timestamp", "Total", "CR in window"); - for (DataPoint dp : index.values()) { + for (Values dp : index.values()) { head += String.format("%20s\t%10d\t%g%n", getTime(dp).toString(), getTotal(dp), getCR(dp)); norm += getCR(dp) / index.size(); totalAv += getTotal(dp) / index.size(); @@ -76,10 +80,10 @@ public class MonitorCorrectAction extends OneToOneAction { head += String.format("%20s\t%10g\t%g%n", "Average", totalAv, norm); - List dataList = new ArrayList<>(); + List dataList = new ArrayList<>(); - for (DataPoint dp : sourceData) { - MapPoint.Builder pb = new MapPoint.Builder(dp); + for (Values dp : sourceData) { + ValueMap.Builder pb = new ValueMap.Builder(dp); pb.putValue("Monitor", 1.0); if (!isMonitorPoint(monitor, dp) || index.isEmpty()) { Pair corr; @@ -139,7 +143,7 @@ public class MonitorCorrectAction extends OneToOneAction { return data; } - private Pair getSplineCorrection(TreeMap index, DataPoint dp, double norm) { + private Pair getSplineCorrection(TreeMap index, Values dp, double norm) { double time = getTime(dp).toEpochMilli(); double[] xs = new double[index.size()]; @@ -147,7 +151,7 @@ public class MonitorCorrectAction extends OneToOneAction { int i = 0; - for (Entry entry : index.entrySet()) { + for (Entry entry : index.entrySet()) { xs[i] = (double) entry.getKey().toEpochMilli(); ys[i] = getCR(entry.getValue()) / norm; i++; @@ -162,10 +166,10 @@ public class MonitorCorrectAction extends OneToOneAction { } } - private Pair getLinearCorrection(TreeMap index, DataPoint dp, double norm) { + private Pair getLinearCorrection(TreeMap index, Values dp, double norm) { Instant time = getTime(dp); - Entry previousMonitor = index.floorEntry(time); - Entry nextMonitor = index.ceilingEntry(time); + Entry previousMonitor = index.floorEntry(time); + Entry nextMonitor = index.ceilingEntry(time); if (previousMonitor == null) { previousMonitor = nextMonitor; @@ -203,25 +207,25 @@ public class MonitorCorrectAction extends OneToOneAction { } } - private boolean isMonitorPoint(double monitor, DataPoint point) { + private boolean isMonitorPoint(double monitor, Values point) { return point.getValue("Uset").doubleValue() == monitor; } - private Instant getTime(DataPoint point) { + private Instant getTime(Values point) { return point.getValue("Timestamp").timeValue(); } - private int getTotal(DataPoint point) { + private int getTotal(Values point) { return point.getValue("Total").intValue(); } - private double getCR(DataPoint point) { + private double getCR(Values point) { return point.getValue("CR").doubleValue(); } - private TreeMap getMonitorIndex(double monitor, Iterable data) { - TreeMap res = new TreeMap<>(); - for (DataPoint dp : data) { + private TreeMap getMonitorIndex(double monitor, Iterable data) { + TreeMap res = new TreeMap<>(); + for (Values dp : data) { if (isMonitorPoint(monitor, dp)) { res.put(getTime(dp), dp); } diff --git a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java index 0533f81b..dec25cfd 100644 --- a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java @@ -25,7 +25,11 @@ import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.XMLMetaWriter; import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Meta; -import hep.dataforge.tables.*; +import hep.dataforge.tables.ListTable; +import hep.dataforge.tables.Table; +import hep.dataforge.tables.TableFormat; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import inr.numass.data.NumassData; import inr.numass.data.NumassPoint; import inr.numass.data.PointBuilders; @@ -113,7 +117,7 @@ public class PrepareDataAction extends OneToOneAction { } } - List dataList = new ArrayList<>(); + List dataList = new ArrayList<>(); for (NumassPoint point : dataFile) { long total = point.getTotalCount(); @@ -145,7 +149,7 @@ public class PrepareDataAction extends OneToOneAction { Instant timestamp = point.getStartTime(); - dataList.add(new MapPoint(parnames, new Object[]{uset, uread, time, total, wind, correctionFactor, cr, crErr, timestamp})); + dataList.add(new ValueMap(parnames, new Object[]{uset, uread, time, total, wind, correctionFactor, cr, crErr, timestamp})); } TableFormat format; diff --git a/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java index 2897db84..9efbb570 100644 --- a/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ShowEnergySpectrumAction.java @@ -18,6 +18,7 @@ import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.XYPlottable; import hep.dataforge.tables.*; import hep.dataforge.values.ValueType; +import hep.dataforge.values.Values; import inr.numass.data.NumassData; import inr.numass.data.NumassPoint; @@ -68,7 +69,7 @@ public class ShowEnergySpectrumAction extends OneToOneAction ListTable.Builder builder = new ListTable.Builder(formatBuilder.build()); rows.stream().forEachOrdered((Double channel) -> { - MapPoint.Builder mb = new MapPoint.Builder(); + ValueMap.Builder mb = new ValueMap.Builder(); mb.putValue("channel", channel); valueMap.entrySet().forEach((Map.Entry> entry) -> { mb.putValue(entry.getKey(), entry.getValue().get(channel)); @@ -106,8 +107,8 @@ public class ShowEnergySpectrumAction extends OneToOneAction String seriesName = String.format("%d: %s", index, entry.getKey()); String[] nameList = {XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY}; - List data = entry.getValue().entrySet().stream() - .map(e -> new MapPoint(nameList, e.getKey(), e.getValue())) + List data = entry.getValue().entrySet().stream() + .map(e -> new ValueMap(nameList, e.getKey(), e.getValue())) .collect(Collectors.toList()); PlottableData datum = PlottableData.plot(seriesName, XYAdapter.DEFAULT_ADAPTER, data); datum.configure(plottableConfig); diff --git a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java index 7c0c5de7..08815bf1 100644 --- a/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/SubstractSpectrumAction.java @@ -11,10 +11,10 @@ import hep.dataforge.description.TypedActionDef; import hep.dataforge.io.ColumnedDataReader; import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.meta.Laminate; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import java.io.File; import java.io.IOException; @@ -35,8 +35,8 @@ public class SubstractSpectrumAction extends OneToOneAction { Table referenceTable = new ColumnedDataReader(referenceFile).toTable(); ListTable.Builder builder = new ListTable.Builder(input.getFormat()); input.stream().forEach(point -> { - MapPoint.Builder pointBuilder = new MapPoint.Builder(point); - Optional referencePoint = referenceTable.stream() + ValueMap.Builder pointBuilder = new ValueMap.Builder(point); + Optional referencePoint = referenceTable.stream() .filter(p -> Math.abs(p.getDouble("Uset") - point.getDouble("Uset")) < 0.1).findFirst(); if (referencePoint.isPresent()) { pointBuilder.putValue("CR", Math.max(0, point.getDouble("CR") - referencePoint.get().getDouble("CR"))); diff --git a/numass-main/src/main/java/inr/numass/actions/SummaryAction.java b/numass-main/src/main/java/inr/numass/actions/SummaryAction.java index 033293ea..eb4cdc55 100644 --- a/numass-main/src/main/java/inr/numass/actions/SummaryAction.java +++ b/numass-main/src/main/java/inr/numass/actions/SummaryAction.java @@ -25,8 +25,12 @@ import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.meta.Laminate; import hep.dataforge.meta.Meta; import hep.dataforge.stat.fit.FitState; -import hep.dataforge.tables.*; +import hep.dataforge.tables.ListTable; +import hep.dataforge.tables.Table; +import hep.dataforge.tables.TableFormat; +import hep.dataforge.tables.ValueMap; import hep.dataforge.values.Value; +import hep.dataforge.values.Values; import java.io.OutputStream; import java.util.Arrays; @@ -92,7 +96,7 @@ public class SummaryAction extends ManyToOneAction { weights[i] += weight; } values[values.length - 1] = Value.of(state.getChi2()); - DataPoint point = new MapPoint(names, values); + Values point = new ValueMap(names, values); res.row(point); }); @@ -105,7 +109,7 @@ public class SummaryAction extends ManyToOneAction { averageValues[2 * i + 2] = Value.of(1 / Math.sqrt(weights[i])); } - res.row(new MapPoint(names, averageValues)); + res.row(new ValueMap(names, averageValues)); return res.build(); } diff --git a/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java b/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java index f761c47b..978e303f 100644 --- a/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java +++ b/numass-main/src/main/java/inr/numass/data/SpectrumGenerator.java @@ -18,9 +18,9 @@ package inr.numass.data; import hep.dataforge.stat.fit.ParamSet; import hep.dataforge.stat.models.Generator; import hep.dataforge.stat.models.XYModel; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; import hep.dataforge.tables.Table; +import hep.dataforge.values.Values; import org.apache.commons.math3.random.JDKRandomGenerator; import org.apache.commons.math3.random.RandomDataGenerator; import org.apache.commons.math3.random.RandomGenerator; @@ -66,9 +66,9 @@ public class SpectrumGenerator implements Generator { } @Override - public Table generateData(Iterable config) { + public Table generateData(Iterable config) { ListTable.Builder res = new ListTable.Builder(adapter.getFormat()); - for (Iterator it = config.iterator(); it.hasNext();) { + for (Iterator it = config.iterator(); it.hasNext();) { res.row(this.generateDataPoint(it.next())); } return res.build(); @@ -81,21 +81,21 @@ public class SpectrumGenerator implements Generator { * @param config * @return */ - public Table generateExactData(Iterable config) { + public Table generateExactData(Iterable config) { ListTable.Builder res = new ListTable.Builder(adapter.getFormat()); - for (Iterator it = config.iterator(); it.hasNext();) { + for (Iterator it = config.iterator(); it.hasNext();) { res.row(this.generateExactDataPoint(it.next())); } return res.build(); } - public DataPoint generateExactDataPoint(DataPoint configPoint) { + public Values generateExactDataPoint(Values configPoint) { double mu = this.getMu(configPoint); return adapter.buildSpectrumDataPoint(this.getX(configPoint), (long) mu, this.getTime(configPoint)); } @Override - public DataPoint generateDataPoint(DataPoint configPoint) { + public Values generateDataPoint(Values configPoint) { double mu = this.getMu(configPoint); if (isNaN(mu) || (mu < 0)) { throw new IllegalStateException("Negative input parameter for generator."); @@ -138,7 +138,7 @@ public class SpectrumGenerator implements Generator { return this.genType.name(); } - private double getMu(DataPoint point) { + private double getMu(Values point) { return source.value(this.getX(point), params) * this.getTime(point); } @@ -148,7 +148,7 @@ public class SpectrumGenerator implements Generator { // } // return sqrt(this.getMu(point)); // } - private double getTime(DataPoint point) { + private double getTime(Values point) { return adapter.getTime(point); // if (point.containsName("time")) { @@ -172,7 +172,7 @@ public class SpectrumGenerator implements Generator { this.adapter = adapter; } - private double getX(DataPoint point) { + private double getX(Values point) { return adapter.getX(point).doubleValue(); } diff --git a/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java b/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java index cc2ee9c5..87fb1050 100644 --- a/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java +++ b/numass-main/src/main/java/inr/numass/data/SpectrumInformation.java @@ -17,9 +17,8 @@ package inr.numass.data; import hep.dataforge.maths.NamedMatrix; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.linear.Array2DRowRealMatrix; import org.apache.commons.math3.linear.RealMatrix; @@ -38,7 +37,7 @@ public class SpectrumInformation { this.source = source; } - public NamedMatrix getExpetedCovariance(NamedValueSet set, ListTable data, String... parNames) { + public NamedMatrix getExpetedCovariance(Values set, ListTable data, String... parNames) { String[] names = parNames; if (names.length == 0) { names = source.namesAsArray(); @@ -56,7 +55,7 @@ public class SpectrumInformation { * @param parNames * @return */ - public NamedMatrix getInformationMatrix(NamedValueSet set, ListTable data, String... parNames) { + public NamedMatrix getInformationMatrix(Values set, ListTable data, String... parNames) { SpectrumDataAdapter reader = NumassDataUtils.adapter(); String[] names = parNames; @@ -67,7 +66,7 @@ public class SpectrumInformation { assert source.names().contains(names); RealMatrix res = new Array2DRowRealMatrix(names.length, names.length); - for (DataPoint dp : data) { + for (Values dp : data) { /*PENDING Тут имеется глобальная неоптимальность связанная с тем, * что при каждом вызове вычисляются две производные * Нужно вычислять сразу всю матрицу для каждой точки, тогда количество @@ -80,11 +79,11 @@ public class SpectrumInformation { } // формула правильная! - public double getPoinSignificance(NamedValueSet set, String name1, String name2, double x) { + public double getPoinSignificance(Values set, String name1, String name2, double x) { return source.derivValue(name1, x, set) * source.derivValue(name2, x, set) / source.value(x, set); } - public NamedMatrix getPointInfoMatrix(NamedValueSet set, double x, double t, String... parNames) { + public NamedMatrix getPointInfoMatrix(Values set, double x, double t, String... parNames) { assert source.names().contains(set.namesAsArray()); String[] names = parNames; @@ -119,7 +118,7 @@ public class SpectrumInformation { * @param name2 * @return */ - public UnivariateFunction getSignificanceFunction(final NamedValueSet set, final String name1, final String name2) { + public UnivariateFunction getSignificanceFunction(final Values set, final String name1, final String name2) { return (double d) -> getPoinSignificance(set, name1, name2, d); } } diff --git a/numass-main/src/main/java/inr/numass/models/BetaSpectrum.java b/numass-main/src/main/java/inr/numass/models/BetaSpectrum.java index e3607cf6..5785c297 100644 --- a/numass-main/src/main/java/inr/numass/models/BetaSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/BetaSpectrum.java @@ -17,8 +17,8 @@ package inr.numass.models; import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.stat.parametric.AbstractParametricFunction; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; +import hep.dataforge.values.Values; import java.io.File; import java.io.FileInputStream; @@ -130,7 +130,7 @@ public class BetaSpectrum extends AbstractParametricFunction implements RangedNa } @Override - public double derivValue(String name, double E, NamedValueSet pars) throws NotDefinedException { + public double derivValue(String name, double E, Values pars) throws NotDefinedException { if (this.fss == null) { return this.derivRootsterile(name, E, pars); } @@ -147,12 +147,12 @@ public class BetaSpectrum extends AbstractParametricFunction implements RangedNa } @Override - public Double max(NamedValueSet set) { + public Double max(Values set) { return set.getDouble("E0"); } @Override - public Double min(NamedValueSet set) { + public Double min(Values set) { return 0d; } @@ -216,7 +216,7 @@ public class BetaSpectrum extends AbstractParametricFunction implements RangedNa } @Override - public double value(double E, NamedValueSet pars) { + public double value(double E, Values pars) { if (this.fss == null) { return rootsterile(E, pars); } diff --git a/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java b/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java index 24ea4e92..d62ae9a0 100644 --- a/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java @@ -6,7 +6,7 @@ package inr.numass.models; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import inr.numass.utils.NumassIntegrator; import inr.numass.utils.TritiumUtils; import org.apache.commons.math3.analysis.UnivariateFunction; @@ -38,7 +38,7 @@ public class CustomNBkgSpectrum extends NBkgSpectrum { } @Override - public double value(double x, NamedValueSet set) { + public double value(double x, Values set) { if (customBackgroundFunction == null) { return super.value(x, set); } else { diff --git a/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java b/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java index d420a6a0..a4803a50 100644 --- a/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java @@ -17,14 +17,15 @@ package inr.numass.models; import hep.dataforge.exceptions.NamingException; import hep.dataforge.exceptions.NotDefinedException; -import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.maths.integration.GaussRuleIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator; -import hep.dataforge.values.NamedValueSet; -import java.util.List; +import hep.dataforge.stat.parametric.AbstractParametricFunction; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; +import java.util.List; + /** * * @author Darksnake @@ -45,12 +46,12 @@ public class EmpiricalLossSpectrum extends AbstractParametricFunction { } @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { throw new NotDefinedException(); } @Override - public double value(double U, NamedValueSet set) { + public double value(double U, Values set) { if (U >= eMax) { return 0; } diff --git a/numass-main/src/main/java/inr/numass/models/ExperimentalVariableLossSpectrum.java b/numass-main/src/main/java/inr/numass/models/ExperimentalVariableLossSpectrum.java index 4dcaea17..151b4a44 100644 --- a/numass-main/src/main/java/inr/numass/models/ExperimentalVariableLossSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/ExperimentalVariableLossSpectrum.java @@ -18,8 +18,8 @@ package inr.numass.models; import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; @@ -38,7 +38,7 @@ public class ExperimentalVariableLossSpectrum extends VariableLossSpectrum { return new ExperimentalVariableLossSpectrum(new AbstractParametricFunction(new String[0]) { @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { throw new NotDefinedException(); } @@ -48,7 +48,7 @@ public class ExperimentalVariableLossSpectrum extends VariableLossSpectrum { } @Override - public double value(double x, NamedValueSet set) { + public double value(double x, Values set) { return transmission.value(x); } }, eMax,smootherW); diff --git a/numass-main/src/main/java/inr/numass/models/FSS.java b/numass-main/src/main/java/inr/numass/models/FSS.java index 41373ded..4cd59792 100644 --- a/numass-main/src/main/java/inr/numass/models/FSS.java +++ b/numass-main/src/main/java/inr/numass/models/FSS.java @@ -16,8 +16,8 @@ package inr.numass.models; import hep.dataforge.io.IOUtils; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.PointSource; +import hep.dataforge.values.Values; import java.io.InputStream; import java.util.ArrayList; @@ -33,7 +33,7 @@ public class FSS { public FSS(InputStream stream) { PointSource data = IOUtils.readColumnedData(stream, "E", "P"); norm = 0; - for (DataPoint dp : data) { + for (Values dp : data) { es.add(dp.getDouble("E")); double p = dp.getDouble("P"); ps.add(p); diff --git a/numass-main/src/main/java/inr/numass/models/GaussResolution.java b/numass-main/src/main/java/inr/numass/models/GaussResolution.java index fe16da2e..1d678bb8 100644 --- a/numass-main/src/main/java/inr/numass/models/GaussResolution.java +++ b/numass-main/src/main/java/inr/numass/models/GaussResolution.java @@ -19,8 +19,8 @@ import hep.dataforge.context.Global; import hep.dataforge.exceptions.NameNotFoundException; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.integration.SimpsonIntegrator; import org.apache.commons.math3.analysis.integration.UnivariateIntegrator; @@ -51,7 +51,7 @@ public class GaussResolution extends AbstractParametricFunction implements Trans } @Override - public double derivValue(String name, double X, NamedValueSet pars) { + public double derivValue(String name, double X, Values pars) { if (abs(X - getPos(pars)) > cutoff * getW(pars)) { return 0; } @@ -71,7 +71,7 @@ public class GaussResolution extends AbstractParametricFunction implements Trans int maxEval = Global.instance().getInt("INTEGR_POINTS", 500); @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { double a = getLowerBound(set); double b = getUpperBound(set); assert b > a; @@ -87,7 +87,7 @@ public class GaussResolution extends AbstractParametricFunction implements Trans } @Override - public double value(double x, NamedValueSet set) { + public double value(double x, Values set) { double a = getLowerBound(set); double b = getUpperBound(set); assert b > a; @@ -97,11 +97,11 @@ public class GaussResolution extends AbstractParametricFunction implements Trans } @Override - public double getDeriv(String name, NamedValueSet set, double input, double output) { + public double getDeriv(String name, Values set, double input, double output) { return this.derivValue(name, output - input, set); } - private UnivariateFunction getDerivProduct(final String name, final ParametricFunction bare, final NamedValueSet pars, final double x0) { + private UnivariateFunction getDerivProduct(final String name, final ParametricFunction bare, final Values pars, final double x0) { return (double x) -> { double res1; double res2; @@ -119,7 +119,7 @@ public class GaussResolution extends AbstractParametricFunction implements Trans }; } - private double getLowerBound(final NamedValueSet pars) { + private double getLowerBound(final Values pars) { return getPos(pars) - cutoff * getW(pars); } @@ -129,7 +129,7 @@ public class GaussResolution extends AbstractParametricFunction implements Trans return 0; } - private UnivariateFunction getProduct(final ParametricFunction bare, final NamedValueSet pars, final double x0) { + private UnivariateFunction getProduct(final ParametricFunction bare, final Values pars, final double x0) { return (double x) -> { double res = bare.value(x0 - x, pars) * GaussResolution.this.value(x, pars); assert !isNaN(res); @@ -137,12 +137,12 @@ public class GaussResolution extends AbstractParametricFunction implements Trans }; } - private double getUpperBound(final NamedValueSet pars) { + private double getUpperBound(final Values pars) { return getPos(pars) + cutoff * getW(pars); } @Override - public double getValue(NamedValueSet set, double input, double output) { + public double getValue(Values set, double input, double output) { return this.value(output - input, set); } @@ -156,7 +156,7 @@ public class GaussResolution extends AbstractParametricFunction implements Trans } @Override - public double value(double x, NamedValueSet pars) { + public double value(double x, Values pars) { if (abs(x - getPos(pars)) > cutoff * getW(pars)) { return 0; } diff --git a/numass-main/src/main/java/inr/numass/models/GaussSourceSpectrum.java b/numass-main/src/main/java/inr/numass/models/GaussSourceSpectrum.java index d9309dd9..b944eb4b 100644 --- a/numass-main/src/main/java/inr/numass/models/GaussSourceSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/GaussSourceSpectrum.java @@ -17,8 +17,9 @@ package inr.numass.models; import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.stat.parametric.AbstractParametricFunction; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; +import hep.dataforge.values.Values; + import static java.lang.Math.exp; import static java.lang.Math.sqrt; @@ -36,7 +37,7 @@ public class GaussSourceSpectrum extends AbstractParametricFunction implements R } @Override - public double derivValue(String parName, double E, NamedValueSet set) { + public double derivValue(String parName, double E, Values set) { switch (parName) { case "pos": return getGaussPosDeriv(E, getPos(set), getSigma(set)); @@ -61,12 +62,12 @@ public class GaussSourceSpectrum extends AbstractParametricFunction implements R } @Override - public Double max(NamedValueSet set) { + public Double max(Values set) { return getPos(set) + cutoff * getSigma(set); } @Override - public Double min(NamedValueSet set) { + public Double min(Values set) { return getPos(set) - cutoff * getSigma(set); } @@ -84,7 +85,7 @@ public class GaussSourceSpectrum extends AbstractParametricFunction implements R } @Override - public double value(final double E, NamedValueSet set) { + public double value(final double E, Values set) { return getGauss(E, getPos(set), getSigma(set)); } } diff --git a/numass-main/src/main/java/inr/numass/models/GunSpectrum.java b/numass-main/src/main/java/inr/numass/models/GunSpectrum.java index 0c3aed61..7a72b025 100644 --- a/numass-main/src/main/java/inr/numass/models/GunSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/GunSpectrum.java @@ -18,7 +18,7 @@ package inr.numass.models; import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.stat.parametric.AbstractParametricFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.UnivariateFunction; @@ -40,7 +40,7 @@ public class GunSpectrum extends AbstractParametricFunction { } @Override - public double derivValue(String parName, final double U, NamedValueSet set) { + public double derivValue(String parName, final double U, Values set) { final double pos = set.getDouble("pos"); final double sigma = set.getDouble("sigma"); final double resA = set.getDouble("resA"); @@ -132,7 +132,7 @@ public class GunSpectrum extends AbstractParametricFunction { } @Override - public double value(final double U, NamedValueSet set) { + public double value(final double U, Values set) { final double pos = set.getDouble("pos"); final double sigma = set.getDouble("sigma"); final double resA = set.getDouble("resA"); diff --git a/numass-main/src/main/java/inr/numass/models/GunTailSpectrum.java b/numass-main/src/main/java/inr/numass/models/GunTailSpectrum.java index a499ee5d..915ec5b4 100644 --- a/numass-main/src/main/java/inr/numass/models/GunTailSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/GunTailSpectrum.java @@ -17,13 +17,12 @@ package inr.numass.models; import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.names.Names; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; -import static java.lang.Math.abs; -import static java.lang.Math.exp; -import static java.lang.Math.sqrt; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.UnivariateFunction; +import static java.lang.Math.*; + public class GunTailSpectrum implements RangedNamedSetSpectrum { private final double cutoff = 4d; @@ -31,17 +30,17 @@ public class GunTailSpectrum implements RangedNamedSetSpectrum { private final String[] list = {"pos", "tailShift", "tailAmp", "sigma"}; @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { throw new NotDefinedException(); } @Override - public Double max(NamedValueSet set) { + public Double max(Values set) { return set.getDouble("pos") + cutoff * set.getDouble("sigma"); } @Override - public Double min(NamedValueSet set) { + public Double min(Values set) { return 0d; } @@ -56,7 +55,7 @@ public class GunTailSpectrum implements RangedNamedSetSpectrum { } @Override - public double value(double E, NamedValueSet set) { + public double value(double E, Values set) { double pos = set.getDouble("pos"); double amp = set.getDouble("tailAmp"); double sigma = set.getDouble("sigma"); diff --git a/numass-main/src/main/java/inr/numass/models/LossCalculator.java b/numass-main/src/main/java/inr/numass/models/LossCalculator.java index 45ba0ac6..6aa033fa 100644 --- a/numass-main/src/main/java/inr/numass/models/LossCalculator.java +++ b/numass-main/src/main/java/inr/numass/models/LossCalculator.java @@ -21,7 +21,7 @@ import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.plots.PlotFrame; import hep.dataforge.plots.data.PlottableXYFunction; import hep.dataforge.utils.Misc; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.exception.OutOfRangeException; @@ -125,7 +125,7 @@ public class LossCalculator { return (e) -> func.value(e) / norm; } - public static UnivariateFunction getSingleScatterFunction(NamedValueSet set) { + public static UnivariateFunction getSingleScatterFunction(Values set) { final double exPos = set.getDouble("exPos"); final double ionPos = set.getDouble("ionPos"); @@ -156,7 +156,7 @@ public class LossCalculator { return instance; } - public static void plotScatter(PlotFrame frame, NamedValueSet set) { + public static void plotScatter(PlotFrame frame, Values set) { //"X", "shift", "exPos", "ionPos", "exW", "ionW", "exIonRatio" // JFreeChartFrame frame = JFreeChartFrame.drawFrame("Differential scattering crosssection", null); diff --git a/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java b/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java index df37b0e7..639951d6 100644 --- a/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/ModularSpectrum.java @@ -15,16 +15,17 @@ */ package inr.numass.models; +import hep.dataforge.names.NamedUtils; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.names.NamedUtils; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; -import java.util.ArrayList; -import java.util.List; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.BivariateFunction; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.List; + /** * Modular spectrum for any source spectrum with separate calculation for * different transmission components @@ -143,7 +144,7 @@ public class ModularSpectrum extends AbstractParametricFunction { } @Override - public double derivValue(String parName, double U, NamedValueSet set) { + public double derivValue(String parName, double U, Values set) { if (U >= sourceSpectrum.max(set)) { return 0; } @@ -228,7 +229,7 @@ public class ModularSpectrum extends AbstractParametricFunction { } @Override - public double value(double U, NamedValueSet set) { + public double value(double U, Values set) { if (U >= sourceSpectrum.max(set)) { return 0; } diff --git a/numass-main/src/main/java/inr/numass/models/NBkgSpectrum.java b/numass-main/src/main/java/inr/numass/models/NBkgSpectrum.java index 3e125b21..83e45183 100644 --- a/numass-main/src/main/java/inr/numass/models/NBkgSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/NBkgSpectrum.java @@ -17,10 +17,11 @@ package inr.numass.models; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import static hep.dataforge.names.NamedUtils.combineNamesWithEquals; import hep.dataforge.utils.MultiCounter; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; +import hep.dataforge.values.Values; + +import static hep.dataforge.names.NamedUtils.combineNamesWithEquals; /** * @@ -39,7 +40,7 @@ public class NBkgSpectrum extends AbstractParametricFunction { } @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { this.counter.increase(parName); switch (parName) { case "N": @@ -72,7 +73,7 @@ public class NBkgSpectrum extends AbstractParametricFunction { } @Override - public double value(double x, NamedValueSet set) { + public double value(double x, Values set) { this.counter.increase("value"); return getN(set) * source.value(x, set) + getBkg(set); } diff --git a/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java b/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java index b5d2ec0d..02e19eaf 100644 --- a/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java +++ b/numass-main/src/main/java/inr/numass/models/NamedSpectrumCaching.java @@ -20,7 +20,7 @@ import hep.dataforge.maths.NamedVector; import hep.dataforge.names.AbstractNamedSet; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.interpolation.SplineInterpolator; import org.slf4j.LoggerFactory; @@ -64,7 +64,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { } @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { if (!isCachingEnabled()) { return source.derivValue(parName, x, set); } @@ -109,7 +109,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { return source.providesDeriv(name); } - protected boolean sameSet(NamedValueSet set1, NamedValueSet set2) { + protected boolean sameSet(Values set1, Values set2) { for (String name : this.names()) { if (!Objects.equals(set1.getDouble(name), set2.getDouble(name))) { return false; @@ -135,7 +135,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { /* * Подразумевается, что трансформация одна и та же и для спектра, и для производных. */ - protected double transformation(CacheElement cache, NamedValueSet newSet, double x) throws TransformationNotAvailable { + protected double transformation(CacheElement cache, Values newSet, double x) throws TransformationNotAvailable { /* @@ -147,7 +147,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { } @Override - public double value(double x, NamedValueSet set) { + public double value(double x, Values set) { if (!isCachingEnabled()) { return source.value(x, set); } @@ -184,10 +184,10 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { protected class CacheElement extends AbstractNamedSet implements UnivariateFunction { private UnivariateFunction cachedSpectrum; - private final NamedValueSet cachedParameters; + private final Values cachedParameters; String parName; - CacheElement(NamedValueSet parameters, String parName) { + CacheElement(Values parameters, String parName) { super(source); //на всякий случай обрезаем набор параметров до необходимого String[] names = source.namesAsArray(); @@ -196,7 +196,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { generate(func); } - CacheElement(NamedValueSet parameters) { + CacheElement(Values parameters) { super(source); String[] names = source.namesAsArray(); this.cachedParameters = new NamedVector(names, MathUtils.getDoubleArray(parameters)); @@ -224,7 +224,7 @@ public class NamedSpectrumCaching extends AbstractParametricFunction { return this.cachedSpectrum.value(x); } - public NamedValueSet getCachedParameters() { + public Values getCachedParameters() { return this.cachedParameters; } } diff --git a/numass-main/src/main/java/inr/numass/models/SimpleRange.java b/numass-main/src/main/java/inr/numass/models/SimpleRange.java index e9dc6df6..e3ac69aa 100644 --- a/numass-main/src/main/java/inr/numass/models/SimpleRange.java +++ b/numass-main/src/main/java/inr/numass/models/SimpleRange.java @@ -15,7 +15,7 @@ */ package inr.numass.models; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; /** * @@ -36,12 +36,12 @@ public class SimpleRange implements SpectrumRange{ @Override - public Double max(NamedValueSet set) { + public Double max(Values set) { return max; } @Override - public Double min(NamedValueSet set) { + public Double min(Values set) { return min; } diff --git a/numass-main/src/main/java/inr/numass/models/SpectrumRange.java b/numass-main/src/main/java/inr/numass/models/SpectrumRange.java index 6b84089b..cd77c517 100644 --- a/numass-main/src/main/java/inr/numass/models/SpectrumRange.java +++ b/numass-main/src/main/java/inr/numass/models/SpectrumRange.java @@ -15,7 +15,7 @@ */ package inr.numass.models; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; /** @@ -23,6 +23,6 @@ import hep.dataforge.values.NamedValueSet; * @author Darksnake */ public interface SpectrumRange { - Double min(NamedValueSet set); - Double max(NamedValueSet set); + Double min(Values set); + Double max(Values set); } diff --git a/numass-main/src/main/java/inr/numass/models/Transmission.java b/numass-main/src/main/java/inr/numass/models/Transmission.java index ded0d1b1..23b6c565 100644 --- a/numass-main/src/main/java/inr/numass/models/Transmission.java +++ b/numass-main/src/main/java/inr/numass/models/Transmission.java @@ -16,10 +16,9 @@ package inr.numass.models; -import hep.dataforge.stat.parametric.ParametricFunction; import hep.dataforge.names.NameSetContainer; -import hep.dataforge.values.NamedValueSet; -import hep.dataforge.values.ValueProvider; +import hep.dataforge.stat.parametric.ParametricFunction; +import hep.dataforge.values.Values; import org.apache.commons.math3.analysis.BivariateFunction; /** @@ -28,18 +27,18 @@ import org.apache.commons.math3.analysis.BivariateFunction; */ public interface Transmission extends NameSetContainer{ - double getValue(NamedValueSet set, double input, double output); - double getDeriv(String name, NamedValueSet set, double input, double output); + double getValue(Values set, double input, double output); + double getDeriv(String name, Values set, double input, double output); boolean providesDeriv(String name); ParametricFunction getConvolutedSpectrum(RangedNamedSetSpectrum bare); - default BivariateFunction getBivariateFunction(final NamedValueSet params){ + default BivariateFunction getBivariateFunction(final Values params){ return (double input, double output) -> getValue(params, input, output); } - default BivariateFunction getBivariateDerivFunction(final String name, final NamedValueSet params){ + default BivariateFunction getBivariateDerivFunction(final String name, final Values params){ return (double input, double output) -> getDeriv(name, params, input, output); } } diff --git a/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java b/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java index 7e9961a0..0398c1d4 100644 --- a/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java +++ b/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java @@ -17,7 +17,7 @@ package inr.numass.models; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; @@ -45,7 +45,7 @@ class TransmissionConvolution extends AbstractParametricFunction { } @Override - public double derivValue(final String parName, final double U, NamedValueSet set) { + public double derivValue(final String parName, final double U, Values set) { double min = range.min(set); double max = range.max(set); @@ -67,7 +67,7 @@ class TransmissionConvolution extends AbstractParametricFunction { } @Override - public double value(final double U, NamedValueSet set) { + public double value(final double U, Values set) { double min = range.min(set); double max = range.max(set); diff --git a/numass-main/src/main/java/inr/numass/models/TransmissionInterpolator.java b/numass-main/src/main/java/inr/numass/models/TransmissionInterpolator.java index e6b1b19e..85fe07d7 100644 --- a/numass-main/src/main/java/inr/numass/models/TransmissionInterpolator.java +++ b/numass-main/src/main/java/inr/numass/models/TransmissionInterpolator.java @@ -20,16 +20,17 @@ import hep.dataforge.context.Context; import hep.dataforge.data.DataNode; import hep.dataforge.io.ColumnedDataReader; import hep.dataforge.meta.Meta; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.PointSource; import hep.dataforge.tables.Table; +import hep.dataforge.values.Values; +import org.apache.commons.math3.analysis.UnivariateFunction; +import org.apache.commons.math3.analysis.interpolation.LinearInterpolator; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; -import org.apache.commons.math3.analysis.UnivariateFunction; -import org.apache.commons.math3.analysis.interpolation.LinearInterpolator; /** * @@ -61,7 +62,7 @@ public class TransmissionInterpolator implements UnivariateFunction { private double xmax; private double xmin; - private TransmissionInterpolator(Iterable data, String xName, String yName, int nSmooth, double w, double border) { + private TransmissionInterpolator(Iterable data, String xName, String yName, int nSmooth, double w, double border) { prepareXY(data, xName, yName); double[] smoothed = smoothXY(x, y, w, border); //Циклы сглаживания @@ -100,11 +101,11 @@ public class TransmissionInterpolator implements UnivariateFunction { * @param xName * @param yName */ - private void prepareXY(Iterable data, String xName, String yName) { + private void prepareXY(Iterable data, String xName, String yName) { - List points = new ArrayList<>(); + List points = new ArrayList<>(); - for (DataPoint dp : data) { + for (Values dp : data) { points.add(dp); } diff --git a/numass-main/src/main/java/inr/numass/models/TritiumSpectrumCaching.java b/numass-main/src/main/java/inr/numass/models/TritiumSpectrumCaching.java index 2215bdda..8f7c26d2 100644 --- a/numass-main/src/main/java/inr/numass/models/TritiumSpectrumCaching.java +++ b/numass-main/src/main/java/inr/numass/models/TritiumSpectrumCaching.java @@ -15,12 +15,13 @@ */ package inr.numass.models; -import hep.dataforge.stat.parametric.ParametricFunction; import hep.dataforge.maths.NamedVector; -import hep.dataforge.values.NamedValueSet; -import static java.lang.Math.abs; +import hep.dataforge.stat.parametric.ParametricFunction; +import hep.dataforge.values.Values; import org.slf4j.LoggerFactory; +import static java.lang.Math.abs; + /** * * @author Darksnake @@ -39,7 +40,7 @@ public class TritiumSpectrumCaching extends NamedSpectrumCaching { } @Override - protected double transformation(CacheElement cache, NamedValueSet newSet, double x) throws TransformationNotAvailable { + protected double transformation(CacheElement cache, Values newSet, double x) throws TransformationNotAvailable { double res; NamedVector curSet = new NamedVector(newSet); double E0new = newSet.getDouble("E0"); diff --git a/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java b/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java index 98fed436..ed3c7a45 100644 --- a/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java @@ -19,8 +19,8 @@ import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; +import hep.dataforge.values.Values; import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; @@ -43,7 +43,7 @@ public class VariableLossSpectrum extends AbstractParametricFunction { return new VariableLossSpectrum(new AbstractParametricFunction(new String[0]) { @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { throw new NotDefinedException(); } @@ -53,7 +53,7 @@ public class VariableLossSpectrum extends AbstractParametricFunction { } @Override - public double value(double x, NamedValueSet set) { + public double value(double x, Values set) { return transmission.value(x); } }, eMax); @@ -70,12 +70,12 @@ public class VariableLossSpectrum extends AbstractParametricFunction { } @Override - public double derivValue(String parName, double x, NamedValueSet set) { + public double derivValue(String parName, double x, Values set) { throw new NotDefinedException(); } @Override - public double value(double U, NamedValueSet set) { + public double value(double U, Values set) { if (U >= eMax) { return 0; } diff --git a/numass-main/src/main/java/inr/numass/models/sterile/NumassBeta.java b/numass-main/src/main/java/inr/numass/models/sterile/NumassBeta.java index 2e00c999..1a68672c 100644 --- a/numass-main/src/main/java/inr/numass/models/sterile/NumassBeta.java +++ b/numass-main/src/main/java/inr/numass/models/sterile/NumassBeta.java @@ -7,7 +7,7 @@ package inr.numass.models.sterile; import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.stat.parametric.AbstractParametricBiFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import static java.lang.Math.*; @@ -93,7 +93,7 @@ public class NumassBeta extends AbstractParametricBiFunction { * @return * @throws NotDefinedException */ - private double derivRootsterile(String name, double E, double E0, NamedValueSet pars) throws NotDefinedException { + private double derivRootsterile(String name, double E, double E0, Values pars) throws NotDefinedException { double mnu2 = getParameter("mnu2", pars); double mst2 = getParameter("msterile2", pars); double u2 = getParameter("U2", pars); @@ -180,7 +180,7 @@ public class NumassBeta extends AbstractParametricBiFunction { * @param pars * @return */ - private double rootsterile(double E, double E0, NamedValueSet pars) { + private double rootsterile(double E, double E0, Values pars) { double mnu2 = getParameter("mnu2", pars); double mst2 = getParameter("msterile2", pars); double u2 = getParameter("U2", pars); @@ -205,13 +205,13 @@ public class NumassBeta extends AbstractParametricBiFunction { } @Override - public double derivValue(String parName, double fs, double eIn, NamedValueSet pars) { + public double derivValue(String parName, double fs, double eIn, Values pars) { double E0 = getParameter("E0", pars); return derivRootsterile(parName, eIn, E0 - fs, pars); } @Override - public double value(double fs, double eIn, NamedValueSet pars) { + public double value(double fs, double eIn, Values pars) { double E0 = getParameter("E0", pars); return rootsterile(eIn, E0 - fs, pars); } diff --git a/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java b/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java index e885bc8d..c93091a6 100644 --- a/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java +++ b/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java @@ -9,7 +9,7 @@ import hep.dataforge.context.Context; import hep.dataforge.maths.MathPlugin; import hep.dataforge.meta.Meta; import hep.dataforge.stat.parametric.AbstractParametricBiFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import inr.numass.models.ResolutionFunction; import inr.numass.utils.ExpressionUtils; import org.apache.commons.math3.analysis.BivariateFunction; @@ -59,7 +59,7 @@ public class NumassResolution extends AbstractParametricBiFunction { } @Override - public double derivValue(String parName, double x, double y, NamedValueSet set) { + public double derivValue(String parName, double x, double y, Values set) { return 0; } @@ -80,7 +80,7 @@ public class NumassResolution extends AbstractParametricBiFunction { } @Override - public double value(double E, double U, NamedValueSet set) { + public double value(double E, double U, Values set) { assert resA > 0; if (resB <= 0) { return this.getValueFast(E, U); diff --git a/numass-main/src/main/java/inr/numass/models/sterile/NumassTransmission.java b/numass-main/src/main/java/inr/numass/models/sterile/NumassTransmission.java index a5b6e76f..36d025c7 100644 --- a/numass-main/src/main/java/inr/numass/models/sterile/NumassTransmission.java +++ b/numass-main/src/main/java/inr/numass/models/sterile/NumassTransmission.java @@ -9,7 +9,7 @@ import hep.dataforge.context.Context; import hep.dataforge.maths.MathPlugin; import hep.dataforge.meta.Meta; import hep.dataforge.stat.parametric.AbstractParametricBiFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import inr.numass.models.LossCalculator; import inr.numass.utils.ExpressionUtils; import org.apache.commons.math3.analysis.BivariateFunction; @@ -50,12 +50,12 @@ public class NumassTransmission extends AbstractParametricBiFunction { } } - public static double getX(double eIn, NamedValueSet set) { + public static double getX(double eIn, Values set) { //From our article return set.getDouble("X") * Math.log(eIn / ION_POTENTIAL) * eIn * ION_POTENTIAL / 1.9580741410115568e6; } - public static double p0(double eIn, NamedValueSet set) { + public static double p0(double eIn, Values set) { return LossCalculator.instance().getLossProbability(0, getX(eIn, set)); } @@ -64,7 +64,7 @@ public class NumassTransmission extends AbstractParametricBiFunction { } @Override - public double derivValue(String parName, double eIn, double eOut, NamedValueSet set) { + public double derivValue(String parName, double eIn, double eOut, Values set) { switch (parName) { case "trap": return trapFunc.value(eIn, eOut); @@ -81,7 +81,7 @@ public class NumassTransmission extends AbstractParametricBiFunction { } @Override - public double value(double eIn, double eOut, NamedValueSet set) { + public double value(double eIn, double eOut, Values set) { //calculate X taking into account its energy dependence double X = getX(eIn, set); // loss part diff --git a/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java b/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java index fc411049..048bcadb 100644 --- a/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java @@ -15,7 +15,7 @@ import hep.dataforge.meta.Meta; import hep.dataforge.stat.parametric.AbstractParametricBiFunction; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricBiFunction; -import hep.dataforge.values.NamedValueSet; +import hep.dataforge.values.Values; import inr.numass.models.FSS; import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.UnivariateFunction; @@ -89,7 +89,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { } @Override - public double derivValue(String parName, double u, NamedValueSet set) { + public double derivValue(String parName, double u, Values set) { switch (parName) { case "U2": case "msterile2": @@ -105,7 +105,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { } @Override - public double value(double u, NamedValueSet set) { + public double value(double u, Values set) { return integrate(u, source, transRes, set); } @@ -128,7 +128,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { double u, ParametricBiFunction sourceFunction, ParametricBiFunction transResFunction, - NamedValueSet set) { + Values set) { double eMax = set.getDouble("E0") + 5d; @@ -178,7 +178,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { } @Override - public double derivValue(String parName, double eIn, double u, NamedValueSet set) { + public double derivValue(String parName, double eIn, double u, Values set) { switch (parName) { case "X": //TODO implement p0 derivative @@ -191,13 +191,13 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { } @Override - public double value(double eIn, double u, NamedValueSet set) { + public double value(double eIn, double u, Values set) { double p0 = NumassTransmission.p0(eIn, set); return p0 * resolution.value(eIn, u, set) + lossRes(transmission, eIn, u, set); } - private double lossRes(ParametricBiFunction transFunc, double eIn, double u, NamedValueSet set) { + private double lossRes(ParametricBiFunction transFunc, double eIn, double u, Values set) { UnivariateFunction integrand = (eOut) -> transFunc.value(eIn, eOut, set) * resolution.value(eOut, u, set); double border = u + 30; 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 b0fa80be..353d7acf 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java @@ -23,10 +23,10 @@ import hep.dataforge.data.DataUtils; import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import hep.dataforge.workspace.AbstractTask; import hep.dataforge.workspace.TaskModel; import org.slf4j.LoggerFactory; @@ -84,8 +84,8 @@ public class NumassSubstractEmptySourceTask extends AbstractTask
{ private Table subtract(Table merge, Table empty) { ListTable.Builder builder = new ListTable.Builder(merge.getFormat()); merge.stream().forEach(point -> { - MapPoint.Builder pointBuilder = new MapPoint.Builder(point); - Optional referencePoint = empty.stream() + ValueMap.Builder pointBuilder = new ValueMap.Builder(point); + Optional referencePoint = empty.stream() .filter(p -> Math.abs(p.getDouble("Uset") - point.getDouble("Uset")) < 0.1).findFirst(); if (referencePoint.isPresent()) { pointBuilder.putValue("CR", Math.max(0, point.getDouble("CR") - referencePoint.get().getDouble("CR"))); diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java index 1b98b21e..67ee23aa 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassTableFilterTask.java @@ -7,10 +7,10 @@ import hep.dataforge.data.DataNode; import hep.dataforge.description.TypedActionDef; import hep.dataforge.meta.Laminate; import hep.dataforge.meta.MetaBuilder; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.Table; import hep.dataforge.tables.TableTransform; import hep.dataforge.values.Value; +import hep.dataforge.values.Values; import hep.dataforge.workspace.SingleActionTask; import hep.dataforge.workspace.TaskModel; import inr.numass.utils.ExpressionUtils; @@ -60,7 +60,7 @@ public class NumassTableFilterTask extends SingleActionTask { getLogger(inputMeta).debug("Filtering finished"); return TableTransform.filter(input, "Uset", uLo, uHi); } else if (inputMeta.hasValue("filter.condition")) { - Predicate predicate = (dp) -> ExpressionUtils.condition(inputMeta.getString("filter.condition"), unbox(dp)); + Predicate predicate = (dp) -> ExpressionUtils.condition(inputMeta.getString("filter.condition"), unbox(dp)); return TableTransform.filter(input, predicate); } else { throw new RuntimeException("No filtering condition specified"); @@ -68,7 +68,7 @@ public class NumassTableFilterTask extends SingleActionTask { } } - private Map unbox(DataPoint dp) { + private Map unbox(Values dp) { Map res = new HashMap<>(); for (String field : dp.names()) { Value val = dp.getValue(field); diff --git a/numass-main/src/main/java/inr/numass/utils/DataModelUtils.java b/numass-main/src/main/java/inr/numass/utils/DataModelUtils.java index 1ffe45aa..9352b5dc 100644 --- a/numass-main/src/main/java/inr/numass/utils/DataModelUtils.java +++ b/numass-main/src/main/java/inr/numass/utils/DataModelUtils.java @@ -15,10 +15,10 @@ */ package inr.numass.utils; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import inr.numass.data.SpectrumDataAdapter; import java.util.Scanner; @@ -37,7 +37,7 @@ public class DataModelUtils { for (int i = 0; i < numpoints; i++) { // формула работает даже в том случае когда порядок точек обратный double x = from + (to - from) / (numpoints - 1) * i; - DataPoint point = new MapPoint(list, x, time); + Values point = new ValueMap(list, x, time); res.row(point); } @@ -51,7 +51,7 @@ public class DataModelUtils { while (scan.hasNextLine()) { double x = scan.nextDouble(); int time = scan.nextInt(); - res.row(new MapPoint(list, x, time)); + res.row(new ValueMap(list, x, time)); } return res.build(); } diff --git a/numass-main/src/main/java/inr/numass/utils/OldDataReader.java b/numass-main/src/main/java/inr/numass/utils/OldDataReader.java index 409ded8b..7d8801ea 100644 --- a/numass-main/src/main/java/inr/numass/utils/OldDataReader.java +++ b/numass-main/src/main/java/inr/numass/utils/OldDataReader.java @@ -16,10 +16,10 @@ package inr.numass.utils; import hep.dataforge.context.Global; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import inr.numass.data.SpectrumDataAdapter; import java.io.File; @@ -51,7 +51,7 @@ public class OldDataReader { if (lineScan.hasNextDouble()) { ushift = lineScan.nextDouble(); } - DataPoint point = new MapPoint(list, u, time, ushift); + Values point = new ValueMap(list, u, time, ushift); res.row(point); } return res.build(); @@ -100,7 +100,7 @@ public class OldDataReader { dummy = sc.nextDouble(); dummy = sc.nextDouble(); dummy = sc.nextDouble(); - DataPoint point = factory.buildSpectrumDataPoint(x, count, time); + Values point = factory.buildSpectrumDataPoint(x, count, time); if (x >= Elow) { res.row(point); } @@ -134,7 +134,7 @@ public class OldDataReader { count = sc.nextLong(); dummy = sc.nextDouble(); dummy = sc.nextDouble(); - DataPoint point = factory.buildSpectrumDataPoint(x, count, time); + Values point = factory.buildSpectrumDataPoint(x, count, time); if (x > Elow) { res.row(point); } @@ -176,7 +176,7 @@ public class OldDataReader { count = lsc.nextDouble(); cr = lsc.nextDouble(); crErr = lsc.nextDouble(); - DataPoint point = factory.buildSpectrumDataPoint(x, (long) (cr * time), crErr * time, time); + Values point = factory.buildSpectrumDataPoint(x, (long) (cr * time), crErr * time, time); // SpectrumDataPoint point = new SpectrumDataPoint(x, (long) count, time); res.row(point); diff --git a/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java b/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java index e9251335..8fc56d7d 100644 --- a/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java +++ b/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java @@ -5,10 +5,10 @@ */ package inr.numass.utils; -import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.ListTable; -import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; +import hep.dataforge.tables.ValueMap; +import hep.dataforge.values.Values; import inr.numass.data.NumassPoint; import org.apache.commons.math3.analysis.ParametricUnivariateFunction; import org.apache.commons.math3.exception.DimensionMismatchException; @@ -62,13 +62,13 @@ public class UnderflowCorrection { // return builder.build(); // } - public DataPoint fitPoint(NumassPoint point, int xLow, int xHigh, int upper, int binning) { + public Values fitPoint(NumassPoint point, int xLow, int xHigh, int upper, int binning) { double norm = ((double) point.getCountInWindow(xLow, upper)) / point.getLength(); double[] fitRes = getUnderflowExpParameters(point, xLow, xHigh, binning); double a = fitRes[0]; double sigma = fitRes[1]; - return new MapPoint(pointNames, point.getVoltage(), a, sigma, a * sigma * Math.exp(xLow / sigma) / norm + 1d); + return new ValueMap(pointNames, point.getVoltage(), a, sigma, a * sigma * Math.exp(xLow / sigma) / norm + 1d); } public Table fitAllPoints(Iterable data, int xLow, int xHigh, int upper, int binning) { diff --git a/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy b/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy index 9818f70e..8d0f516e 100644 --- a/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy +++ b/numass-test/src/main/groovy/inr/numass/scripts/TestStorageAccess.groovy @@ -13,7 +13,7 @@ import hep.dataforge.meta.MetaBuilder import hep.dataforge.storage.commons.JSONMetaWriter import hep.dataforge.storage.commons.LoaderFactory import hep.dataforge.storage.commons.StorageManager -import hep.dataforge.tables.MapPoint +import hep.dataforge.tables.ValueMap import inr.numass.client.NumassClient new StorageManager().startGlobal(); @@ -38,7 +38,7 @@ new NumassClient("127.0.0.1",8335).withCloseable{ for(int i = 0; i<5; i++){ - data.putNode(DataPoint.toMeta(new MapPoint(names,i, 2*i,3*i))); + data.putNode(DataPoint.toMeta(new ValueMap(names,i, 2*i,3*i))); } diff --git a/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java b/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java index f3a72f48..30d41747 100644 --- a/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java +++ b/numass-viewer/src/main/java/inr/numass/viewer/MspViewController.java @@ -33,9 +33,9 @@ import hep.dataforge.plots.jfreechart.JFreeChartFrame; import hep.dataforge.storage.api.PointLoader; import hep.dataforge.storage.api.Storage; import hep.dataforge.storage.commons.StorageUtils; -import hep.dataforge.tables.DataPoint; -import hep.dataforge.tables.MapPoint; +import hep.dataforge.tables.ValueMap; import hep.dataforge.values.Value; +import hep.dataforge.values.Values; import javafx.application.Platform; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -133,7 +133,7 @@ public class MspViewController implements Encapsulated { Collection names = joinNames(loaders); - Stream stream = loaders.stream().flatMap(loader -> getLoaderData(loader)); + Stream stream = loaders.stream().flatMap(loader -> getLoaderData(loader)); updateMspPane(PlotDataUtils.buildGroup("timestamp", names, stream)); @@ -154,15 +154,15 @@ public class MspViewController implements Encapsulated { return nameSet; } - private Stream getLoaderData(PointLoader loader) { + private Stream getLoaderData(PointLoader loader) { try { loader.open(); - List points = new ArrayList<>(); + List points = new ArrayList<>(); // callback.updateStatus("Loading mass spectrometer data from " + loader.getName()); - DataPoint last = null; + Values last = null; - for (DataPoint dp : loader) { + for (Values dp : loader) { points.add(dp); last = dp; } @@ -241,8 +241,8 @@ public class MspViewController implements Encapsulated { * @param last * @return */ - private DataPoint terminatorPoint(DataPoint last) { - MapPoint.Builder p = new MapPoint.Builder(); + private Values terminatorPoint(Values last) { + ValueMap.Builder p = new ValueMap.Builder(); p.putValue("timestamp", last.getValue("timestamp").timeValue().plusMillis(10)); for (String name : last.namesAsArray()) { if (!name.equals("timestamp")) { diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt index 773df3df..2cbc3c6f 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt @@ -13,10 +13,10 @@ import hep.dataforge.plots.data.TimePlottable import hep.dataforge.plots.fx.PlotContainer import hep.dataforge.plots.jfreechart.JFreeChartFrame import hep.dataforge.storage.commons.JSONMetaWriter -import hep.dataforge.tables.DataPoint import hep.dataforge.tables.ListTable -import hep.dataforge.tables.MapPoint +import hep.dataforge.tables.ValueMap import hep.dataforge.tables.XYAdapter +import hep.dataforge.values.Values import inr.numass.data.NumassData import inr.numass.data.NumassDataUtils import inr.numass.data.NumassPoint @@ -254,7 +254,7 @@ class NumassLoaderView : View() { spectrumData.fillData(data.nmPoints.stream() .map { point: NumassPoint -> getSpectrumPoint(point, lowChannel, highChannel, dTime) } - .collect(Collectors.toList()) + .collect(Collectors.toList()) ) } @@ -268,9 +268,9 @@ class NumassLoaderView : View() { } - private fun getSpectrumPoint(point: NumassPoint, lowChannel: Int, upChannel: Int, dTime: Double): DataPoint { + private fun getSpectrumPoint(point: NumassPoint, lowChannel: Int, upChannel: Int, dTime: Double): Values { val u = point.voltage - return MapPoint(arrayOf(XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY, XYAdapter.Y_ERROR_KEY), u, + return ValueMap(arrayOf(XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY, XYAdapter.Y_ERROR_KEY), u, NumassDataUtils.countRateWithDeadTime(point, lowChannel, upChannel, dTime), NumassDataUtils.countRateWithDeadTimeErr(point, lowChannel, upChannel, dTime)) } diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt index dc836e74..d9e660b5 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/SlowControlView.kt @@ -9,10 +9,10 @@ import hep.dataforge.plots.fx.PlotContainer import hep.dataforge.plots.jfreechart.JFreeChartFrame import hep.dataforge.storage.api.PointLoader import hep.dataforge.storage.api.ValueIndex -import hep.dataforge.tables.DataPoint import hep.dataforge.tables.ListTable import hep.dataforge.tables.Table import hep.dataforge.tables.XYAdapter +import hep.dataforge.values.Values import tornadofx.* /** @@ -49,7 +49,7 @@ class SlowControlView : View("My View") { } private fun getData(loader: PointLoader, query: Meta = Meta.empty()): Table { - val index: ValueIndex = + val index: ValueIndex = if (query.hasValue("index")) { //use custom index if needed loader.getIndex(query.getString("index")) diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/test/JFCTest.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/test/JFCTest.kt index 898fce71..880e0754 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/test/JFCTest.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/test/JFCTest.kt @@ -3,7 +3,7 @@ package inr.numass.viewer.test import hep.dataforge.plots.data.PlottableData import hep.dataforge.plots.fx.PlotContainer import hep.dataforge.plots.jfreechart.JFreeChartFrame -import hep.dataforge.tables.MapPoint +import hep.dataforge.tables.ValueMap import hep.dataforge.tables.XYAdapter import tornadofx.* import java.util.* @@ -22,7 +22,7 @@ class JFCTest : View("My View") { action { data.fillData( - (1..1000).map { MapPoint(arrayOf(XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY), it, rnd.nextDouble()) } + (1..1000).map { ValueMap(arrayOf(XYAdapter.X_VALUE_KEY, XYAdapter.Y_VALUE_KEY), it, rnd.nextDouble()) } ) plot.add(data) }