Also if you're at a "mid school" but prestigious lab (i.e. lab with industry connections that publishes top work) you can also probably get into a top PhD program as this lab is likely to know someone that is hiring and their referrals are very prestigious.