How to detect if some page template has been selected

sure it is possible. Just check the page meta field (assuming you’re in the loop):

$template = get_post_meta( get_the_ID(), '_wp_page_template', true );