#! /usr/bin/env python

"""
Run a simple test instance of the evaluation module.

This script can be used as a basis for a more complete routine to
evaluate cross sections.

Use: xsec-test <directory-for-xsec-data>
    If no argument <directory-for-xsec-data> is given, the code looks
    for a folder called 'gprocs' in the current working directory.
"""

import os
import sys

# Import xsec, first assume we have pip installed it
try:
    import xsec
# Someone is using our fine programme without pip installing
except ImportError:
    # Our current absolute directory
    abs_dir = os.path.dirname(os.path.abspath(__file__))
    # Parent directory containing xsec
    parent_dir = os.path.dirname(abs_dir)
    sys.path.append(parent_dir)
    import xsec

try:
    input_dir = sys.argv[1]
except IndexError:
    # By default, look for './gprocs'
    cwd = os.getcwd()
    input_dir = os.path.join(cwd, "gprocs")

# Set directory and cache choices
xsec.init(data_dir=input_dir)  # run with default settings (no caching)

# Set center-of-mass energy (in GeV)
xsec.set_energy(13000)

# Load GP models for the specified process(es)
processes = [(1000021, 1000021)]
xsec.load_processes(processes)

# Enter parameter values
xsec.set_parameters(
    {
        "m1000021": 1000,
        "m1000001": 500,
        "m1000002": 500,
        "m1000003": 500,
        "m1000004": 500,
        "m1000005": 500,
        "m1000006": 500,
        "m2000001": 500,
        "m2000002": 500,
        "m2000003": 500,
        "m2000004": 500,
        "m2000005": 500,
        "m2000006": 500,
        "sbotmix11": 0,
        "stopmix11": 0,
        "mean": 500,
    }
)

# Evaluate the cross section with the given input parameters
xsec.eval_xsection()

# Finalise the evaluation procedure
xsec.finalise()
