gundam-organization / gundam

GUNDAM, for Generalized and Unified Neutrino Data Analysis Methods, is a suite of applications which aims at performing various statistical analysis with different purposes and setups.
GNU Lesser General Public License v2.1
13 stars 10 forks source link

[LTS/1.8.x] NaN saved in output #490

Closed riccioc closed 3 months ago

riccioc commented 4 months ago

Running a fit NaN values are saved for the pion FSI parameters. This was not observed before and may be related to the configuration files, but it could be avoided by adding a protection against it. I have identified the following lines where this protection can go: L943 and L944 in MinimizerInterface.cpp. I was thinking of adding a simple if(not std::isnan(par.getParameterValue()) ) before setting the bin content and if( not std::isnan((*covMatrix_)[par.getParameterIndex()][par.getParameterIndex()]) ) before setting the parameter errors. The exception can be that the bin is set to zero and an error is printed in the log. Feedback on my proposal is welcome!

tadoyle commented 4 months ago

I thinking seeing NaN is a very clear indication something went wrong; unless this causes crashes I'd be tempted to leave it so the underlying problem isn't missed. If it does cause issues, I think an exception like you propose above works. I'd probably set the value to something like -999 so it's still very obvious that something went wrong, 0 could be overlooked if people don't check carefully.

ClarkMcGrew commented 4 months ago

I pushed a test branch LTS/testbed/OnlyValidParameters that will throw if a NaN parameter is used. It should also print the name of the parameter. I would go further than @tadoyle and say using any invalid parameters should be treated as a full "cannot continue" situation.

riccioc commented 4 months ago

I've tested this version and it throws an error as expected what(): exception thrown by the logger: std::isnan(_parameterValue_)

ClarkMcGrew commented 3 months ago

Based on discussions: The actual issue is that disabled parameters are being saved into the output. Disabled parameters should not be saved. If there are ENABLED parameters with a NaN value, that should be an error.