[no commit message]
This commit is contained in:
parent
ce626fdb25
commit
3a10cc0672
@ -16,8 +16,8 @@ dependencies {
|
|||||||
compile group: 'commons-io', name: 'commons-io', version:'2.+'
|
compile group: 'commons-io', name: 'commons-io', version:'2.+'
|
||||||
compile project(':dataforge-fitting:dataforge-minuit')
|
compile project(':dataforge-fitting:dataforge-minuit')
|
||||||
compile project(':dataforge-fx')
|
compile project(':dataforge-fx')
|
||||||
compile project(':dataforge-grind')
|
|
||||||
compile project(':dataforge-plots')
|
compile project(':dataforge-plots')
|
||||||
|
compile project(':numass-storage')
|
||||||
}
|
}
|
||||||
|
|
||||||
task runNumass(dependsOn: classes, type : JavaExec){
|
task runNumass(dependsOn: classes, type : JavaExec){
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2015 Alexander Nozik.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
@ -20,9 +20,9 @@ import hep.dataforge.data.binary.Binary;
|
|||||||
import hep.dataforge.io.BasicIOManager;
|
import hep.dataforge.io.BasicIOManager;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.names.Name;
|
import hep.dataforge.names.Name;
|
||||||
import inr.numass.data.NumassDataReader;
|
import inr.numass.storage.NumassDataReader;
|
||||||
import inr.numass.data.NumassPawReader;
|
import inr.numass.data.NumassPawReader;
|
||||||
import inr.numass.data.RawNMFile;
|
import inr.numass.storage.RawNMFile;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
32
numass-main/src/main/java/inr/numass/WorkspaceTest.java
Normal file
32
numass-main/src/main/java/inr/numass/WorkspaceTest.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package inr.numass;
|
||||||
|
|
||||||
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
|
import hep.dataforge.storage.commons.StorageDataFactory;
|
||||||
|
import hep.dataforge.workspace.BasicWorkspace;
|
||||||
|
import hep.dataforge.workspace.Workspace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexander Nozik
|
||||||
|
*/
|
||||||
|
public class WorkspaceTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args the command line arguments
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
String storagepath = "D:\\Work\\Numass\\data\\";
|
||||||
|
Workspace workspace = BasicWorkspace.builder()
|
||||||
|
.setContext(new NumassContext())
|
||||||
|
.loadData("", new StorageDataFactory(), new MetaBuilder("storage").putValue("path", storagepath))
|
||||||
|
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,8 +18,8 @@ package inr.numass.actions;
|
|||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
||||||
import hep.dataforge.tables.SimplePointSource;
|
import hep.dataforge.tables.SimplePointSource;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ import hep.dataforge.description.ValueDef;
|
|||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.reports.Reportable;
|
import hep.dataforge.io.reports.Reportable;
|
||||||
import hep.dataforge.meta.Laminate;
|
import hep.dataforge.meta.Laminate;
|
||||||
import inr.numass.data.RawNMFile;
|
import inr.numass.storage.RawNMFile;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import inr.numass.debunch.DebunchReport;
|
import inr.numass.debunch.DebunchReport;
|
||||||
import inr.numass.debunch.FrameAnalizer;
|
import inr.numass.debunch.FrameAnalizer;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
@ -22,8 +22,8 @@ import hep.dataforge.exceptions.ContentException;
|
|||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.io.reports.Reportable;
|
import hep.dataforge.io.reports.Reportable;
|
||||||
import hep.dataforge.meta.Laminate;
|
import hep.dataforge.meta.Laminate;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,9 +30,9 @@ import hep.dataforge.tables.ListTable;
|
|||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.tables.TableFormat;
|
import hep.dataforge.tables.TableFormat;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -25,8 +25,8 @@ import hep.dataforge.exceptions.ContentException;
|
|||||||
import hep.dataforge.io.reports.Reportable;
|
import hep.dataforge.io.reports.Reportable;
|
||||||
import hep.dataforge.meta.Laminate;
|
import hep.dataforge.meta.Laminate;
|
||||||
import static inr.numass.NumassIO.getNumassData;
|
import static inr.numass.NumassIO.getNumassData;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.data.RawNMFile;
|
import inr.numass.storage.RawNMFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -26,8 +26,8 @@ import hep.dataforge.meta.Meta;
|
|||||||
import hep.dataforge.plots.fx.FXPlotUtils;
|
import hep.dataforge.plots.fx.FXPlotUtils;
|
||||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||||
import inr.numass.data.ESpectrum;
|
import inr.numass.data.ESpectrum;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -19,8 +19,8 @@ import hep.dataforge.tables.MapPoint;
|
|||||||
import hep.dataforge.tables.SimplePointSource;
|
import hep.dataforge.tables.SimplePointSource;
|
||||||
import hep.dataforge.tables.TableFormat;
|
import hep.dataforge.tables.TableFormat;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -23,8 +23,8 @@ import hep.dataforge.io.ColumnedDataWriter;
|
|||||||
import hep.dataforge.io.reports.Reportable;
|
import hep.dataforge.io.reports.Reportable;
|
||||||
import hep.dataforge.meta.Laminate;
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.storage.NMFile;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.data;
|
||||||
|
|
||||||
|
import inr.numass.storage.NMPoint;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
||||||
import hep.dataforge.tables.SimplePointSource;
|
import hep.dataforge.tables.SimplePointSource;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.data;
|
||||||
|
|
||||||
|
import inr.numass.storage.RawNMFile;
|
||||||
import hep.dataforge.data.binary.Binary;
|
import hep.dataforge.data.binary.Binary;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -13,195 +13,195 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.debunch;
|
package inr.numass.debunch;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Хранит сортированный набор событий с возможностью вырезать куски и склеивать
|
* Хранит сортированный набор событий с возможностью вырезать куски и склеивать
|
||||||
* концы
|
* концы
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
class DebunchData {
|
class DebunchData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Удаляет из листа события в определенном диапазоне времени. При этом общее
|
* Удаляет из листа события в определенном диапазоне времени. При этом общее
|
||||||
* время не изменяется, поэтому скорость счета меняется. Возвращает
|
* время не изменяется, поэтому скорость счета меняется. Возвращает
|
||||||
* количество удаленных событий.
|
* количество удаленных событий.
|
||||||
*
|
*
|
||||||
* @param from
|
* @param from
|
||||||
* @param to
|
* @param to
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static List<NMEvent> removeFrame(List<NMEvent> events, Frame frame) {
|
private static List<NMEvent> removeFrame(List<NMEvent> events, Frame frame) {
|
||||||
List<NMEvent> res = new ArrayList<>();
|
List<NMEvent> res = new ArrayList<>();
|
||||||
for (NMEvent event : events) {
|
for (NMEvent event : events) {
|
||||||
if (event.getTime() >= frame.getEnd()) {
|
if (event.getTime() >= frame.getEnd()) {
|
||||||
res.add(new NMEvent(event.getChanel(), event.getTime() - frame.length()));
|
res.add(new NMEvent(event.getChanel(), event.getTime() - frame.length()));
|
||||||
} else if (event.getTime() <= frame.getBegin()) {
|
} else if (event.getTime() <= frame.getBegin()) {
|
||||||
res.add(event);
|
res.add(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List<Frame> bunches = new ArrayList<>();
|
private final List<Frame> bunches = new ArrayList<>();
|
||||||
private final List<NMEvent> events;
|
private final List<NMEvent> events;
|
||||||
private final double length;
|
private final double length;
|
||||||
|
|
||||||
public DebunchData(RawNMPoint point) {
|
public DebunchData(RawNMPoint point) {
|
||||||
events = point.getEvents();
|
events = point.getEvents();
|
||||||
Collections.sort(events, new EventComparator());
|
Collections.sort(events, new EventComparator());
|
||||||
length = point.getLength();
|
length = point.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Frame countInFrame(double start, double length, int lowerChanel, int upperChanel) {
|
public Frame countInFrame(double start, double length, int lowerChanel, int upperChanel) {
|
||||||
double end;
|
double end;
|
||||||
|
|
||||||
if (start + length < this.getLength()) {
|
if (start + length < this.getLength()) {
|
||||||
end = start + length;
|
end = start + length;
|
||||||
} else {
|
} else {
|
||||||
end = this.getLength();
|
end = this.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<NMEvent> sum = new ArrayList<>();
|
ArrayList<NMEvent> sum = new ArrayList<>();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((i < this.size()) && (events.get(i).getTime() < start)) {
|
while ((i < this.size()) && (events.get(i).getTime() < start)) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
while ((i < this.size()) && (events.get(i).getTime() < end)) {
|
while ((i < this.size()) && (events.get(i).getTime() < end)) {
|
||||||
if ((events.get(i).getChanel() >= lowerChanel) && (events.get(i).getChanel() <= upperChanel)) {
|
if ((events.get(i).getChanel() >= lowerChanel) && (events.get(i).getChanel() <= upperChanel)) {
|
||||||
sum.add(getEvents().get(i));
|
sum.add(getEvents().get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Frame(start, end, sum);
|
return new Frame(start, end, sum);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as CountInFrame, but it does not copy all of the event times, only
|
* Same as CountInFrame, but it does not copy all of the event times, only
|
||||||
* total count in frame.
|
* total count in frame.
|
||||||
*
|
*
|
||||||
* @param start
|
* @param start
|
||||||
* @param length
|
* @param length
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Frame countInFrameFast(double start, double length, int lowerChanel, int upperChanel) {
|
public Frame countInFrameFast(double start, double length, int lowerChanel, int upperChanel) {
|
||||||
//PENDING самый долгий метод
|
//PENDING самый долгий метод
|
||||||
if (start > this.getLength()) {
|
if (start > this.getLength()) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
double end;
|
double end;
|
||||||
|
|
||||||
if (start + length < this.getLength()) {
|
if (start + length < this.getLength()) {
|
||||||
end = start + length;
|
end = start + length;
|
||||||
} else {
|
} else {
|
||||||
end = this.getLength();
|
end = this.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sumCount = 0;
|
int sumCount = 0;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((i < this.size()) && (events.get(i).getTime() < start)) {
|
while ((i < this.size()) && (events.get(i).getTime() < start)) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
while ((i < this.size()) && (events.get(i).getTime() < end)) {
|
while ((i < this.size()) && (events.get(i).getTime() < end)) {
|
||||||
if ((events.get(i).getChanel() >= lowerChanel) && (events.get(i).getChanel() <= upperChanel)) {
|
if ((events.get(i).getChanel() >= lowerChanel) && (events.get(i).getChanel() <= upperChanel)) {
|
||||||
sumCount++;
|
sumCount++;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Frame(start, end, sumCount);
|
return new Frame(start, end, sumCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Frame> getBunches() {
|
public List<Frame> getBunches() {
|
||||||
return bunches;
|
return bunches;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Возвращает скорректированную скорость счета по всему интервалу
|
* Возвращает скорректированную скорость счета по всему интервалу
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double getCountRate() {
|
public double getCountRate() {
|
||||||
return this.size() / this.getLength();
|
return this.size() / this.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Медленный метод, вызывать минимальное количество рах
|
* Медленный метод, вызывать минимальное количество рах
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<NMEvent> getDebunchedEvents() {
|
public List<NMEvent> getDebunchedEvents() {
|
||||||
List<NMEvent> res = getEvents();
|
List<NMEvent> res = getEvents();
|
||||||
for (Frame frame : getBunches()) {
|
for (Frame frame : getBunches()) {
|
||||||
res = removeFrame(res, frame);
|
res = removeFrame(res, frame);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Медленный метод, вызывать минимальное количество рах
|
* Медленный метод, вызывать минимальное количество рах
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double getDebunchedLength() {
|
public double getDebunchedLength() {
|
||||||
double res = length;
|
double res = length;
|
||||||
for (Frame frame : getBunches()) {
|
for (Frame frame : getBunches()) {
|
||||||
res -= frame.length();
|
res -= frame.length();
|
||||||
}
|
}
|
||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Zero length point after debunching");
|
throw new RuntimeException("Zero length point after debunching");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<NMEvent> getEvents() {
|
public List<NMEvent> getEvents() {
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the length
|
* @return the length
|
||||||
*/
|
*/
|
||||||
public double getLength() {
|
public double getLength() {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAsBunch(Frame bunch) {
|
public void setAsBunch(Frame bunch) {
|
||||||
//FIXME сделать проверку пересечения кадров
|
//FIXME сделать проверку пересечения кадров
|
||||||
this.bunches.add(bunch);
|
this.bunches.add(bunch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAsBunch(double from, double to) {
|
public void setAsBunch(double from, double to) {
|
||||||
assert to > from;
|
assert to > from;
|
||||||
setAsBunch(countInFrame(from, to - from,0, RawNMPoint.MAX_CHANEL));
|
setAsBunch(countInFrame(from, to - from,0, RawNMPoint.MAX_CHANEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
public long size() {
|
public long size() {
|
||||||
return this.getEvents().size();
|
return this.getEvents().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EventComparator implements Comparator<NMEvent> {
|
private static class EventComparator implements Comparator<NMEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(NMEvent o1, NMEvent o2) {
|
public int compare(NMEvent o1, NMEvent o2) {
|
||||||
return (int) Math.signum(o1.getTime() - o2.getTime());
|
return (int) Math.signum(o1.getTime() - o2.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,66 +13,66 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.debunch;
|
package inr.numass.debunch;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class DebunchEvent extends NMEvent {
|
public class DebunchEvent extends NMEvent {
|
||||||
|
|
||||||
public static double getEventWeight(NMEvent event) {
|
public static double getEventWeight(NMEvent event) {
|
||||||
if (event instanceof DebunchEvent) {
|
if (event instanceof DebunchEvent) {
|
||||||
return ((DebunchEvent) event).getWeight();
|
return ((DebunchEvent) event).getWeight();
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double shift = 0;
|
private double shift = 0;
|
||||||
/**
|
/**
|
||||||
* В общем случае принимает значение от 0 (событие полностью выкинуто) до
|
* В общем случае принимает значение от 0 (событие полностью выкинуто) до
|
||||||
* 1(событие полностью принято)
|
* 1(событие полностью принято)
|
||||||
*/
|
*/
|
||||||
private double weight;
|
private double weight;
|
||||||
|
|
||||||
public DebunchEvent(NMEvent event, double weight) {
|
public DebunchEvent(NMEvent event, double weight) {
|
||||||
super(event.getChanel(), event.getTime());
|
super(event.getChanel(), event.getTime());
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DebunchEvent(double weight, double shift, short chanel, double time) {
|
protected DebunchEvent(double weight, double shift, short chanel, double time) {
|
||||||
super(chanel, time);
|
super(chanel, time);
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.shift = shift;
|
this.shift = shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DebunchEvent clone() {
|
public DebunchEvent clone() {
|
||||||
return new DebunchEvent(weight, shift, chanel, time);
|
return new DebunchEvent(weight, shift, chanel, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getTime() {
|
public double getTime() {
|
||||||
return super.getTime() + shift;
|
return super.getTime() + shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getWeight() {
|
public double getWeight() {
|
||||||
return this.weight;
|
return this.weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param marker
|
* @param marker
|
||||||
*/
|
*/
|
||||||
public void setWeight(int marker){
|
public void setWeight(int marker){
|
||||||
this.weight = marker;
|
this.weight = marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shiftTime(double shift) {
|
public void shiftTime(double shift) {
|
||||||
this.shift += shift;
|
this.shift += shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,23 +13,23 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.debunch;
|
package inr.numass.debunch;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public interface DebunchReport {
|
public interface DebunchReport {
|
||||||
RawNMPoint getInitialPoint();
|
RawNMPoint getInitialPoint();
|
||||||
RawNMPoint getPoint();
|
RawNMPoint getPoint();
|
||||||
|
|
||||||
List<Frame> getBunches();
|
List<Frame> getBunches();
|
||||||
List<NMEvent> getBunchEvents();
|
List<NMEvent> getBunchEvents();
|
||||||
|
|
||||||
double eventsFiltred();
|
double eventsFiltred();
|
||||||
double timeFiltred();
|
double timeFiltred();
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.debunch;
|
package inr.numass.debunch;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.debunch;
|
package inr.numass.debunch;
|
||||||
|
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public interface Debuncher {
|
public interface Debuncher {
|
||||||
DebunchReport debunchPoint(RawNMPoint point);
|
DebunchReport debunchPoint(RawNMPoint point);
|
||||||
}
|
}
|
||||||
|
@ -13,89 +13,89 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.debunch;
|
package inr.numass.debunch;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.commons.math3.distribution.PoissonDistribution;
|
import org.apache.commons.math3.distribution.PoissonDistribution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class Frame {
|
public class Frame {
|
||||||
|
|
||||||
private final double begin;
|
private final double begin;
|
||||||
private final double end;
|
private final double end;
|
||||||
private List<NMEvent> events;
|
private List<NMEvent> events;
|
||||||
private final int eventsCount;
|
private final int eventsCount;
|
||||||
|
|
||||||
public Frame(double begin, double end, List<NMEvent> events) {
|
public Frame(double begin, double end, List<NMEvent> events) {
|
||||||
assert end > begin;
|
assert end > begin;
|
||||||
this.begin = begin;
|
this.begin = begin;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.events = events;
|
this.events = events;
|
||||||
this.eventsCount = events.size();
|
this.eventsCount = events.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Сокращенная версия для экономии памяти
|
* Сокращенная версия для экономии памяти
|
||||||
*
|
*
|
||||||
* @param begin
|
* @param begin
|
||||||
* @param end
|
* @param end
|
||||||
* @param count
|
* @param count
|
||||||
*/
|
*/
|
||||||
public Frame(double begin, double end, int count) {
|
public Frame(double begin, double end, int count) {
|
||||||
assert end > begin;
|
assert end > begin;
|
||||||
this.begin = begin;
|
this.begin = begin;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.eventsCount = count;
|
this.eventsCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Frame cloneFast() {
|
public Frame cloneFast() {
|
||||||
return new Frame(begin, end, eventsCount);
|
return new Frame(begin, end, eventsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBegin() {
|
public double getBegin() {
|
||||||
return begin;
|
return begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
if (this.events != null) {
|
if (this.events != null) {
|
||||||
return events.size();
|
return events.size();
|
||||||
} else {
|
} else {
|
||||||
return eventsCount;
|
return eventsCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCountRate(){
|
public double getCountRate(){
|
||||||
return this.getCount() / this.length();
|
return this.getCount() / this.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCountRateError(){
|
public double getCountRateError(){
|
||||||
return Math.sqrt(this.getCount()) / this.length();
|
return Math.sqrt(this.getCount()) / this.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getEnd() {
|
public double getEnd() {
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<NMEvent> getEvents() {
|
public List<NMEvent> getEvents() {
|
||||||
if(events!=null)
|
if(events!=null)
|
||||||
return events;
|
return events;
|
||||||
else
|
else
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getProbability(double cr){
|
public double getProbability(double cr){
|
||||||
PoissonDistribution distr = new PoissonDistribution(cr * this.length());
|
PoissonDistribution distr = new PoissonDistribution(cr * this.length());
|
||||||
return distr.probability(getCount());
|
return distr.probability(getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double length() {
|
public double length() {
|
||||||
assert this.end > this.begin;
|
assert this.end > this.begin;
|
||||||
return this.end - this.begin;
|
return this.end - this.begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,230 +13,230 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.debunch;
|
package inr.numass.debunch;
|
||||||
|
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||||
import org.apache.commons.math3.analysis.interpolation.LinearInterpolator;
|
import org.apache.commons.math3.analysis.interpolation.LinearInterpolator;
|
||||||
import org.apache.commons.math3.util.FastMath;
|
import org.apache.commons.math3.util.FastMath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class FrameAnalizer implements Debuncher {
|
public class FrameAnalizer implements Debuncher {
|
||||||
|
|
||||||
private static final double POISSON_THRESHOLD = 1e-80;
|
private static final double POISSON_THRESHOLD = 1e-80;
|
||||||
|
|
||||||
static double getGaussianCRThreshold(double cr, double frameLength, double prob) {
|
static double getGaussianCRThreshold(double cr, double frameLength, double prob) {
|
||||||
double[] xs = {9, 8, 7, 6, 5, 4, 3, 2, 1};
|
double[] xs = {9, 8, 7, 6, 5, 4, 3, 2, 1};
|
||||||
double[] probs = {1.15e-19, 6.22e-16, 1.27e-12, 9.86e-10, 2.86e-7, 3.167e-5, 0.001349, 0.0227, 0.1586};
|
double[] probs = {1.15e-19, 6.22e-16, 1.27e-12, 9.86e-10, 2.86e-7, 3.167e-5, 0.001349, 0.0227, 0.1586};
|
||||||
LinearInterpolator interpolator = new LinearInterpolator();
|
LinearInterpolator interpolator = new LinearInterpolator();
|
||||||
UnivariateFunction function = interpolator.interpolate(probs, xs);
|
UnivariateFunction function = interpolator.interpolate(probs, xs);
|
||||||
double sigmas = function.value(prob);
|
double sigmas = function.value(prob);
|
||||||
return cr + sigmas * Math.sqrt(cr / frameLength);
|
return cr + sigmas * Math.sqrt(cr / frameLength);
|
||||||
}
|
}
|
||||||
//double frameShift;
|
//double frameShift;
|
||||||
double frameLength;
|
double frameLength;
|
||||||
int lowerChanel = 0;
|
int lowerChanel = 0;
|
||||||
|
|
||||||
int numCircles = 1;
|
int numCircles = 1;
|
||||||
double rejectionProb;
|
double rejectionProb;
|
||||||
int upperChanel = RawNMPoint.MAX_CHANEL;
|
int upperChanel = RawNMPoint.MAX_CHANEL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public FrameAnalizer(double rejectionProb, double frameLength) {
|
public FrameAnalizer(double rejectionProb, double frameLength) {
|
||||||
this.rejectionProb = rejectionProb;
|
this.rejectionProb = rejectionProb;
|
||||||
this.frameLength = frameLength;
|
this.frameLength = frameLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FrameAnalizer(double rejectionProb, double frameLength, int lower, int upper) {
|
public FrameAnalizer(double rejectionProb, double frameLength, int lower, int upper) {
|
||||||
assert upper > lower;
|
assert upper > lower;
|
||||||
this.rejectionProb = rejectionProb;
|
this.rejectionProb = rejectionProb;
|
||||||
this.frameLength = frameLength;
|
this.frameLength = frameLength;
|
||||||
this.lowerChanel = lower;
|
this.lowerChanel = lower;
|
||||||
this.upperChanel = upper;
|
this.upperChanel = upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FrameAnalizer(double rejectionProb, double frameLength, int numCircles) {
|
public FrameAnalizer(double rejectionProb, double frameLength, int numCircles) {
|
||||||
this.rejectionProb = rejectionProb;
|
this.rejectionProb = rejectionProb;
|
||||||
this.frameLength = frameLength;
|
this.frameLength = frameLength;
|
||||||
this.numCircles = numCircles;
|
this.numCircles = numCircles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Полный аналог Сережиной программы
|
* Полный аналог Сережиной программы
|
||||||
*
|
*
|
||||||
* @param numCicles
|
* @param numCicles
|
||||||
* @param prob
|
* @param prob
|
||||||
* @param frameShift
|
* @param frameShift
|
||||||
* @param frameLength
|
* @param frameLength
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private DebunchReport cicledDebunch(RawNMPoint point, int numCicles, double prob, double frameShift, double frameLength) {
|
private DebunchReport cicledDebunch(RawNMPoint point, int numCicles, double prob, double frameShift, double frameLength) {
|
||||||
DebunchReport res = this.debunch(point, prob, frameShift, frameLength);
|
DebunchReport res = this.debunch(point, prob, frameShift, frameLength);
|
||||||
for (int i = 0; i < numCicles-1; i++) {
|
for (int i = 0; i < numCicles-1; i++) {
|
||||||
res = this.debunch(res, prob, frameShift, frameLength);
|
res = this.debunch(res, prob, frameShift, frameLength);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DebunchReport debunch(DebunchReport res, double prob, double frameShift, double frameLength) {
|
private DebunchReport debunch(DebunchReport res, double prob, double frameShift, double frameLength) {
|
||||||
return debunch(res.getPoint(), prob, frameShift, frameLength);
|
return debunch(res.getPoint(), prob, frameShift, frameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DebunchReport debunch(RawNMPoint point, double prob, double frameShift, double frameLength) {
|
private DebunchReport debunch(RawNMPoint point, double prob, double frameShift, double frameLength) {
|
||||||
double cr = point.selectChanels(lowerChanel, upperChanel).getCR();
|
double cr = point.selectChanels(lowerChanel, upperChanel).getCR();
|
||||||
return debunch(point, cr, prob, frameShift, frameLength);
|
return debunch(point, cr, prob, frameShift, frameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DebunchReport debunch(RawNMPoint point, double averageCR, double prob, double frameShift, double frameLength) {
|
private DebunchReport debunch(RawNMPoint point, double averageCR, double prob, double frameShift, double frameLength) {
|
||||||
|
|
||||||
DebunchData data = new DebunchData(point);
|
DebunchData data = new DebunchData(point);
|
||||||
|
|
||||||
double timeTotal = data.getLength();
|
double timeTotal = data.getLength();
|
||||||
// long countTotal = data.size();
|
// long countTotal = data.size();
|
||||||
|
|
||||||
double curPos = 0;
|
double curPos = 0;
|
||||||
double baseThreshold = getCRThreshold(averageCR, frameLength, prob);
|
double baseThreshold = getCRThreshold(averageCR, frameLength, prob);
|
||||||
Frame workFrame;
|
Frame workFrame;
|
||||||
boolean bunchFlag = false;// Флаг символизирует, находимся ли мы в состоянии пачки
|
boolean bunchFlag = false;// Флаг символизирует, находимся ли мы в состоянии пачки
|
||||||
|
|
||||||
while (curPos < (data.getLength() - frameLength)) {
|
while (curPos < (data.getLength() - frameLength)) {
|
||||||
workFrame = data.countInFrameFast(curPos, frameLength,lowerChanel,upperChanel);
|
workFrame = data.countInFrameFast(curPos, frameLength,lowerChanel,upperChanel);
|
||||||
|
|
||||||
if (workFrame.getCountRate() > baseThreshold) {
|
if (workFrame.getCountRate() > baseThreshold) {
|
||||||
/*
|
/*
|
||||||
* Если счет в рамке превышает порог, то выкидываем рамку из результата и сдвигаем
|
* Если счет в рамке превышает порог, то выкидываем рамку из результата и сдвигаем
|
||||||
* каретку на один шаг. При этом выставляем флаг.
|
* каретку на один шаг. При этом выставляем флаг.
|
||||||
* Если видим флаг,то вырезаем только последний шаг, чтобы избежать двойного вырезания
|
* Если видим флаг,то вырезаем только последний шаг, чтобы избежать двойного вырезания
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (bunchFlag) {
|
if (bunchFlag) {
|
||||||
/*Тут возможен косяк, когда две пачки рядом, но не вплотную. Можно сделать
|
/*Тут возможен косяк, когда две пачки рядом, но не вплотную. Можно сделать
|
||||||
* так, чтобы запоминалось не состояние флага, а конец последнего вырезанного кадра
|
* так, чтобы запоминалось не состояние флага, а конец последнего вырезанного кадра
|
||||||
*/
|
*/
|
||||||
workFrame = data.countInFrameFast(curPos + frameLength - frameShift, frameShift,lowerChanel,upperChanel);
|
workFrame = data.countInFrameFast(curPos + frameLength - frameShift, frameShift,lowerChanel,upperChanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.setAsBunch(workFrame);
|
data.setAsBunch(workFrame);
|
||||||
timeTotal -= workFrame.length();
|
timeTotal -= workFrame.length();
|
||||||
if (timeTotal <= 0) {
|
if (timeTotal <= 0) {
|
||||||
throw new RuntimeException("Total time after cleaning is zero.");
|
throw new RuntimeException("Total time after cleaning is zero.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bunchFlag = true;
|
bunchFlag = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Если пачки нет, то просто сдвигаем каретку к следующей рамке и убираем флаг
|
* Если пачки нет, то просто сдвигаем каретку к следующей рамке и убираем флаг
|
||||||
*/
|
*/
|
||||||
bunchFlag = false;
|
bunchFlag = false;
|
||||||
}
|
}
|
||||||
curPos += frameShift;
|
curPos += frameShift;
|
||||||
}
|
}
|
||||||
return new DebunchReportImpl(point, data);
|
return new DebunchReportImpl(point, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DebunchReport debunchPoint(RawNMPoint point) {
|
public DebunchReport debunchPoint(RawNMPoint point) {
|
||||||
return cicledDebunch(point, numCircles, rejectionProb, frameLength/4, frameLength);
|
return cicledDebunch(point, numCircles, rejectionProb, frameLength/4, frameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getCRThreshold(double cr, double frameLength, double prob) {
|
private double getCRThreshold(double cr, double frameLength, double prob) {
|
||||||
if (cr * frameLength > 20) {
|
if (cr * frameLength > 20) {
|
||||||
return getGaussianCRThreshold(cr, frameLength, prob);
|
return getGaussianCRThreshold(cr, frameLength, prob);
|
||||||
} else {
|
} else {
|
||||||
return getPoissonThreshold(cr * frameLength, prob) / frameLength;
|
return getPoissonThreshold(cr * frameLength, prob) / frameLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns set of intervals begining with frameStarts[i]. All FrameStart
|
* Returns set of intervals begining with frameStarts[i]. All FrameStart
|
||||||
* should be inside data region
|
* should be inside data region
|
||||||
*
|
*
|
||||||
* @param frameStarts
|
* @param frameStarts
|
||||||
* @param frameLength
|
* @param frameLength
|
||||||
* @param fast
|
* @param fast
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Frame[] getIntervals(DebunchData data, double[] frameStarts, double frameLength, boolean fast) {
|
private Frame[] getIntervals(DebunchData data, double[] frameStarts, double frameLength, boolean fast) {
|
||||||
Frame[] res = new Frame[frameStarts.length];
|
Frame[] res = new Frame[frameStarts.length];
|
||||||
|
|
||||||
for (int i = 0; i < frameStarts.length; i++) {
|
for (int i = 0; i < frameStarts.length; i++) {
|
||||||
if (fast) {
|
if (fast) {
|
||||||
res[i] = data.countInFrameFast(frameStarts[i], frameLength,lowerChanel,upperChanel);
|
res[i] = data.countInFrameFast(frameStarts[i], frameLength,lowerChanel,upperChanel);
|
||||||
} else {
|
} else {
|
||||||
res[i] = data.countInFrame(frameStarts[i], frameLength,lowerChanel,upperChanel);
|
res[i] = data.countInFrame(frameStarts[i], frameLength,lowerChanel,upperChanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns count rate in consequent frames with the length of frameLength.
|
* Returns count rate in consequent frames with the length of frameLength.
|
||||||
* The last frame could be shorter than the overs. This method could be used
|
* The last frame could be shorter than the overs. This method could be used
|
||||||
* for fast distribution calculation.
|
* for fast distribution calculation.
|
||||||
*
|
*
|
||||||
* @param frameLength
|
* @param frameLength
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private double[] getNonIntercectFramesCountRate(DebunchData data, double frameLength) {
|
private double[] getNonIntercectFramesCountRate(DebunchData data, double frameLength) {
|
||||||
double dataLength = data.getLength();
|
double dataLength = data.getLength();
|
||||||
int maxFramesCount = (int) Math.ceil(dataLength / frameLength);
|
int maxFramesCount = (int) Math.ceil(dataLength / frameLength);
|
||||||
if (maxFramesCount < 2) {
|
if (maxFramesCount < 2) {
|
||||||
throw new IllegalArgumentException("The frameLength is too large.");
|
throw new IllegalArgumentException("The frameLength is too large.");
|
||||||
}
|
}
|
||||||
|
|
||||||
double[] res = new double[maxFramesCount];
|
double[] res = new double[maxFramesCount];
|
||||||
double frameBegin;
|
double frameBegin;
|
||||||
|
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
frameBegin = i * frameLength;
|
frameBegin = i * frameLength;
|
||||||
res[i] = data.countInFrameFast(frameBegin, frameLength,lowerChanel,upperChanel).getCountRate();
|
res[i] = data.countInFrameFast(frameBegin, frameLength,lowerChanel,upperChanel).getCountRate();
|
||||||
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPoissonThreshold(double mean, double prob) {
|
private int getPoissonThreshold(double mean, double prob) {
|
||||||
/*
|
/*
|
||||||
* Находим точку "обнуления" распределения и значения коммулятивной плотности в этой точке.
|
* Находим точку "обнуления" распределения и значения коммулятивной плотности в этой точке.
|
||||||
*/
|
*/
|
||||||
double pdf = FastMath.exp(-mean);
|
double pdf = FastMath.exp(-mean);
|
||||||
double cdf = pdf;
|
double cdf = pdf;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
while (pdf > POISSON_THRESHOLD) {
|
while (pdf > POISSON_THRESHOLD) {
|
||||||
k++;
|
k++;
|
||||||
pdf *= mean / k;
|
pdf *= mean / k;
|
||||||
cdf += pdf;
|
cdf += pdf;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Начинаем считать комулятивную плотность в обратном порядке
|
* Начинаем считать комулятивную плотность в обратном порядке
|
||||||
*/
|
*/
|
||||||
cdf = 1 - cdf;
|
cdf = 1 - cdf;
|
||||||
if (pdf <= 0) {
|
if (pdf <= 0) {
|
||||||
throw new Error();// Проверяем чтобы там точно не было нуля;
|
throw new Error();// Проверяем чтобы там точно не было нуля;
|
||||||
}
|
}
|
||||||
while (cdf < prob) {
|
while (cdf < prob) {
|
||||||
k--;
|
k--;
|
||||||
pdf *= k / mean;
|
pdf *= k / mean;
|
||||||
cdf += pdf;
|
cdf += pdf;
|
||||||
}
|
}
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Frame[] getUniformShiftedIntervals(DebunchData data, double frameShift, double frameLength, boolean fast) {
|
private Frame[] getUniformShiftedIntervals(DebunchData data, double frameShift, double frameLength, boolean fast) {
|
||||||
double dataLength = data.getLength();
|
double dataLength = data.getLength();
|
||||||
int maxFramesCount = (int) Math.ceil(dataLength / frameShift);
|
int maxFramesCount = (int) Math.ceil(dataLength / frameShift);
|
||||||
|
|
||||||
double[] frameStarts = new double[maxFramesCount];
|
double[] frameStarts = new double[maxFramesCount];
|
||||||
for (int i = 0; i < frameStarts.length; i++) {
|
for (int i = 0; i < frameStarts.length; i++) {
|
||||||
frameStarts[i] = i * frameShift;
|
frameStarts[i] = i * frameShift;
|
||||||
|
|
||||||
}
|
}
|
||||||
return getIntervals(data, frameStarts, frameLength, fast);
|
return getIntervals(data, frameStarts, frameLength, fast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,192 +13,192 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.generators;
|
package inr.numass.generators;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.apache.commons.math3.random.MersenneTwister;
|
import org.apache.commons.math3.random.MersenneTwister;
|
||||||
import org.apache.commons.math3.random.RandomGenerator;
|
import org.apache.commons.math3.random.RandomGenerator;
|
||||||
import org.apache.commons.math3.random.SynchronizedRandomGenerator;
|
import org.apache.commons.math3.random.SynchronizedRandomGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class BunchGenerator {
|
public class BunchGenerator {
|
||||||
|
|
||||||
private double bunchCr; // additional count rate in bunch
|
private double bunchCr; // additional count rate in bunch
|
||||||
private double bunchDist;// average distance between bunches
|
private double bunchDist;// average distance between bunches
|
||||||
private double bunchLength; // length of bunches
|
private double bunchLength; // length of bunches
|
||||||
private double cr; // count rate of normal events
|
private double cr; // count rate of normal events
|
||||||
private ExpGenerator expGen;
|
private ExpGenerator expGen;
|
||||||
|
|
||||||
// private ExponentialDistribution expGen;
|
// private ExponentialDistribution expGen;
|
||||||
public BunchGenerator(double cr, double bunchLength, double bunchDist, double bunchCr) {
|
public BunchGenerator(double cr, double bunchLength, double bunchDist, double bunchCr) {
|
||||||
this.cr = cr;
|
this.cr = cr;
|
||||||
this.bunchLength = bunchLength;
|
this.bunchLength = bunchLength;
|
||||||
this.bunchDist = bunchDist;
|
this.bunchDist = bunchDist;
|
||||||
this.bunchCr = bunchCr;
|
this.bunchCr = bunchCr;
|
||||||
expGen = new ExpGenerator(new SynchronizedRandomGenerator(new MersenneTwister()));
|
expGen = new ExpGenerator(new SynchronizedRandomGenerator(new MersenneTwister()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BunchGenerator(double cr, double bunchLength, double bunchDist, double bunchCr, RandomGenerator gen) {
|
public BunchGenerator(double cr, double bunchLength, double bunchDist, double bunchCr, RandomGenerator gen) {
|
||||||
this.cr = cr;
|
this.cr = cr;
|
||||||
this.bunchLength = bunchLength;
|
this.bunchLength = bunchLength;
|
||||||
this.bunchDist = bunchDist;
|
this.bunchDist = bunchDist;
|
||||||
this.bunchCr = bunchCr;
|
this.bunchCr = bunchCr;
|
||||||
expGen = new ExpGenerator(gen);
|
expGen = new ExpGenerator(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<NMEvent> generate(double dist, double length, double timeShift, boolean isBunch) {
|
public ArrayList<NMEvent> generate(double dist, double length, double timeShift, boolean isBunch) {
|
||||||
ArrayList<NMEvent> res = new ArrayList<>();
|
ArrayList<NMEvent> res = new ArrayList<>();
|
||||||
ArrayList<Double> events = generateEvents(dist, length);
|
ArrayList<Double> events = generateEvents(dist, length);
|
||||||
for (Double event : events) {
|
for (Double event : events) {
|
||||||
if (event < length) {
|
if (event < length) {
|
||||||
res.add(new NMEvent((short)0,event + timeShift));
|
res.add(new NMEvent((short)0,event + timeShift));
|
||||||
// if (isBunch) {
|
// if (isBunch) {
|
||||||
// res.add(new DebunchEvent(event + timeShift, 10));
|
// res.add(new DebunchEvent(event + timeShift, 10));
|
||||||
// } else {
|
// } else {
|
||||||
// res.add(new DebunchEvent(event + timeShift));
|
// res.add(new DebunchEvent(event + timeShift));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Double> generateEvents(double dist, double timeTotal) {
|
ArrayList<Double> generateEvents(double dist, double timeTotal) {
|
||||||
ArrayList<Double> res = new ArrayList<>();
|
ArrayList<Double> res = new ArrayList<>();
|
||||||
double timeCount = 0;
|
double timeCount = 0;
|
||||||
double delta;
|
double delta;
|
||||||
while (timeCount < timeTotal) {
|
while (timeCount < timeTotal) {
|
||||||
delta = expGen.nextExp(dist);
|
delta = expGen.nextExp(dist);
|
||||||
timeCount += delta;
|
timeCount += delta;
|
||||||
if (timeCount < timeTotal) {
|
if (timeCount < timeTotal) {
|
||||||
res.add(timeCount);
|
res.add(timeCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Создает пачку с треугольным распределением
|
* Создает пачку с треугольным распределением
|
||||||
*
|
*
|
||||||
* @param dist
|
* @param dist
|
||||||
* @param timeTotal
|
* @param timeTotal
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ArrayList<Double> generateEventsTriangle(double dist, double timeTotal) {
|
ArrayList<Double> generateEventsTriangle(double dist, double timeTotal) {
|
||||||
ArrayList<Double> res = new ArrayList<>();
|
ArrayList<Double> res = new ArrayList<>();
|
||||||
double timeCount = 0;
|
double timeCount = 0;
|
||||||
double delta;
|
double delta;
|
||||||
while (timeCount < timeTotal) {
|
while (timeCount < timeTotal) {
|
||||||
delta = expGen.nextExp(dist * timeTotal / (timeTotal - timeCount));
|
delta = expGen.nextExp(dist * timeTotal / (timeTotal - timeCount));
|
||||||
timeCount += delta;
|
timeCount += delta;
|
||||||
if (timeCount < timeTotal) {
|
if (timeCount < timeTotal) {
|
||||||
res.add(timeCount);
|
res.add(timeCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<NMEvent> generateNormalEvents(double measurementTime) {
|
public ArrayList<NMEvent> generateNormalEvents(double measurementTime) {
|
||||||
return generate(1 / cr, measurementTime, 0, false);
|
return generate(1 / cr, measurementTime, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<NMEvent> generateTriangle(double dist, double length, double timeShift, boolean isBunch) {
|
public ArrayList<NMEvent> generateTriangle(double dist, double length, double timeShift, boolean isBunch) {
|
||||||
ArrayList<NMEvent> res = new ArrayList<>();
|
ArrayList<NMEvent> res = new ArrayList<>();
|
||||||
ArrayList<Double> events = generateEventsTriangle(dist, length);
|
ArrayList<Double> events = generateEventsTriangle(dist, length);
|
||||||
for (Double event : events) {
|
for (Double event : events) {
|
||||||
if (event < length) {
|
if (event < length) {
|
||||||
res.add(new NMEvent((short)0,event + timeShift));
|
res.add(new NMEvent((short)0,event + timeShift));
|
||||||
// if (isBunch) {
|
// if (isBunch) {
|
||||||
// res.add(new DebunchEvent(event + timeShift, 10));
|
// res.add(new DebunchEvent(event + timeShift, 10));
|
||||||
// } else {
|
// } else {
|
||||||
// res.add(new DebunchEvent(event + timeShift));
|
// res.add(new DebunchEvent(event + timeShift));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param measurementTime - total measurement time
|
* @param measurementTime - total measurement time
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RawNMPoint generateWithBunches(double measurementTime) {
|
public RawNMPoint generateWithBunches(double measurementTime) {
|
||||||
ArrayList<NMEvent> res = generateNormalEvents(measurementTime);
|
ArrayList<NMEvent> res = generateNormalEvents(measurementTime);
|
||||||
ArrayList<Double> bunchList = generateEvents(bunchDist, measurementTime);
|
ArrayList<Double> bunchList = generateEvents(bunchDist, measurementTime);
|
||||||
for (Double bunchPos : bunchList) {
|
for (Double bunchPos : bunchList) {
|
||||||
res.addAll(generate(1 / bunchCr, bunchLength, bunchPos, true));
|
res.addAll(generate(1 / bunchCr, bunchLength, bunchPos, true));
|
||||||
}
|
}
|
||||||
return new RawNMPoint(0, res, measurementTime);
|
return new RawNMPoint(0, res, measurementTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param measurementTime - total measurement time
|
* @param measurementTime - total measurement time
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RawNMPoint generateWithRandomBunches(double measurementTime) {
|
public RawNMPoint generateWithRandomBunches(double measurementTime) {
|
||||||
ArrayList<NMEvent> res = generateNormalEvents(measurementTime);
|
ArrayList<NMEvent> res = generateNormalEvents(measurementTime);
|
||||||
ArrayList<Double> bunchList = generateEvents(bunchDist, measurementTime);
|
ArrayList<Double> bunchList = generateEvents(bunchDist, measurementTime);
|
||||||
for (Double bunchPos : bunchList) {
|
for (Double bunchPos : bunchList) {
|
||||||
double l = expGen.nextSafeGaussian(bunchLength, bunchLength / 3);
|
double l = expGen.nextSafeGaussian(bunchLength, bunchLength / 3);
|
||||||
double lambda = expGen.nextSafeGaussian(1 / bunchCr, 1 / bunchCr / 3);
|
double lambda = expGen.nextSafeGaussian(1 / bunchCr, 1 / bunchCr / 3);
|
||||||
res.addAll(generate(lambda, l, bunchPos, true));
|
res.addAll(generate(lambda, l, bunchPos, true));
|
||||||
}
|
}
|
||||||
return new RawNMPoint(0, res, measurementTime);
|
return new RawNMPoint(0, res, measurementTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RawNMPoint generateWithTriangleBunches(double measurementTime) {
|
public RawNMPoint generateWithTriangleBunches(double measurementTime) {
|
||||||
ArrayList<NMEvent> res = generateNormalEvents(measurementTime);
|
ArrayList<NMEvent> res = generateNormalEvents(measurementTime);
|
||||||
ArrayList<Double> bunchList = generateEvents(bunchDist, measurementTime);
|
ArrayList<Double> bunchList = generateEvents(bunchDist, measurementTime);
|
||||||
for (Double bunchPos : bunchList) {
|
for (Double bunchPos : bunchList) {
|
||||||
res.addAll(generateTriangle(1 / bunchCr, bunchLength, bunchPos, true));
|
res.addAll(generateTriangle(1 / bunchCr, bunchLength, bunchPos, true));
|
||||||
}
|
}
|
||||||
return new RawNMPoint(0, res, measurementTime);
|
return new RawNMPoint(0, res, measurementTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSeed(int seed) {
|
public void setSeed(int seed) {
|
||||||
this.expGen.setSeed(seed);
|
this.expGen.setSeed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ExpGenerator {
|
private static class ExpGenerator {
|
||||||
|
|
||||||
private final RandomGenerator generator;
|
private final RandomGenerator generator;
|
||||||
|
|
||||||
public ExpGenerator(RandomGenerator generator) {
|
public ExpGenerator(RandomGenerator generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpGenerator(RandomGenerator generator, int seed) {
|
public ExpGenerator(RandomGenerator generator, int seed) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
this.generator.setSeed(seed);
|
this.generator.setSeed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSeed(int seed) {
|
void setSeed(int seed) {
|
||||||
generator.setSeed(seed);
|
generator.setSeed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
double nextUniform() {
|
double nextUniform() {
|
||||||
return generator.nextDouble();
|
return generator.nextDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
double nextExp(double mean) {
|
double nextExp(double mean) {
|
||||||
double rand = this.nextUniform();
|
double rand = this.nextUniform();
|
||||||
return -mean * Math.log(1 - rand);
|
return -mean * Math.log(1 - rand);
|
||||||
}
|
}
|
||||||
|
|
||||||
double nextSafeGaussian(double mean, double sigma) {
|
double nextSafeGaussian(double mean, double sigma) {
|
||||||
double res = -1;
|
double res = -1;
|
||||||
while (res <= 0) {
|
while (res <= 0) {
|
||||||
res = mean + generator.nextGaussian() * sigma;
|
res = mean + generator.nextGaussian() * sigma;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.generators;
|
package inr.numass.generators;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,102 +13,102 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.generators;
|
package inr.numass.generators;
|
||||||
|
|
||||||
import inr.numass.data.NMEvent;
|
import inr.numass.storage.NMEvent;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.storage.RawNMPoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.commons.math3.distribution.EnumeratedRealDistribution;
|
import org.apache.commons.math3.distribution.EnumeratedRealDistribution;
|
||||||
import org.apache.commons.math3.distribution.RealDistribution;
|
import org.apache.commons.math3.distribution.RealDistribution;
|
||||||
import org.apache.commons.math3.random.EmpiricalDistribution;
|
import org.apache.commons.math3.random.EmpiricalDistribution;
|
||||||
import org.apache.commons.math3.random.JDKRandomGenerator;
|
import org.apache.commons.math3.random.JDKRandomGenerator;
|
||||||
import org.apache.commons.math3.random.RandomGenerator;
|
import org.apache.commons.math3.random.RandomGenerator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class EventGenerator {
|
public class EventGenerator {
|
||||||
|
|
||||||
double cr;
|
double cr;
|
||||||
// UnivariateFunction signalShape;
|
// UnivariateFunction signalShape;
|
||||||
RealDistribution distribution;
|
RealDistribution distribution;
|
||||||
|
|
||||||
private final RandomGenerator generator;
|
private final RandomGenerator generator;
|
||||||
|
|
||||||
public EventGenerator(double cr) {
|
public EventGenerator(double cr) {
|
||||||
this.cr = cr;
|
this.cr = cr;
|
||||||
generator = new JDKRandomGenerator();
|
generator = new JDKRandomGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromPoint(RawNMPoint point,int minChanel, int maxChanel){
|
public void loadFromPoint(RawNMPoint point,int minChanel, int maxChanel){
|
||||||
List<Short> shorts = new ArrayList<>();
|
List<Short> shorts = new ArrayList<>();
|
||||||
for (NMEvent event : point.getEvents()) {
|
for (NMEvent event : point.getEvents()) {
|
||||||
if((event.getChanel()>minChanel)&&(event.getChanel()<maxChanel)) {
|
if((event.getChanel()>minChanel)&&(event.getChanel()<maxChanel)) {
|
||||||
shorts.add(event.getChanel());
|
shorts.add(event.getChanel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double[] doubles = new double[shorts.size()];
|
double[] doubles = new double[shorts.size()];
|
||||||
|
|
||||||
for (int i = 0; i < shorts.size(); i++) {
|
for (int i = 0; i < shorts.size(); i++) {
|
||||||
doubles[i] = shorts.get(i);
|
doubles[i] = shorts.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
EmpiricalDistribution d = new EmpiricalDistribution();
|
EmpiricalDistribution d = new EmpiricalDistribution();
|
||||||
d.load(doubles);
|
d.load(doubles);
|
||||||
|
|
||||||
distribution = d;
|
distribution = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromSpectrum(Map<Double,Double> spectrum, int minChanel, int maxChanel){
|
public void loadFromSpectrum(Map<Double,Double> spectrum, int minChanel, int maxChanel){
|
||||||
assert minChanel > 0;
|
assert minChanel > 0;
|
||||||
assert maxChanel < RawNMPoint.MAX_CHANEL;
|
assert maxChanel < RawNMPoint.MAX_CHANEL;
|
||||||
|
|
||||||
double[] chanels = new double[spectrum.size()];
|
double[] chanels = new double[spectrum.size()];
|
||||||
double[] values = new double[spectrum.size()];
|
double[] values = new double[spectrum.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Map.Entry<Double, Double> entry : spectrum.entrySet()) {
|
for (Map.Entry<Double, Double> entry : spectrum.entrySet()) {
|
||||||
chanels[i] = entry.getKey();
|
chanels[i] = entry.getKey();
|
||||||
values[i] = entry.getValue();
|
values[i] = entry.getValue();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
distribution = new EnumeratedRealDistribution(chanels, values);
|
distribution = new EnumeratedRealDistribution(chanels, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NMEvent nextEvent(NMEvent prev) {
|
public NMEvent nextEvent(NMEvent prev) {
|
||||||
//пока без канала
|
//пока без канала
|
||||||
short chanel = 1600;
|
short chanel = 1600;
|
||||||
|
|
||||||
if(distribution!=null){
|
if(distribution!=null){
|
||||||
chanel = (short) distribution.sample();
|
chanel = (short) distribution.sample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new NMEvent(chanel, prev.getTime() + nextExp(1 / cr));
|
return new NMEvent(chanel, prev.getTime() + nextExp(1 / cr));
|
||||||
}
|
}
|
||||||
|
|
||||||
double nextExp(double mean) {
|
double nextExp(double mean) {
|
||||||
double rand = this.nextUniform();
|
double rand = this.nextUniform();
|
||||||
return -mean * Math.log(1 - rand);
|
return -mean * Math.log(1 - rand);
|
||||||
}
|
}
|
||||||
|
|
||||||
double nextPositiveGaussian(double mean, double sigma) {
|
double nextPositiveGaussian(double mean, double sigma) {
|
||||||
double res = -1;
|
double res = -1;
|
||||||
while (res <= 0) {
|
while (res <= 0) {
|
||||||
res = mean + generator.nextGaussian() * sigma;
|
res = mean + generator.nextGaussian() * sigma;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
double nextUniform() {
|
double nextUniform() {
|
||||||
return generator.nextDouble();
|
return generator.nextDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSeed(int seed) {
|
void setSeed(int seed) {
|
||||||
generator.setSeed(seed);
|
generator.setSeed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
configurations{
|
|
||||||
all*.exclude module: 'commons-math3'
|
|
||||||
all*.exclude group: 'org.jfree'
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(':numass-main')){transitive = false}
|
|
||||||
compile project(':dataforge-storage')
|
compile project(':dataforge-storage')
|
||||||
compile project(':dataforge-grind')
|
compile project(':dataforge-grind')
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@ task runClient(type: JavaExec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(':numass-storage')){transitive = false}
|
compile(project(':numass-storage'))
|
||||||
compile project(':dataforge-storage')
|
|
||||||
compile 'commons-cli:commons-cli:1.3.1'
|
compile 'commons-cli:commons-cli:1.3.1'
|
||||||
compile 'org.zeroturnaround:zt-zip:1.9'
|
compile 'org.zeroturnaround:zt-zip:1.9'
|
||||||
}
|
}
|
@ -13,37 +13,37 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class NMEvent implements Cloneable{
|
public class NMEvent implements Cloneable{
|
||||||
protected final short chanel;
|
protected final short chanel;
|
||||||
protected final double time;
|
protected final double time;
|
||||||
|
|
||||||
public NMEvent(short chanel, double time) {
|
public NMEvent(short chanel, double time) {
|
||||||
this.chanel = chanel;
|
this.chanel = chanel;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMEvent clone() {
|
public NMEvent clone() {
|
||||||
return new NMEvent(chanel, time);
|
return new NMEvent(chanel, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the chanel
|
* @return the chanel
|
||||||
*/
|
*/
|
||||||
public short getChanel() {
|
public short getChanel() {
|
||||||
return chanel;
|
return chanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the time
|
* @return the time
|
||||||
*/
|
*/
|
||||||
public double getTime(){
|
public double getTime(){
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.storage;
|
||||||
|
|
||||||
import hep.dataforge.description.ValueDef;
|
import hep.dataforge.description.ValueDef;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.storage;
|
||||||
|
|
||||||
import hep.dataforge.tables.DataPoint;
|
import hep.dataforge.tables.DataPoint;
|
||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
@ -3,8 +3,9 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.storage;
|
||||||
|
|
||||||
|
import inr.numass.storage.NMPoint;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.names.Named;
|
import hep.dataforge.names.Named;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
@ -24,10 +24,6 @@ import hep.dataforge.meta.MetaBuilder;
|
|||||||
import hep.dataforge.storage.api.ObjectLoader;
|
import hep.dataforge.storage.api.ObjectLoader;
|
||||||
import hep.dataforge.storage.api.Storage;
|
import hep.dataforge.storage.api.Storage;
|
||||||
import hep.dataforge.storage.loaders.AbstractLoader;
|
import hep.dataforge.storage.loaders.AbstractLoader;
|
||||||
import inr.numass.data.NMEvent;
|
|
||||||
import inr.numass.data.NMPoint;
|
|
||||||
import inr.numass.data.NumassData;
|
|
||||||
import inr.numass.data.RawNMPoint;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -13,8 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.storage;
|
||||||
|
|
||||||
|
import inr.numass.storage.NMEvent;
|
||||||
|
import inr.numass.storage.RawNMFile;
|
||||||
|
import inr.numass.storage.RawNMPoint;
|
||||||
import hep.dataforge.data.FileDataFactory;
|
import hep.dataforge.data.FileDataFactory;
|
||||||
import hep.dataforge.data.binary.Binary;
|
import hep.dataforge.data.binary.Binary;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
@ -22,8 +22,6 @@ import hep.dataforge.meta.Meta;
|
|||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.storage.filestorage.FileStorage;
|
import hep.dataforge.storage.filestorage.FileStorage;
|
||||||
import hep.dataforge.storage.filestorage.VFSUtils;
|
import hep.dataforge.storage.filestorage.VFSUtils;
|
||||||
import inr.numass.data.NMFile;
|
|
||||||
import inr.numass.data.NumassData;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.storage;
|
||||||
|
|
||||||
import hep.dataforge.names.NamedMetaHolder;
|
import hep.dataforge.names.NamedMetaHolder;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
@ -109,7 +109,7 @@ public class RawNMFile extends NamedMetaHolder {
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
void putEvent(double U, short chanel, double time) {
|
public void putEvent(double U, short chanel, double time) {
|
||||||
for (RawNMPoint point : this.getData()) {
|
for (RawNMPoint point : this.getData()) {
|
||||||
if (U == point.getUread()) {
|
if (U == point.getUread()) {
|
||||||
point.putEvent(new NMEvent(chanel, time));
|
point.putEvent(new NMEvent(chanel, time));
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package inr.numass.data;
|
package inr.numass.storage;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -11,8 +11,6 @@ description = "The viewer for numass data"
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':numass-main')
|
compile project(':numass-main')
|
||||||
// compile project(':dataforge-storage')
|
|
||||||
compile project(':numass-storage')
|
|
||||||
compile project(':dataforge-fx')
|
compile project(':dataforge-fx')
|
||||||
compile 'com.jcraft:jsch:0.1.53'
|
compile 'com.jcraft:jsch:0.1.53'
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import hep.dataforge.context.ProcessManager;
|
|||||||
import hep.dataforge.exceptions.StorageException;
|
import hep.dataforge.exceptions.StorageException;
|
||||||
import hep.dataforge.fx.ConsoleFragment;
|
import hep.dataforge.fx.ConsoleFragment;
|
||||||
import hep.dataforge.fx.ProcessManagerFragment;
|
import hep.dataforge.fx.ProcessManagerFragment;
|
||||||
import inr.numass.data.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
import inr.numass.storage.NumassStorage;
|
import inr.numass.storage.NumassStorage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -19,7 +19,7 @@ import hep.dataforge.context.ProcessManager;
|
|||||||
import hep.dataforge.exceptions.StorageException;
|
import hep.dataforge.exceptions.StorageException;
|
||||||
import hep.dataforge.storage.api.Loader;
|
import hep.dataforge.storage.api.Loader;
|
||||||
import hep.dataforge.storage.api.Storage;
|
import hep.dataforge.storage.api.Storage;
|
||||||
import inr.numass.data.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
import inr.numass.storage.NumassStorage;
|
import inr.numass.storage.NumassStorage;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -37,8 +37,8 @@ import hep.dataforge.tables.ListTable;
|
|||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.tables.XYAdapter;
|
import hep.dataforge.tables.XYAdapter;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import inr.numass.data.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
Loading…
Reference in New Issue
Block a user