A complete simulation of a triple-GEM detector