#!/usr/bin/env python

import sys
import os
import inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
grand_parentdir = os.path.dirname(os.path.dirname(currentdir))
sys.path.insert(0, grand_parentdir)
import sconstruct_utils as su
from SCons.Script import Environment, Decider, ADD_BUILDERS, main

env = Environment(ENV=os.environ, tools=['default', ADD_BUILDERS])
# We use timestamps instead of MD5s since hepmc's are big
Decider('timestamp-match')

base_analysis = 'WHIZARD_2W2b_NLO'
analysiss = [base_analysis]
env['NUMTHREADS'] = '4'
env['ANALYSIS'] = base_analysis
configs = [base_analysis, base_analysis + '-show-MCerrors']
configs = [c + '.plot' for c in configs]
configs = ['WHIZARD_threshold.plot']
processes = ['proc_lo', 'proc_lo_thresholdparams', 'unity', 'fact_lo',
             'fact_decayonshellprojected_lo',
             'proc_nlo_low_Born', 'proc_nlo_central_Born', 'proc_nlo_high_Born',
             'proc_nlo_low_Virtual', 'proc_nlo_central_Virtual', 'proc_nlo_high_Virtual',
             'proc_nlo_low_Real', 'proc_nlo_central_Real', 'proc_nlo_high_Real',
             'proc_nlo_low_Mismatch', 'proc_nlo_central_Mismatch',
             'proc_nlo_high_Mismatch']
processes = ['proc_lo_thresholdparams', 'unity', 'fact_lo',
             'fact_decayonshellprojected_lo']
for p in list(processes):
  for mult in ['350', '10000']:
    processes += [p + mult]

plot_together = [{'target': 'plots',
                  'lines': ['proc_lo_thresholdparams',
                            'fact_lo',
                            'fact_decayonshellprojected_lo']},
              {'target': 'plots350',
                'lines': ['proc_lo_thresholdparams350',
                          'fact_lo350',
                          'fact_decayonshellprojected_lo350']},
                {'target': 'plots10000',
                  'lines': ['proc_lo_thresholdparams10000',
                            'fact_lo10000',
                            'fact_decayonshellprojected_lo10000']}
                  ]
descriptions = [r"\textsc{LO}", r"factorized", r"factorized,decay onshellprojected"]
lo_nlo_lines_and_nlo_band = []
# lo_nlo_lines_and_nlo_band = ['proc_lo.yoda', 'proc_nlo_central.yoda',
#         'envelope.yoda']

main(env, analysiss, processes, plot_together, configs,
    lo_nlo_lines_and_nlo_band, descriptions)
