Electron and photon measurement with the CMS detector