)

for cat, val in MAXJOBS.iteritems():
    optname = "--maxjobs-%s" % cat.lower().replace("_", "-")
    optp.add_option(optname,
                    type="int",
                    default=MAXJOBS[cat],
                    help="Set MAXJOBS in DAGs for category %s. Default is %s" %
                    (cat, str(val)))

# Options transferred to ILE
common_cl.add_datasource_params(optp)
common_cl.add_integration_params(optp)
common_cl.add_output_params(optp)
common_cl.add_intrinsic_params(optp)
common_cl.add_pinnable_params(optp)

opts, args = optp.parse_args()

if not opts.template_bank_xml:
    exit("Option --template-bank-xml is required.")

#
# Get trigger information from coinc xml file
#
# FIXME: CML should package this for us

# Get end time from coinc inspiral table or command line
xmldoc = None
if opts.coinc_xml is not None:
    xmldoc = utils.load_filename(opts.coinc_xml,
argp.add_argument("--n-copies", default=1, help="Number of copies of each integrator instance to run per mass point. Default is one.")
argp.add_argument("--write-script", action="store_true", help="In addition to the DAG, write a script to this filename to execute the workflow.")
argp.add_argument("--write-eff-lambda", action="store_true", help="Use psi0 column of template bank XML as effective lambda point to calculate in DAG.")
argp.add_argument("--write-deff-lambda", action="store_true", help="Use psi3 column of template bank XML as delta effective lambda point to calculate in DAG.")
argp.add_argument("--condor-command", action="append", help="Append these condor commands to the submit files. Useful for account group information.")

for cat, val in MAXJOBS.iteritems():
    optname = "--maxjobs-%s" % cat.lower().replace("_", "-")
    argp.add_argument(optname, type=int, default=MAXJOBS[cat], help="Set MAXJOBS in DAGs for category %s. Default is %s" % (cat, str(val)))

# Options transferred to ILE
common_cl.add_datasource_params(argp)
common_cl.add_integration_params(argp)
common_cl.add_output_params(argp)
common_cl.add_intrinsic_params(argp)
common_cl.add_pinnable_params(argp)

opts = argp.parse_args()

if not opts.template_bank_xml:
    exit("Option --template-bank-xml is required.")

condor_commands = None
if opts.condor_command is not None:
    condor_commands = dict([c.split("=") for c in opts.condor_command])

#
# Get trigger information from coinc xml file
#
# FIXME: CML should package this for us
optp.add_option("-W", "--web-output", default="./", help="Directory to place web accessible plots and webpages.")
optp.add_option("--disable-ile-postproc", action="store_true", help="Do not plot mass posteriors via plot_like_contours.")
optp.add_option("--disable-bayes-postproc", action="store_true", help="Do not plot posteriors via cbcBayesPostProc.")
optp.add_option("--n-copies", default=1, help="Number of copies of each integrator instance to run per mass point. Default is one.")
optp.add_option("--write-script", action="store_true", help="In addition to the DAG, write a script to this filename to execute the workflow.")

for cat, val in MAXJOBS.iteritems():
    optname = "--maxjobs-%s" % cat.lower().replace("_", "-")
    optp.add_option(optname, type="int", default=MAXJOBS[cat], help="Set MAXJOBS in DAGs for category %s. Default is %s" % (cat, str(val)))

# Options transferred to ILE
common_cl.add_datasource_params(optp)
common_cl.add_integration_params(optp)
common_cl.add_output_params(optp)
common_cl.add_intrinsic_params(optp)
common_cl.add_pinnable_params(optp)

opts, args = optp.parse_args()

if not opts.template_bank_xml:
    exit("Option --template-bank-xml is required.")

#
# Get trigger information from coinc xml file
#
# FIXME: CML should package this for us

# Get end time from coinc inspiral table or command line
xmldoc = None
if opts.coinc_xml is not None:
    xmldoc = utils.load_filename(opts.coinc_xml, contenthandler=ligolw.LIGOLWContentHandler)
common_cl.add_output_params(argp)

#
# Add the integration options
#
common_cl.add_integration_params(argp)

#
# Add the intrinsic parameters
#
common_cl.add_intrinsic_params(argp)

#
# Add the pinnable parameters
#
common_cl.add_pinnable_params(argp)

opts = argp.parse_args()

# Check both or neither of --data-start/end-time given
if opts.data_start_time is None and opts.data_end_time is not None:
    raise ValueError("You must provide both or neither of --data-start-time and --data-end-time.")
if opts.data_end_time is None and opts.data_start_time is not None:
    raise ValueError("You must provide both or neither of --data-start-time and --data-end-time.")

#
# Hardcoded variables
#
t_ref_wind = 50e-3 # Interpolate in a window +/- this width about event time. 
T_safety = 2. # Safety buffer (in sec) for wraparound corruption