#!/bin/bash
echo "This will take a while ... grab a coffee/tea/water/cocktail"
mkdir -p logs
fit_var="M3,angle_bl"
nice_fit_var=`echo $fit_var | sed 's/,/_/g'`
N_JOBS=6

echo "Using the fit variable(s): $fit_var"

i=0
for var in MET HT ST WPT MT lepTopPt lepTopRap hadTopPt hadTopRap ttbarPt ttbarM ttbarRap; do
	echo "Fitting distribution: $var"
	nohup time python dps/analysis/xsection/01_get_fit_results.py -V -v $var --fit-variables $fit_var &> logs/01_${var}_fit_13TeV_${nice_fit_var}.log &
	let i+=1
	if (( $i % N_JOBS == 0 ))
	then
		echo "Waiting on the above to finish."
    	wait;
	fi
done

wait;
echo "All done! Time to run x_02_all_vars."
