calculations in event.cpp