An if statement about template specific sidebar


I am working on a genesis website. I created a contact page template and assigned a special sidebar for it and succesfully created a widget for it. It works fine. However I want this contact page template specific sidebar to work only if the widget is actually used and if not I want the contact page template to show the general sidebar that is used in all pages. The code I used in the contact page template is as follows. I tried all sorts of php if statement, but couldnt make it work. I just need to code it as such that if the "sidebar-contact" widget area is used, this page template shall show this content, else it shall show the general sidebar. Many thanks.

//Replace primary sidebar
remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
add_action( 'genesis_after_content', 'child_switch_sidebar' );
function child_switch_sidebar(){
echo '<div id="sidebar" class="sidebar widget-area">';
echo '</div>';