Beam-based alignment at the Cooler Synchrotron COSY as a prerequisite for an electric dipole moment measurement