How to find out which template file is used for the current page

For this, check what is passed to the template_include filter:

## Which template is used at the current moment
add_filter( 'template_include', 'echo_cur_tplfile', 99 );
function echo_cur_tplfile( $template ){

	echo '<span style="color:red">'. wp_basename( $template ) .'</span>';

	return $template;
}

Note embeded into: template_include