Added new function for weighted event selection