fact-project / fact-tools

The fact-tools are an extension to the streams framework to analyse the data of the First G-APD Cherenkov Telescope.
http://sfb876.tu-dortmund.de/FACT/
GNU General Public License v3.0
6 stars 1 forks source link

Make calibration.xml work with FactFileMultistream #351

Closed tarrox closed 6 years ago

tarrox commented 6 years ago

Currently the DrsCalibration in the calibration.xml uses the url="${drsfile}" method of getting the drs file, which makes the xml incompatible with the use of FactFileMultistream. I think it would be nice if it would work with it, as it means one can just reuse it.

There are two options I can think of to make this work:

maxnoe commented 6 years ago

Maybe something like:

if (item.get("@drsFile") != null && url == "") {
    // use @drsFile
} else {
    // use url
}
maxnoe commented 6 years ago

So streams does apparently not allow to create an empty or null url by setting the property to an empty string.

What I came up with was setting -Ddrsfile=file: and using:

    @Override
    public void init(ProcessContext processContext) throws Exception {

        if (url != null)  {
            if (!url.getPath().equals("")) {
                try {
                    loadDrsData(url);
                } catch (Exception e) {
                    log.error("Could not load .drs file specified in the url.");
                    throw new RuntimeException(e.getMessage());
                }
            } else {
                url = null;
            }
        }
    }

But I don't really like it. Anybody got a better idea?

tarrox commented 6 years ago

Another option would be to switch the url to a string and convert it if needed. That way we could set it as empty. Although this wouldn't be a good solution either, i would even say worse.

Another way would be to skip the whole init function and simply load the url if needed in the process function, basically taking @drsfile and if not given use the url parameter, if this fails, just abort as usual. That way we wouldn't need to check for an empty path as a way to check which method to use. Instead the drskey is always used if given. I think this option would be the cleanest.

maxnoe commented 6 years ago

simply load the url if needed in the process function

The checking is done by streams at the xml Parsing level. The only thing would be make it a string and convert to url.

tarrox commented 6 years ago

The checking is done by streams at the xml Parsing level. The only thing would be make it a string and convert to url.

We would set the url to -Ddrsfile=file: or -Ddrsfile=file:whatever but wouldn't bother checking it in any special way, as we would priorities the information from the @drsfile and if that isn't given we load the url which would fail, which would be fine as no correct drs information was given, which should result in a failure.