Self-trapping of charge carriers in polymers: A comparative study of poly(p-phenylene) and poly(N-vinylcarbazole)