MARBLEHEAD – Police Sgt. Marion Keating, the town’s first female officer, will receive $40,000 toward her legal costs as part of the settlement of her U.S. District Court sex discrimination case.The payments, which will be made directly to the Cambridge office of Keating’s lawyer, Attorney David Belfort, include $20,000 during the current fiscal year and $20,000 in Fiscal 2011 – in other words, after June 30.In addition to the partial payment of her legal fees, Keating retains her assignment as joint School Attendance/Truant Officer, which carries a $600 stipend, and receives two new appointments, Co-Juvenile Officer and Youth and Victim Services Officer, which carry annual stipends of $400 each. Youth and Victim Services Officer is described as a new position.Keating filed the lawsuit after her alleged demotion from detective in charge of the department’s Criminal Investigation Division to patrol supervision in July 2007.The case was resolved under a mutual agreement of confidentiality Oct. 29, reviewed by the police union and subsequently approved by selectmen Dec. 9.