#!/bin/bash
shallIwait() {
	if (( $1 % $2 == 0 ))
	then
		echo "Waiting on the above to finish."
    	wait;
	fi
}
echo "This will take a while ... grab a coffee/tea/water"
mkdir -p logs
N_JOBS=4

i=0

echo "Visible phase space"
for var in MET HT ST WPT lepton_pt abs_lepton_eta NJets; do
	echo "Calculating diff. x-section for distribution: $var"
	nohup time python dps/analysis/xsection/03_calculate_systematics.py --visiblePS  -s -v $var -c 13 -u TUnfold -p data/normalisation/background_subtraction/ &> logs/03_${var}_calculate_Vis_13TeV.log &
	let i+=1
	shallIwait $i $N_JOBS
done

wait;
echo "All done! Time to run x_04b_all_vars and x_05b_all_vars."
