numass fixes

This commit is contained in:
darksnake 2017-02-09 16:23:00 +03:00
parent 1a637cff41
commit 5cf68cc21f
5 changed files with 35 additions and 37 deletions

View File

@ -68,7 +68,7 @@ public class UnderflowCorrection {
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) / norm + 1d);
builder.row(point.getUset(), a, sigma, a * sigma * (Math.exp(xLow / sigma)) / norm + 1d);
}
return builder.build();
}

View File

@ -49,8 +49,8 @@ public class NumassServer extends AbstractNetworkListener {
private StateLoader rootState;
private NumassRun run;
public NumassServer(FileStorage storage, Meta listnerConfig) {
super(listnerConfig);
public NumassServer(FileStorage storage, Meta listenerConfig) {
super(listenerConfig);
init(storage);
}

View File

@ -184,7 +184,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
* @param envelope
* @return
*/
private RawNMPoint readRawPoint(Envelope envelope) {
private synchronized RawNMPoint readRawPoint(Envelope envelope) {
List<NMEvent> events = new ArrayList<>();
double timeCoef = envelope.meta().getDouble("time_coeff", 50);
@ -283,32 +283,27 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
@Override
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) {
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() {
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()
.filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null)
.map(entry -> entry.getValue().get())
.sorted((Envelope t, Envelope t1)
-> t.meta().getInt("external_meta.point_index", -1).compareTo(t1.meta().getInt("external_meta.point_index", -1)))
.collect(Collectors.toList());
.sorted(Comparator.comparing(t -> t.meta().getInt("external_meta.point_index", -1)));
}
public boolean isReversed() {
//TODO replace by meta tag in later revisions
return SetDirectionUtility.isReversed(getPath(), n -> {
List<Envelope> points = getPoints();
return getPoints().size() >= 2 && readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta()));
});
return meta().getBoolean("iteration_info.reverse", false);
}
@Override

View File

@ -56,6 +56,17 @@ public class NumassStorage extends FileStorage {
public static final String NUMASS_DATA_LOADER_TYPE = "numassData";
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
*
@ -64,18 +75,22 @@ public class NumassStorage extends FileStorage {
* @return
* @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 {
Meta meta = new MetaBuilder("storage")
.setValue("type", "file.numass")
.setValue("readOnly", readOnly)
.setValue("monitor", false);
.setValue("monitor", monitor);
return new NumassStorage(VFSUtils.getLocalFile(dir), meta);
} catch (FileSystemException 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 {
try {
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
protected void updateDirectoryLoaders() {
try {

View File

@ -15,20 +15,19 @@
*/
package inr.numass.scripts
import hep.dataforge.storage.filestorage.VFSUtils
import hep.dataforge.meta.Meta
import inr.numass.server.NumassServer
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
NumassServer listener = new NumassServer(storage, null);
NumassServer listener = new NumassServer(storage, Meta.empty());
listener.open()