hate to say it, but if you had to "slam" on your breaks to avoid running a red light, then its quite obvious you really weren't paying attention to the light at the intersection.
There is plenty of time given between green, yellow, and red lights to avoid being surprised by them - if you're actually fully focused on driving and aware of what is going on at least 20 seconds ahead of you.
I'm sorry you got rear-ended, (its obvious they weren't paying attention to rules of the road and staying far enough away from you); but really, if you had been driving better, you could have avoided both a ticket and the accident.
Hope you're all right.