#!/bin/tcsh -f

set dirs="12degrees 20degrees 90degrees"

foreach d ($dirs)

	# Change to specific directory
	cd $d

	# Run 1st pass
	foreach s (LAYERS*)
		cd $s
		#nice +10 hd_root --config=jana.conf ../sim_photon.hddm
		root -l -q ../../macros/timewalk_calibrate.C++
		cd -
	end
	
	# Copy timewalk calibrations into plugin directory
	cp LAYERS_*/timewalk_*.h bcal_timing*
	
	# Recompile plugin
	cd bcal_timing*
	make
	cd ..
		
	# Run 2nd pass
	foreach s (LAYERS*)
		cd $s
		nice +10 hd_root --config=jana.conf ../sim_photon.hddm
		../../run_one.csh
		cd -
	end
	
	# Change back to top directory
	cd ..

end
