In the current NectarCAMEventSource, the number of gains n_gains is an argument constructor and is assumed to be the same for all events. Also it could be derived from the source.camera_config.nectarcam.algorithms parameter.
Since switching to version 4 of the event builder, this parameter is no longer filled as gain selection is enabled or not depending on the event type.
Maybe we should look how LSTEventSource handled the transition.