#ifndef CTF_INFO_H
#define CTF_INFO_H

#define ctfInfoModeWithAmplitudeContrast    0x0f
#define ctfInfoModeWithIlluminationAngle    0x20
#define ctfInfoModeWithEnergySpread         0x40

typedef enum ctfInfoMode {
	ctfInfoModePhaseCTFOnly   = 0,
	ctfInfoModePhaseAndAmpCTF = 1 
} ctfInfoMode;

typedef struct ctfInfo {
	float kV;      /* kV */
	float defocus; /* A : Underfocus is plus, while overfocus is minus*/
	float Cc; 
	float dE; 
	float Cs;      /* mm */
	float Ain;     /* mrad : Illumination Angle */
	long  flagWin; /* Windowing */ 
	float CutLow;  /* Windowing: CutLow  A-1 */
	float CutHigh; /* Windowing: CutHigh A-1 */
	float I0;      /* Intensity */
	float ratioOfAmpToPhase; /* The ratio of amp to phase */
	float BofMTF;  /* exp(-B R) */

	long  flagWhiteNoise;
	float WhiteNoise; /* The ratio of signal to noise */

	float MolcEnv; /* A*A */

	float defocus2D[2];      /* A */
	float defocus0axis;          /* radian : angle of the defocus2D[0]-axis */

	long mode;
} ctfInfo;

#ifdef __cplusplus
extern "C" {
#endif
extern void ctfInfoSendByPVM(ctfInfo* info, int tid, long mode);
extern void ctfInfoRecieveByPVM(ctfInfo* info, int tid, long mode);
extern float ctfFunction(ctfInfo* info, float R, long mode);
extern void  ctfFunctionPVMStart(ctfInfo* info, float R, int tid, long mode);
extern float ctfFunctionPVMEnd(ctfInfo* info, float R, int tid, long mode);
extern void  ctfFunctionPVMServer();
extern float ctfEnvelopFunction(ctfInfo* info, float R, long mode);
extern float ctfFunction2D(ctfInfo* info, float X, float Y, long mode);
extern float wavelengthOfElectron(float E);
extern float defocusDeterminationFromThonRing(ctfInfo* info, float R, long n, long mode);
extern float ctfWeightForCorrection(ctfInfo* info, float R, long mode);

#ifdef __cplusplus
};
#endif

#endif
