A method for the automatic analysis of gamma ray events in astronomical spark chambers