Fighting traffic tickets
Tickets may be issued for moving violations (such as failing to stop), or for inadequate bike equipment (lights, for example). You can't receive demerit points on your driver's licence for tickets received while on a bicycle.
Don't escalate the situation by yelling, etc. Stay calm, it's just a ticket. You will be able to fight it. Don't assume that as a "law-abiding citizen" you can't be criminally charged just for being annoying. It has happened and it sucks. If necessary, there is a police complaints process.
Write down what happened as soon as possible after receiving the ticket. Include the location, direction of travel, the incident, witnesses, etc. Obtain as much information as possible at the scene. Sign and date it.
Call for witnesses: It is very hard to get them later. Get their phone number or contact information. Ask them to make a signed and dated statement of events as soon as possible. All of the information you need about your charge and the officer (such as badge number and division) should be on your ticket.