Development and application of ab initio methods for the study of electronic excitations in molecules and extended solids : GW approximation and constrained DFT