numass fixes
This commit is contained in:
parent
1a637cff41
commit
5cf68cc21f
@ -68,7 +68,7 @@ public class UnderflowCorrection {
|
|||||||
double sigma = fitRes[1];
|
double sigma = fitRes[1];
|
||||||
|
|
||||||
//builder.row(point.getUset(), a, sigma, (a * sigma * (Math.exp(xLow / sigma) - 1) - a*xLow) / norm + 1d);
|
//builder.row(point.getUset(), a, sigma, (a * sigma * (Math.exp(xLow / sigma) - 1) - a*xLow) / norm + 1d);
|
||||||
builder.row(point.getUset(), a, sigma, a * sigma * (Math.exp(xLow / sigma) - 1) / norm + 1d);
|
builder.row(point.getUset(), a, sigma, a * sigma * (Math.exp(xLow / sigma)) / norm + 1d);
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ public class NumassServer extends AbstractNetworkListener {
|
|||||||
private StateLoader rootState;
|
private StateLoader rootState;
|
||||||
private NumassRun run;
|
private NumassRun run;
|
||||||
|
|
||||||
public NumassServer(FileStorage storage, Meta listnerConfig) {
|
public NumassServer(FileStorage storage, Meta listenerConfig) {
|
||||||
super(listnerConfig);
|
super(listenerConfig);
|
||||||
init(storage);
|
init(storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
* @param envelope
|
* @param envelope
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private RawNMPoint readRawPoint(Envelope envelope) {
|
private synchronized RawNMPoint readRawPoint(Envelope envelope) {
|
||||||
List<NMEvent> events = new ArrayList<>();
|
List<NMEvent> events = new ArrayList<>();
|
||||||
|
|
||||||
double timeCoef = envelope.meta().getDouble("time_coeff", 50);
|
double timeCoef = envelope.meta().getDouble("time_coeff", 50);
|
||||||
@ -283,32 +283,27 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<NMPoint> stream() {
|
public Stream<NMPoint> stream() {
|
||||||
return this.getPoints().stream().parallel().map(this::readPoint);
|
return this.getPoints().map(this::readPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<NMPoint> getNMPoints(Function<RawNMPoint, NMPoint> transformation) {
|
public List<NMPoint> getNMPoints(Function<RawNMPoint, NMPoint> transformation) {
|
||||||
return this.getPoints().stream().parallel().map(env -> readPoint(env, transformation)).collect(Collectors.toList());
|
return this.getPoints().map(env -> readPoint(env, transformation)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RawNMPoint> getRawPoints() {
|
public List<RawNMPoint> getRawPoints() {
|
||||||
return this.getPoints().stream().parallel().map(this::readRawPoint).collect(Collectors.toList());
|
return this.getPoints().map(this::readRawPoint).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Envelope> getPoints() {
|
private Stream<Envelope> getPoints() {
|
||||||
return getItems().entrySet().stream()
|
return getItems().entrySet().stream()
|
||||||
.filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null)
|
.filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null)
|
||||||
.map(entry -> entry.getValue().get())
|
.map(entry -> entry.getValue().get())
|
||||||
.sorted((Envelope t, Envelope t1)
|
.sorted(Comparator.comparing(t -> t.meta().getInt("external_meta.point_index", -1)));
|
||||||
-> t.meta().getInt("external_meta.point_index", -1).compareTo(t1.meta().getInt("external_meta.point_index", -1)))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReversed() {
|
public boolean isReversed() {
|
||||||
//TODO replace by meta tag in later revisions
|
return meta().getBoolean("iteration_info.reverse", false);
|
||||||
return SetDirectionUtility.isReversed(getPath(), n -> {
|
|
||||||
List<Envelope> points = getPoints();
|
|
||||||
return getPoints().size() >= 2 && readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,6 +56,17 @@ public class NumassStorage extends FileStorage {
|
|||||||
public static final String NUMASS_DATA_LOADER_TYPE = "numassData";
|
public static final String NUMASS_DATA_LOADER_TYPE = "numassData";
|
||||||
public static final String GROUP_META_FILE = "numass_group_meta";
|
public static final String GROUP_META_FILE = "numass_group_meta";
|
||||||
|
|
||||||
|
protected NumassStorage(FileStorage parent, String path, Meta config) throws StorageException {
|
||||||
|
super(parent, path, config);
|
||||||
|
super.refresh();
|
||||||
|
//TODO read meta from numass_group_meta to .numass element
|
||||||
|
}
|
||||||
|
|
||||||
|
protected NumassStorage(FileObject dir, Meta config) throws StorageException {
|
||||||
|
super(dir, config);
|
||||||
|
super.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create root numass storage
|
* Create root numass storage
|
||||||
*
|
*
|
||||||
@ -64,18 +75,22 @@ public class NumassStorage extends FileStorage {
|
|||||||
* @return
|
* @return
|
||||||
* @throws StorageException
|
* @throws StorageException
|
||||||
*/
|
*/
|
||||||
public static NumassStorage buildLocalNumassRoot(File dir, boolean readOnly) throws StorageException {
|
public static NumassStorage buildLocalNumassRoot(File dir, boolean readOnly, boolean monitor) throws StorageException {
|
||||||
try {
|
try {
|
||||||
Meta meta = new MetaBuilder("storage")
|
Meta meta = new MetaBuilder("storage")
|
||||||
.setValue("type", "file.numass")
|
.setValue("type", "file.numass")
|
||||||
.setValue("readOnly", readOnly)
|
.setValue("readOnly", readOnly)
|
||||||
.setValue("monitor", false);
|
.setValue("monitor", monitor);
|
||||||
return new NumassStorage(VFSUtils.getLocalFile(dir), meta);
|
return new NumassStorage(VFSUtils.getLocalFile(dir), meta);
|
||||||
} catch (FileSystemException ex) {
|
} catch (FileSystemException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static NumassStorage buildLocalNumassRoot(File dir, boolean readOnly) throws StorageException {
|
||||||
|
return buildLocalNumassRoot(dir, readOnly, false);
|
||||||
|
}
|
||||||
|
|
||||||
public static NumassStorage buildRemoteNumassRoot(String ip, int port, String login, String password, String path) throws StorageException {
|
public static NumassStorage buildRemoteNumassRoot(String ip, int port, String login, String password, String path) throws StorageException {
|
||||||
try {
|
try {
|
||||||
Meta meta = new MetaBuilder("storage")
|
Meta meta = new MetaBuilder("storage")
|
||||||
@ -120,17 +135,6 @@ public class NumassStorage extends FileStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NumassStorage(FileStorage parent, String path, Meta config) throws StorageException {
|
|
||||||
super(parent, path, config);
|
|
||||||
super.refresh();
|
|
||||||
//TODO read meta from numass_group_meta to .numass element
|
|
||||||
}
|
|
||||||
|
|
||||||
protected NumassStorage(FileObject dir, Meta config) throws StorageException {
|
|
||||||
super(dir, config);
|
|
||||||
super.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateDirectoryLoaders() {
|
protected void updateDirectoryLoaders() {
|
||||||
try {
|
try {
|
||||||
|
@ -15,27 +15,26 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.scripts
|
package inr.numass.scripts
|
||||||
|
|
||||||
import hep.dataforge.storage.filestorage.VFSUtils
|
import hep.dataforge.meta.Meta
|
||||||
import inr.numass.server.NumassServer
|
import inr.numass.server.NumassServer
|
||||||
import inr.numass.storage.NumassStorage
|
import inr.numass.storage.NumassStorage
|
||||||
import org.apache.commons.vfs2.FileObject
|
|
||||||
|
|
||||||
String path = "D:\\temp\\test\\numass\\"
|
String path = "D:\\Work\\Numass\\data\\2016_10\\"
|
||||||
|
|
||||||
FileObject file = VFSUtils.getLocalFile(new File(path))
|
//FileObject file = VFSUtils.getLocalFile(new File(path))
|
||||||
|
|
||||||
NumassStorage storage = new NumassStorage(file,null)
|
NumassStorage storage = NumassStorage.buildLocalNumassRoot(new File(path), true, true);
|
||||||
|
|
||||||
println "Starting test numass listener in "+path
|
println "Starting test numass listener in " + path
|
||||||
|
|
||||||
NumassServer listener = new NumassServer(storage, null);
|
NumassServer listener = new NumassServer(storage, Meta.empty());
|
||||||
|
|
||||||
listener.open()
|
listener.open()
|
||||||
|
|
||||||
String stopLine = "";
|
String stopLine = "";
|
||||||
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
|
||||||
while(stopLine == null || !stopLine.startsWith("exit")){
|
while (stopLine == null || !stopLine.startsWith("exit")) {
|
||||||
// print ">"
|
// print ">"
|
||||||
stopLine = br.readLine();
|
stopLine = br.readLine();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user