added code for event generation and simulation