#!/bin/bash

#Use as ./rerunBasic.sh RUN

E_NO_ARGS=65
if [ $# -eq 1 ]  # Must have one command-line argument (run number)
then
    run=$1
    echo "Rerruning everything for Run $run"
else
    echo "Please invoke this script with one command-line argument in the following format:"
    echo "./rerunBasic.sh RUN"
    exit $E_NO_ARGS
fi

if [ $run = 12 ]
then
    python run.py -convert -all -Run 1
    python run.py -dontCompile -convert -all -Run 2 
    python run.py -dontCompile -MC -angCorr -Run 1 -scan
    python run.py -dontCompile -MC -angCorr -Run 2 -scan
    python run.py -dontCompile -MC -angCorr -Run 1 
    python run.py -dontCompile -MC -angCorr -Run 2 
    python run.py -dontCompile -MC -angRes -Run 1
    python run.py -dontCompile -MC -angRes -Run 2
    python run.py -dontCompile -MC -Run 12 -fit -Ref -nBins 1;
    python run.py -dontCompile -MC -Run 12 -fit -nBins 5;
    python run.py -dontCompile -Data -Run 12 -fit -Ref -nBins 1 -massDim;
    python run.py -dontCompile -Data -Run 12 -fit -nBins 5 -massDim;
    python run.py -dontCompile -Data -Run 12 -fit -Ref -nBins 1 -bkgOnly -upper;
    python run.py -dontCompile -Data -Run 12 -fit -nBins 5 -onlyBkg -upper;
    python run.py -dontCompile -Run 12 -v 2 -fit -Ref -nBins 1 -genMC -Ref
    python run.py -dontCompile -Run 12 -v 2 -fit -nBins 5 -genMC
else   
    python run.py -convert -all -Run $run
    python run.py -dontCompile -MC -angCorr -Run $run -scan
    python run.py -dontCompile -MC -angCorr -Run $run
    python run.py -dontCompile -MC -angRes -Run $run
    python run.py -dontCompile -MC -Run $run -fit -Ref -nBins 1;
    python run.py -dontCompile -MC -Run $run -fit -nBins 5;
    python run.py -dontCompile -Data -Run $run -fit -Ref -nBins 1 -massDim;
    python run.py -dontCompile -Data -Run $run -fit -nBins 5 -massDim;
    python run.py -dontCompile -Data -Run $run -fit -Ref -nBins 1 -bkgOnly -upper;
    python run.py -dontCompile -Data -Run $run -fit -nBins 5 -onlyBkg -upper;
    python run.py -dontCompile -Run $run -v 2 -fit -Ref -nBins 1 -genMC -Ref
    python run.py -dontCompile -Run $run -v 2 -fit -nBins 5 -genMC
fi

echo "All done"

