numass-framework/numass-main/src/main/java/inr/numass/actions/ReadNumassDataAction.java

66 lines
2.7 KiB
Java
Raw Normal View History

2015-12-18 16:20:47 +03:00
/*
* 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.
*/
package inr.numass.actions;
import hep.dataforge.actions.OneToOneAction;
import hep.dataforge.context.Context;
2016-04-02 21:08:37 +03:00
import hep.dataforge.data.binary.Binary;
2016-02-17 15:08:21 +03:00
import hep.dataforge.description.NodeDef;
import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef;
2015-12-18 16:20:47 +03:00
import hep.dataforge.exceptions.ContentException;
2016-04-30 21:57:46 +03:00
import hep.dataforge.io.reports.Reportable;
2016-03-27 20:40:50 +03:00
import hep.dataforge.meta.Laminate;
2015-12-18 16:20:47 +03:00
import static inr.numass.NumassIO.getNumassData;
import inr.numass.data.NMFile;
import inr.numass.data.RawNMFile;
/**
2016-03-21 15:29:31 +03:00
*
2015-12-18 16:20:47 +03:00
* @author Darksnake
*/
@TypedActionDef(name = "readData",
2016-04-30 16:13:50 +03:00
inputType = Binary.class, outputType = NMFile.class, info = "Read binary numass data file")
2015-12-18 16:20:47 +03:00
@ValueDef(name = "fileName", info = "The name of the file. By default equals file name.")
@ValueDef(name = "HVdev", info = "Divider for HV measurements. Should be set to 1.0 for numass data 2014",
def = "2.468555393226049", type = "NUMBER")
@ValueDef(name = "noUset", info = "If 'true', then Uset = Uread")
@NodeDef(name = "debunch", target = "class::inr.numass.actions.DebunchAction", info = "If given, governs debunching")
2016-04-02 21:08:37 +03:00
public class ReadNumassDataAction extends OneToOneAction<Binary, NMFile> {
2015-12-18 16:20:47 +03:00
@Override
2016-04-30 16:13:50 +03:00
protected NMFile execute(Context context, Reportable log, String name, Laminate meta, Binary source) throws ContentException {
2015-12-18 16:20:47 +03:00
// log.logString("File '%s' started", source.getName());
2016-03-27 20:40:50 +03:00
RawNMFile raw = getNumassData(source, meta);
if (meta.getBoolean("paw", false)) {
raw.generatePAW(buildActionOutput(context, name + ".paw"));
2015-12-18 16:20:47 +03:00
}
2016-03-21 15:29:31 +03:00
2016-03-27 20:40:50 +03:00
if (meta.getNodeNames(false).contains("debunch")) {
DebunchAction debunch = new DebunchAction();
Laminate laminate = new Laminate(meta.getNode("debunch"))
.setValueContext(context)
.setDescriptor(debunch.getDescriptor());
raw = debunch.execute(context, log, name, laminate, raw);
2015-12-18 16:20:47 +03:00
}
NMFile result = new NMFile(raw);
2016-03-21 15:29:31 +03:00
2015-12-18 16:20:47 +03:00
return result;
}
}