bc_stage2_acc.tcl: ../mad8/bc_stage2_acc.mad
	mkdir -p tmp;\
	cd tmp;\
	mad -8 < ../../mad8/bc_stage2_acc.mad;\
	tclsh ~/placet-development/tools/mad2placet/madoptics3.tcl;\
	cat  lattice.tcl | grep -v Girder  > lattice2.tcl;\
	sed -e 's/Drift -name AC/Cavity -6d 1 -length 1.0 -gradient $$gradient -phase 90 -type 0 -name AC/g' lattice2.tcl > lattice3.tcl;\
	sed -e 's/Drift .* \-l 0.00000/# &/g' lattice3.tcl > lattice4.tcl;\
	sed -e 's/-l 0.00000//' lattice4.tcl > lattice5.tcl;\
	sed 's/ -aperture elliptic -apx  -apy //' lattice5.tcl > lattice6.tcl;\
	cp lattice6.tcl ../bc_stage2_acc.tcl;


clean:
	rm -rf bc_stage2_acc.tcl tmp
