#include "radiation_from_focal_volume.h"

/** \example radiation_from_focal_volume.cpp
	This is an example of how to generate the radiation from the focal volume.
*/
int main(int argc, char** argv)
	{
	if(argc < 3)
		{
		cerr << "Usage: " << argv[0] << " <parameters file> <output directory>\n";
		exit(-1);
		}
	string param_file = argv[1];
	string outputdir = argv[2];

	focus3d_parameters p;
	if(!p.load(param_file)) {exit (-1);} // load the parameters file

	Array<complex<double>,2> E_rad_x, E_rad_y, E_rad_z;
	E_rad_x.resize(p.Ntheta,p.Nphi);
	E_rad_y.resize(p.Ntheta,p.Nphi);
	E_rad_z.resize(p.Ntheta,p.Nphi);
	E_rad_x = 0.0;
	E_rad_y = 0.0;
	E_rad_z = 0.0;

	dipole_radiation drad(p);
	drad.set_dipole_field("successive/focus1_lambda_0.8/E_focus_x.bar", \
	                      "successive/focus1_lambda_0.8/E_focus_y.bar", \
	                      "successive/focus1_lambda_0.8/E_focus_z.bar");
	drad.calculate_refracted_radiation(E_rad_x,E_rad_y,E_rad_z);
	drad.save_results(outputdir);

	return(0);
	}
