numass analysis fix

This commit is contained in:
darksnake 2016-11-22 17:02:05 +03:00
parent 79336be1da
commit 931c880259
4 changed files with 34 additions and 27 deletions

View File

@ -112,10 +112,10 @@ public class TritiumUtils {
double res;
if (deadTime > 0) {
double total = p.getEventsCount();
double time = p.getLength();
res = wind / (1 - total * deadTime / time);
// double timeRatio = deadTime / p.getLength();
// res = wind / total * (1d - Math.sqrt(1d - 4d * total * timeRatio)) / 2d / timeRatio;
// double time = p.getLength();
// res = wind / (1 - total * deadTime / time);
double timeRatio = deadTime / p.getLength();
res = wind / total * (1d - Math.sqrt(1d - 4d * total * timeRatio)) / 2d / timeRatio;
} else {
res = wind;
}

View File

@ -64,6 +64,8 @@ public class NumassFitTask extends SingleActionTask<Table, FitState> {
MetaBuilder metaBuilder = new MetaBuilder(model.meta()).removeNode("fit");
if (model.meta().hasMeta("filter")) {
model.dependsOn("filter", metaBuilder.build(), "prepare");
} else if (model.meta().hasMeta("empty")) {
model.dependsOn("substractEmpty", metaBuilder.build(), "prepare");
} else {
model.dependsOn("prepare", metaBuilder.build(), "prepare");
}

View File

@ -12,7 +12,6 @@ import hep.dataforge.data.*;
import hep.dataforge.description.DescriptorBuilder;
import hep.dataforge.description.NodeDescriptor;
import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.meta.Template;
import hep.dataforge.storage.api.Loader;
import hep.dataforge.storage.commons.StorageUtils;
@ -60,9 +59,9 @@ public class NumassPrepareTask extends AbstractTask<Table> {
Meta dataMeta = config.getMeta("data");
URI storageUri = input.getCheckedData("dataRoot", URI.class).get();
DataSet.Builder<NumassData> dataBuilder = readData(callback, context, storageUri, dataMeta);
if (config.hasMeta("empty")) {
dataBuilder.putNode("empty", readData(callback, context, storageUri, config.getMeta("empty")).build());
}
// if (config.hasMeta("empty")) {
// dataBuilder.putNode("empty", readData(callback, context, storageUri, config.getMeta("empty")).build());
// }
DataNode<NumassData> data = dataBuilder.build();
@ -80,13 +79,13 @@ public class NumassPrepareTask extends AbstractTask<Table> {
DataTree.Builder<Table> resultBuilder = DataTree.builder(Table.class);
DataTree.Builder<Table> tablesForMerge = new DataTree.Builder<>(tables);
//extracting empty data
if (config.hasMeta("empty")) {
DataNode<Table> emptySourceNode = tables.getCheckedNode("empty", Table.class);
Meta emptyMergeMeta = new MetaBuilder("emptySource").setValue("mergeName", "emptySource");
resultBuilder.putData("merge.empty", runAction(new MergeDataAction(), callback, context, emptySourceNode, emptyMergeMeta).getData());
tablesForMerge.removeNode("empty");
}
// //extracting empty data
// if (config.hasMeta("empty")) {
// DataNode<Table> emptySourceNode = tables.getCheckedNode("empty", Table.class);
// Meta emptyMergeMeta = new MetaBuilder("emptySource").setValue("mergeName", "emptySource");
// resultBuilder.putData("merge.empty", runAction(new MergeDataAction(), callback, context, emptySourceNode, emptyMergeMeta).getData());
// tablesForMerge.removeNode("empty");
// }
config.getMetaList("merge").forEach(mergeNode -> {
Meta mergeMeta = Template.compileTemplate(mergeNode, config);

View File

@ -22,6 +22,8 @@ import hep.dataforge.data.DataNode;
import hep.dataforge.data.DataTree;
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;
@ -45,9 +47,8 @@ public class NumassSubstractEmptySourceTask extends AbstractTask<Table> {
protected DataNode<Table> run(TaskModel model, ProgressCallback callback, DataNode<?> data) {
DataTree.Builder<Table> builder = DataTree.builder(Table.class);
DataNode<Table> rootNode = data.getCheckedNode("prepare", Table.class);
Data<Table> emptySource = rootNode.getCheckedData("merge.empty", Table.class);
Data<? extends Table> emptySource = data.getCheckedNode("empty", Table.class).getData();
rootNode.forEachDataWithType(Table.class, input -> {
if (!input.getName().startsWith("merge.empty")) {
Data<? extends Table> res = subtractBackground(input, emptySource);
res.getGoal().onComplete((r, err) -> {
if (r != null) {
@ -57,14 +58,19 @@ public class NumassSubstractEmptySourceTask extends AbstractTask<Table> {
});
builder.putData(input.getName(), res);
}
});
return builder.build();
}
@Override
protected TaskModel transformModel(TaskModel model) {
model.dependsOn("prepare", model.meta(), "prepare");
Meta modelMeta = model.meta();
model.dependsOn("prepare", modelMeta, "prepare");
MetaBuilder emptyCfg = new MetaBuilder("prepare")
.setNode(modelMeta.getMeta("prepare"))
.setNode("data", modelMeta.getMeta("empty"))
.setNode(new MetaBuilder("merge").setValue("mergeName", model.meta().getName() + ".empty"));
model.dependsOn("prepare", emptyCfg, "empty");
return model;
}