in rajdhani express and all, there is oven and all and for such things working, the current cannot be self generated by the compartments. ANd hence the AC, working of ovens, chillers, and lights need electricty which will be obtained by EOG.
In other trains, there is an alternator which is connected to the battery which will be sufficient to produce enough current to the respective coaches