Large deviations for a class of counting processes and some statistical applications