def insert_mass_range_option_group(parser,nonSpin=False):
    """
    Adds the options used to specify mass ranges in the bank generation codes
    to an argparser as an OptionGroup. This should be used if you
    want to use these options in your code.
 
    Parameters
    -----------
    parser : object
        OptionParser instance.
    nonSpin : boolean, optional (default=False)
        If this is provided the spin-related options will not be added.
    """
    massOpts = parser.add_argument_group("Options related to mass and spin "
                  "limits for bank generation")
    massOpts.add_argument("--min-mass1", action="store", type=positive_float,
                  required=True, 
                  help="Minimum mass1: must be >= min-mass2. "
                       "REQUIRED. UNITS=Solar mass")
    massOpts.add_argument("--max-mass1", action="store", type=positive_float,
                  required=True,
                  help="Maximum mass1: must be >= max-mass2. "
                       "REQUIRED. UNITS=Solar mass")
    massOpts.add_argument("--min-mass2", action="store", type=positive_float,
                  required=True,
                  help="Minimum mass2. REQUIRED. UNITS=Solar mass")
    massOpts.add_argument("--max-mass2", action="store", type=positive_float,
                  required=True,
                  help="Maximum mass2. REQUIRED. UNITS=Solar mass")
    massOpts.add_argument("--max-total-mass", action="store",
                          type=positive_float, default=None, 
                          help="Maximum total mass. OPTIONAL, if not provided "
                          "the max total mass is determined by the component "
                          "masses. UNITS=Solar mass")
    massOpts.add_argument("--min-total-mass", action="store",
                          type=positive_float, default=None, 
                  help="Minimum total mass. OPTIONAL, if not provided the "
                       "min total mass is determined by the component masses."
                       " UNITS=Solar mass")
    massOpts.add_argument("--max-chirp-mass", action="store",
                          type=positive_float, default=None,
                  help="Maximum chirp mass. OPTIONAL, if not provided the "
                       "max chirp mass is determined by the component masses."
                       " UNITS=Solar mass")
    massOpts.add_argument("--min-chirp-mass", action="store",
                          type=positive_float, default=None,
                  help="Minimum total mass. OPTIONAL, if not provided the "
                       "min chirp mass is determined by the component masses."
                       " UNITS=Solar mass")
    massOpts.add_argument("--max-eta", action="store", type=positive_float,
                  default=0.25,
                  help="Maximum symmetric mass ratio. OPTIONAL, no upper bound"
                       " on eta will be imposed if not provided. "
                       "UNITS=Solar mass.")
    massOpts.add_argument("--min-eta", action="store", type=nonnegative_float,
                  default=0.,
                  help="Minimum symmetric mass ratio. OPTIONAL, no lower bound"
                       " on eta will be imposed if not provided. "
                       "UNITS=Solar mass.")
    massOpts.add_argument("--ns-eos", action="store",
                  default=None,
                  help="Select the EOS to be used for the NS when calculating "
                       "the remnant disk mass. Only 2H is currently supported. "
                       "OPTIONAL")
    massOpts.add_argument("--remnant-mass-threshold", action="store",
                          type=nonnegative_float, default=None,
                  help="Setting this filters EM dim NS-BH binaries: if the "
                       "remnant disk mass does not exceed this value, the NS-BH "
                       "binary is dropped from the target parameter space. "
                       "When it is set to None (default value) the EM dim "
                       "filter is not activated. OPTIONAL")
    massOpts.add_argument("--use-eos-max-ns-mass", action="store_true", default=False,
                  help="Cut the mass range of the smaller object to the maximum "
                       "mass allowed by EOS. "
                       "OPTIONAL")
    massOpts.add_argument("--delta-bh-spin", action="store",
                          type=positive_float, default=None,
                  help="Grid spacing used for the BH spin z component when "
                       "generating the surface of the minumum minimum symmetric "
                       "mass ratio as a function of BH spin and NS mass required "
                       "to produce a remnant disk mass that exceeds the threshold "
                       "specificed in --remnant-mass-threshold. "
                       "OPTIONAL (0.1 by default) ")
    massOpts.add_argument("--delta-ns-mass", action="store",
                          type=positive_float, default=None,
                  help="Grid spacing used for the NS mass when generating the "
                       "surface of the minumum minimum symmetric mass ratio as "
                       "a function of BH spin and NS mass required to produce "
                       "a remnant disk mass that exceeds the thrsehold specified "
                       "in --remnant-mass-threshold. "
                       "OPTIONAL (0.1 by default) ")
    if nonSpin:
        parser.add_argument_group(massOpts)
        return massOpts

    massOpts.add_argument("--max-ns-spin-mag", action="store",
                          type=nonnegative_float, default=None,
                  help="Maximum neutron star spin magnitude.  Neutron stars "
                       "are defined as components lighter than the NS-BH "
                       "boundary (3 Msun by default). REQUIRED if min-mass2 "
                       "< ns-bh-boundary-mass")
    massOpts.add_argument("--max-bh-spin-mag", action="store",
                          type=nonnegative_float, default=None,
                  help="Maximum black hole spin magnitude.  Black holes are "
                       "defined as components at or above the NS-BH boundary "
                       "(3 Msun by default). REQUIRED if max-mass1 >= "
                       "ns-bh-boundary-mass")
    # Mutually exclusive group prevents both options being set on command line
    # If --nsbh-flag is True then spinning bank generation must ignore the
    # default value of ns-bh-boundary-mass.
    action = massOpts.add_mutually_exclusive_group(required=False)
    action.add_argument("--ns-bh-boundary-mass", action='store',
                        type=positive_float,
                  help="Mass boundary between neutron stars and black holes. "
                       "Components below this mass are considered neutron "
                       "stars and are subject to the neutron star spin limits. "
                       "Components at/above are subject to the black hole spin "
                       "limits.  OPTIONAL, default=%f.  UNITS=Solar mass" \
                       % massRangeParameters.default_nsbh_boundary_mass)
    action.add_argument("--nsbh-flag", action="store_true", default=False,
                  help="Set this flag if generating a bank that contains only "
                       "systems with 1 black hole and 1 neutron star. With "
                       "this flag set the heavier body will always be subject "
                       "to the black hole spin restriction and the lighter "
                       "to the neutron star spin restriction, regardless of "
                       "mass.  OPTIONAL.  If set, the value of "
                       "--ns-bh-boundary-mass will be ignored.")
    return massOpts
Adds the options used to specify mass ranges in the bank generation codes
    to an argparser as an OptionGroup. This should be used if you
    want to use these options in your code.
 
    Parameters
    -----------
    parser : object
        OptionParser instance.
    nonSpin : boolean, optional (default=False)
        If this is provided the spin-related options will not be added.