Magnetically assisted self-injection and radiation generation for plasma-based acceleration