Role of Dopants in Organic and Halide Perovskite Energy Conversion Devices