Constraining heavy quark energy loss using B and D meson measurements in heavy ion collision at RHIC and LHC energies