/*! \file focus3d_parameters.h
		\author Vishnu Krishnamachari
		\date June 2006 - May 2008
		\brief Defines focus3d_parameters class.
		
		Defines the class focus3d_parameters that should be used to generate objects of the focus3d and dipole_radiation classes.
*/

#ifndef __FOCUS3D_PARAMETERS_H__
#define __FOCUS3D_PARAMETERS_H__

#include "precompile.h"

//! A class.
/*!		
		Use the objects of this class to pass the input values to objects of the focus3d and the dipole_radiation classes. 
			
		The data members of this class correspond to the simulation parameters such as the number of the grid points as well as the minium and the maximum coordinates along x, y, z, theta (polar angle), and phi (azimuthal angle) directions. This member list also includes the focal length (f) of the lens and the wavelength (lambda) of light. The units of all angles is radians and the units of lengths is in \f$\mu m\f$. All the data members are public and hence can be set from the program. 
			 
		To assist in filling in the values of the data members the previously stored values of the parameters can be loaded using the the constructor focus3d_parameters(string filename) of the method load(string filename). The parameters can also be saved in an ascii file using the method save(string outfilename). Programmer would generally use these three methods. But for futher assistance a few more methods are provided.
			 
		If the programmer does not know how to generate a parameters file, a method, set_default(), is provided which will set default values to the data members; these values can be eventually saved using save() or can be summarized using print() methods.  The sanity of the parameters can be tested using the method test() which will return a false if the parameters do not pass certain intuitive and obvious conditions.  
			 
		Note: 
			- theta_min and theta_max correspond to the limits of integration along polar angle
			- phi_min and phi_max correspond to the limits of integration along azimuthal angle
*/
class focus3d_parameters
	{
public:
	int Nx; 					/*!< Number of x-points*/
	int Ny;						/*!< Number of y-points*/
	int Nz;						/*!< Number of z-points*/
	int Ntheta;				/*!< Number of theta-points*/
	int Nphi;					/*!< Number of phi-points*/
	double xmin;			/*!< minimum value of x in microns*/
	double xmax;			/*!< maximum value of x in microns*/
	double ymin;			/*!< minimum value of y in microns*/
	double ymax;			/*!< maximum value of y in microns*/
	double zmin;			/*!< minimum value of z in microns*/
	double zmax;			/*!< maximum value of z in microns*/
	double theta_min;	/*!< minimum value of theta in rad - lower limit of integration*/
	double theta_max;	/*!< maximum value of theta in rad - upper limit of integration*/
	double phi_min;		/*!< minimum value of phi in rad - lower limit of integration*/
	double phi_max;		/*!< maximum value of phi in rad - upper limit of integration*/
	double lambda;		/*!< wavelength in microns*/
	double f; 				/*!< focal length of the lens in microns*/

	//! A Constructor.
	/*! 
	A constructor that sets all the data members to zero.
	*/
	focus3d_parameters();
	//---------------------------------------------------------
	
	//! A Constructor.
	/*! 
	A constructor loads the data memebers from an external file 'filename'. Internally this constructor calls the load() method of this class.
	
	\param filename - a std::string containing the name of the parameter file  
	*/
	focus3d_parameters(string filename);
	//---------------------------------------------------------
	
	//! A method for loading parameters from a file.
	/*! 
	A method for loading the data members from an ascii file 'filename'. The format of this ascii file is as follows. It contains the values of the data members one in each line in the order: lambda, f, Nx, Ny, Nz, Ntheta, Nphi, xmin, xmax, ymin, ymax, zmin, zmax, theta_min, theta_max, phi_min, phi_max.
	
	\param filename - a std::string containing the name of the parameter file  
	\return result -  a bool : true if loaded, false if unable to load the parameters.
	*/
	bool load(string filename);
	//---------------------------------------------------------
	
	//! A method for saving parameters to a file.
	/*!
	Saves the data members of this class to a parameter file. The format of this ascii file is as follows. It contains the values of the data members one in each line in the order: lambda, f, Nx, Ny, Nz, Ntheta, Nphi, xmin, xmax, ymin, ymax, zmin, zmax, theta_min, theta_max, phi_min, phi_max.
	
	\param filename - a std::string conatining the name of the parameter file
	\return result -  a bool : true if saved successfully, false if not successful.
	*/
	bool save(string filename);
	//---------------------------------------------------------
	
	//! A method for printing parameters to the screen.
	/*!
	Prints the current data members of this class to the screen. 
	*/
	void print();
	//---------------------------------------------------------
	
	//! A method for testing the sanity of the current parameters.
	/*!
	Tests if the parameters meet certain obvious conditions such as xmin < xmax, Nx > 0, etc.
	
	\return result - a bool : true if parameters are sane, false otherwise. 	
	*/
	bool test();
	//---------------------------------------------------------
	
	//! A method for setting default values..
	/*!
	Sets default and sane values to the parameters of this object. This method can be used initially to generate a valid parameter file and then modify it according to the needs. 	
	*/
	void set_default();
	//---------------------------------------------------------
	
	//! Overloaded "=" operator.
	/*!
	Overloads the equal-to operator.	
	*/
	focus3d_parameters& operator= (const focus3d_parameters& fp);
	
	//---------------------------------------------------------
	//! Overloaded "==" operator.
	/*!
	Overloads the == operator.	
	*/
	bool operator==(const focus3d_parameters& fp) const;
	
	//---------------------------------------------------------
	//! Overloaded "!=" operator.
	/*!
	Overloads the != operator.	
	*/
	bool operator!=(const focus3d_parameters& fp) const;
 };

#endif
