There are two forces to consider when dealing with a vertical loop. Those are the weight of the cart and the centripetal force. The centripetal force is found by the equation: Fc = m(v*v/r). The veloocity at any height is found by using the conservation of energy equations. Don't forget to include the rotational and translational kiinetic energies.
In order for the ball to remain on the track it must have a centripetal force which is equal to or greater than its weight.