These two lines should be outside the if-statement (if the event is real data, then the weight put in it should be 1).