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

67 lines
2.5 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-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;
import hep.dataforge.io.log.Logable;
2016-02-17 15:08:21 +03:00
import hep.dataforge.meta.Meta;
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-22 11:31:54 +03:00
import java.io.File;
2015-12-18 16:20:47 +03:00
/**
2016-03-21 15:29:31 +03:00
*
2015-12-18 16:20:47 +03:00
* @author Darksnake
*/
@TypedActionDef(name = "readData",
2016-03-22 11:31:54 +03:00
inputType = File.class, outputType = NMFile.class, description = "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-03-22 11:31:54 +03:00
public class ReadNumassDataAction extends OneToOneAction<File, NMFile> {
2015-12-18 16:20:47 +03:00
public ReadNumassDataAction(Context context, Meta an) {
super(context, an);
}
@Override
2016-03-22 11:31:54 +03:00
protected NMFile execute(Logable log, String name, Meta reader, File source) throws ContentException {
2015-12-18 16:20:47 +03:00
// log.logString("File '%s' started", source.getName());
RawNMFile raw = getNumassData(source, meta());
if (meta().getBoolean("paw", false)) {
2016-03-21 15:29:31 +03:00
raw.generatePAW(buildActionOutput(name + ".paw"));
2015-12-18 16:20:47 +03:00
}
2016-03-21 15:29:31 +03:00
if (meta().hasNode("debunch")) {
2015-12-18 16:20:47 +03:00
DebunchAction debunch = new DebunchAction(getContext(), meta().getNode("debunch"));
2016-03-21 15:29:31 +03:00
raw = debunch.execute(log, name, null, 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;
}
}