Nanostructural dependence of photoluminescence and photosensing properties in hydrothermally synthesized Mg-doped ZnO nanorod arrays