#!/bin/bash
# Helper functions
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 "Unfolding distribution: $var"
	nohup time python dps/analysis/xsection/02_unfold_and_measure.py --visiblePS -v $var -c 13 -p data/normalisation/background_subtraction/ &> logs/02_${var}_Vis_unfold_13TeV.log &
	let i+=1
	shallIwait $i $N_JOBS
done

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