Fix for ROOT-5605
Fix for ROOT-5571. Return now a NaN for indices outside the range and not access the internal array which can be empty.