It's entirely possible that both factors are playing a role in your daughter's behavior. Since you've noticed the asociation between certain foods and her behavior, be sure to eliminate those foods. Caffeine can be a powerful stimulant to children and a catalst to disorganized and sometimes aggressive behavior. Also, be sure to set limits on her aggressive behavior. If this occurs on the train, you'll likely have to wait until you arrive at your home, but at that point be sure to sit her in a chair for time out and let her know that you will not permit any behavior that is harmful. Keep in mind, too, that at the end of the day small children are really depleted and will have a much more difficult time coping than at other times.
Yes I babysit for a little boy with autism, if given chocolate (specifically milk chocalate)(and various other foods, mainly of the sugary variety) who becomes extremely violent, and his behaviour becomes unmanageable if he eats these foods. i didn't believe it at first, I've always been of the theory that behaviour is linked to how a child is feeling about something (ie anger, resentment etc) but I certainly found out for myself when he had chocolate the next time!