def paramset_to_rootnames(paramset):
    """
    Generates parameter names for parameters in the set as ROOT would do.

    Args:
        paramset (:obj:`pyhf.paramsets.paramset`): The parameter set.

    Returns:
        :obj:`List[str]` or :obj:`str`: The generated parameter names
        (for the non-scalar/scalar case) respectively.

    Example:

        pyhf parameter names and then the converted names for ROOT:

        * ``"lumi"`` -> ``"Lumi"``
        * unconstrained scalar parameter ``"foo"`` -> ``"foo"``
        * constrained scalar parameter ``"foo"`` -> ``"alpha_foo"``
        * non-scalar parameters ``"foo"`` -> ``"gamma_foo_i"``

        >>> import pyhf
        >>> pyhf.set_backend("numpy")
        >>> model = pyhf.simplemodels.uncorrelated_background(
        ...     signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
        ... )
        >>> model.config.parameters
        ['mu', 'uncorr_bkguncrt']
        >>> pyhf.compat.paramset_to_rootnames(model.config.param_set("mu"))
        'mu'
        >>> pyhf.compat.paramset_to_rootnames(model.config.param_set("uncorr_bkguncrt"))
        ['gamma_uncorr_bkguncrt_0', 'gamma_uncorr_bkguncrt_1']
    """

    if paramset.name == 'lumi':
        return 'Lumi'
    if paramset.is_scalar:
        if paramset.constrained:
            return f'alpha_{paramset.name}'
        return f'{paramset.name}'
    return [f'gamma_{paramset.name}_{index}' for index in range(paramset.n_parameters)]