Replaced isnan with TMath::IsNaN and isinf with !TMath::Finite, since