How do I find if a page has a template?

This should do the trick for you. This shows what template file is stored in post_meta, if one has been selected in the admin panel:

$template_name = get_post_meta( $the_query->post->ID, '_wp_page_template', true );

If you want to see if the page is the homepage, use is_home() or is_front_page().

If you want to see what files are generating the page, use this in your functions.php:

// Returns a list of files used to generate the page.  Best called in footer.php before </body>
function _dump_files()
{
    # @todo Aufrufende Datei kann im Array manchmal fehlen!
    add_action( 'all', create_function( '', "echo '<pre>'; print_r( get_included_files() ); echo '</pre>'; return;" ) );
}

I use it in footer.php like this:

if (is_user_logged_in()) {
    _dump_files() ;
}