Study of the demagnetization and optimization of the magnetic field of perpendicular ferromagnetic thin films usingesub-μ m lithography