#ifndef SVREACTION_H
#define SVREACTION_H

//-----------------------------------------------------------------------------
//
//  Peter Richter (prichter@princeton.edu)
//  Princeton Plasma Physics Laboratory
//  August 2000
//
//  svreaction.h - Interface for stopping <sigma*v> reaction class.
//     used for impurity stopping cross-sections:  sum of cx + ii
//     "sigvTe table" sigma*v(Erel/A) only.
//
//-----------------------------------------------------------------------------

#include "preact/grid_1d.h"
#include "preact/grid_2d.h"

class SVReaction {

public:    // constructor, destructor...
           SVReaction(char tag[], int errlo = WARN, int errhi = HALT);
	   ~SVReaction();

	   // sigma, vrel as functions of Erel...
           fp_64 sigmav(fp_64 Erel);

	   // sigma*v for beam to cold (T=0) target...
	   void coldTarget_sigmaTimesV(fp_64 E[], fp_64 f[], int n);
	   range coldTarget_ERange() const;
	   void coldTarget_EPolicy(int errlo, int errhi);

protected: // auxiliary functions...
	   void setTableParameters(char dir[]);
	   void computeAxis(fp_64 axis[], int npts, range endpts, int spac);
	   void compute1DTable(grid_1D& g, char file[]);
	   void read1DTable(grid_1D& g, char file[]);
	   void interp1DTable(char table[], grid_1D& g,
			      fp_64 x[], char xdim[],
			      fp_64 f[], int n);
	   void g_tablefile(char table[], char file[]);
	   void range_error_exit(char table[]);
	   void range_error_warn(char table[]);

	   // data members...

	   grid_1D coldTarget_data;
	   int errlo, errhi;
	   int code;
	   int Zimp, Zplas;
};

//-----------------------------------------------------------------------------

#endif
