19 #ifndef _OBJCRYST_SCATTERINGDATA_H_ 
   20 #define _OBJCRYST_SCATTERINGDATA_H_ 
   22 #include "ObjCryst/CrystVector/CrystVector.h" 
   24 #include "ObjCryst/ObjCryst/General.h" 
   26 #include "ObjCryst/ObjCryst/SpaceGroup.h" 
   27 #include "ObjCryst/ObjCryst/ScatteringPower.h" 
   28 #include "ObjCryst/ObjCryst/Scatterer.h" 
   29 #include "ObjCryst/ObjCryst/Crystal.h" 
   41 #ifndef HAVE_SSE_MATHFUN 
   43 void InitLibCrystTabulCosine();
 
   44 void DeleteLibCrystTabulCosine();
 
   45 void InitLibCrystTabulExp();
 
   46 void DeleteLibCrystTabulExp();
 
   83 extern const RefParType *gpRefParTypeRadiation;
 
   84 extern const RefParType *gpRefParTypeRadiationWavelength;
 
   93             #ifndef HAVE_SSE_MATHFUN 
   94             InitLibCrystTabulCosine();
 
   95             InitLibCrystTabulExp();
 
   99             gpRefParTypeScattDataProfile= 
new RefParType(gpRefParTypeScattData,
"Profile");
 
  100             gpRefParTypeScattDataProfileType= 
new RefParType(gpRefParTypeScattDataProfile,
"Type");
 
  101             gpRefParTypeScattDataProfileWidth= 
new RefParType(gpRefParTypeScattDataProfile,
"Width");
 
  102             gpRefParTypeScattDataProfileAsym= 
new RefParType(gpRefParTypeScattDataProfile,
"Asymmetry");
 
  103             gpRefParTypeScattDataCorr= 
new RefParType(gpRefParTypeScattData,
"Correction");
 
  104             gpRefParTypeScattDataCorrInt= 
new RefParType(gpRefParTypeScattDataCorr,
"Intensities");
 
  105             gpRefParTypeScattDataCorrIntPO_Direction= 
new RefParType(gpRefParTypeScattDataCorrIntPO_Direction,
"Preferred orientation direction");
 
  106             gpRefParTypeScattDataCorrIntPO_Fraction= 
new RefParType(gpRefParTypeScattDataCorrIntPO_Fraction,
"Preferred orientation fraction");
 
  107             gpRefParTypeScattDataCorrIntPO_Amplitude= 
new RefParType(gpRefParTypeScattDataCorrIntPO_Amplitude,
"Preferred orientation amplitude");
 
  108             gpRefParTypeScattDataCorrInt_Ellipsoid= 
new RefParType(gpRefParTypeScattDataCorrInt_Ellipsoid,
"Preferred orientation ellipsoid");
 
  109             gpRefParTypeScattDataCorrIntAbsorp= 
new RefParType(gpRefParTypeScattDataCorrInt,
"Absorption");
 
  110             gpRefParTypeScattDataCorrIntPolar= 
new RefParType(gpRefParTypeScattDataCorrInt,
"Polarization");
 
  111             gpRefParTypeScattDataCorrIntExtinc= 
new RefParType(gpRefParTypeScattDataCorrInt,
"Extinction");
 
  112             gpRefParTypeScattDataCorrPos= 
new RefParType(gpRefParTypeScattDataCorr,
"Reflections Positions");
 
  113             gpRefParTypeScattDataBackground= 
new RefParType(gpRefParTypeScattData,
"Background");
 
  115             gpRefParTypeRadiationWavelength= 
new RefParType(gpRefParTypeRadiation,
"Wavelength");
 
  122             #ifndef HAVE_SSE_MATHFUN 
  123             DeleteLibCrystTabulCosine();
 
  124             DeleteLibCrystTabulExp();
 
  139             delete gpRefParTypeRadiation;
 
  140             delete gpRefParTypeRadiationWavelength;
 
  141             gpRefParTypeScattData=0;
 
  142             gpRefParTypeScattDataScale=0;
 
  143             gpRefParTypeScattDataProfile=0;
 
  144             gpRefParTypeScattDataProfileType=0;
 
  145             gpRefParTypeScattDataProfileWidth=0;
 
  146             gpRefParTypeScattDataProfileAsym=0;
 
  147             gpRefParTypeScattDataCorr=0;
 
  148             gpRefParTypeScattDataCorrInt=0;
 
  149             gpRefParTypeScattDataCorrIntAbsorp=0;
 
  150             gpRefParTypeScattDataCorrIntPolar=0;
 
  151             gpRefParTypeScattDataCorrIntExtinc=0;
 
  152             gpRefParTypeScattDataCorrPos=0;
 
  153             gpRefParTypeScattDataBackground=0;
 
  154             gpRefParTypeRadiation=0;
 
  155             gpRefParTypeRadiationWavelength=0;
 
  204       Radiation(
const string &XRayTubeElementName,
const REAL alpha2Alpha2ratio=0.5);
 
  244       void SetWavelength(
const string &XRayTubeElementName,
const REAL alpha2Alpha2ratio=0.5);
 
  255       virtual void XMLOutput(ostream &os,
int indent=0)
const;
 
  260       REAL GetLinearPolarRate()
const;
 
  261       void SetLinearPolarRate(
const REAL f);
 
  319       virtual void SetHKL( 
const CrystVector_REAL &h,
 
  320                            const CrystVector_REAL &k,
 
  321                            const CrystVector_REAL &l);
 
  338                                    const bool unique=
false);
 
  358                                    const bool unique=
false);
 
  379       const CrystVector_REAL& 
GetH() 
const;
 
  381       const CrystVector_REAL& 
GetK() 
const;
 
  383       const CrystVector_REAL& 
GetL() 
const;
 
  386       const CrystVector_REAL& 
GetH2Pi() 
const;
 
  389       const CrystVector_REAL& 
GetK2Pi() 
const;
 
  392       const CrystVector_REAL& 
GetL2Pi() 
const;
 
  394       const CrystVector_REAL& 
GetReflX() 
const;
 
  396       const CrystVector_REAL& 
GetReflY() 
const;
 
  398       const CrystVector_REAL& 
GetReflZ() 
const;
 
  404       const CrystVector_REAL& 
GetTheta()
const;
 
  410       std::map<RefinablePar*, CrystVector_REAL> & GetFhklCalcSq_FullDeriv(std::set<RefinablePar *> &vPar);
 
  449                                      const bool enableRestraints=
false);
 
  489          virtual const CrystMatrix_REAL& 
GetBMatrix()
const;
 
  514       void CalcStructFactor_FullDeriv(std::set<RefinablePar *> &vPar);
 
  520       void CalcGeomStructFactor_FullDeriv(std::set<RefinablePar*> &vPar);
 
  534       CrystVector_REAL 
mH, mK, mL ;
 
  536       mutable CrystVector_long 
mIntH, mIntK, mIntL ;
 
  538       mutable CrystVector_REAL 
mH2Pi, mK2Pi, mL2Pi ;
 
  540       mutable CrystVector_REAL 
mX, mY, mZ ;
 
  553       mutable std::map<RefinablePar*, CrystVector_REAL> mFhklCalcReal_FullDeriv, mFhklCalcImag_FullDeriv ;
 
  556       mutable std::map<RefinablePar*, CrystVector_REAL> mFhklCalcSq_FullDeriv;
 
  595          mutable map<const ScatteringPower*,REAL> 
mvFprime,mvFsecond;
 
  604          mutable map<const ScatteringPower*,CrystVector_REAL> 
mvRealGeomSF,mvImagGeomSF;
 
  605          mutable map<RefinablePar*,map<const ScatteringPower*,CrystVector_REAL> > mvRealGeomSF_FullDeriv,mvImagGeomSF_FullDeriv;
 
  687 #endif // _OBJCRYST_SCATTERINGDATA_H_ 
const RefinableObjClock & GetClockNbReflBelowMaxSinThetaOvLambda() const 
Clock the last time the number of reflections used was changed. 
const CrystVector_REAL & GetH() const 
Return the 1D array of H coordinates for all reflections. 
void Print() const 
Print to screen/console the charcteristics of the radiation. 
const CrystVector_REAL & GetFhklCalcImag() const 
Access to imaginary part of F(hkl)calc. 
map< const ScatteringPower *, CrystVector_REAL > mvRealGeomSF
Geometrical Structure factor for each ScatteringPower, as vectors with NbRefl elements. 
virtual long GetNbReflBelowMaxSinThetaOvLambda() const 
Recalc, and get the number of reflections which should be actually used, due to the maximuml sin(thet...
RefinableObjClock mClockGeomStructFact
Clock the last time the geometrical structure factors were computed. 
map< const ScatteringPower *, REAL > mvFprime
Anomalous X-Ray scattering term f' and f" are stored here for each ScatteringPower We store here only...
bool mIgnoreImagScattFact
Ignore imaginary part of scattering factor. 
REAL mXRayTubeDeltaLambda
Absolute difference between alpha1 and alpha2, in angstroems. 
RefinableObjClock mClockHKL
Clock for the list of hkl. 
RadiationType GetRadiationType() const 
Neutron or x-ray experiment ? Wavelength ? 
const CrystVector_REAL & GetSinThetaOverLambda() const 
Return an array with  for all reflections. 
RefObjOpt mWavelengthType
monochromatic ? Alpha1 & Alpha2 ? Multi-Wavelength ? 
void CalcGlobalTemperatureFactor() const 
Compute the overall temperature factor affecting all reflections. 
const RefParType * gpRefParTypeScattDataCorrInt
Generic type for correction to calculated intensities. 
RefinableObjClock mClockNbReflUsed
Clock recording the last time the number of reflections used has increased. 
const CrystVector_REAL & GetTheta() const 
Return an array with theta values for all reflections. 
virtual void PrepareHKLarrays()
const RefParType * gpRefParTypeScattDataCorrPos
Parameter type for correction to peak positions. 
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream. 
RefinableObjClock mClockScattFactor
Clock the last time scattering factors were computed. 
CrystVector_REAL mGlobalTemperatureFactor
Global Biso factor. 
REAL mMaxSinThetaOvLambda
Maximum sin(theta)/lambda for all calculations (10 by default). 
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
virtual void CalcSinThetaLambda() const 
virtual void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
This should be called by any optimization class at the begining of an optimization. 
CrystVector_REAL GetWavelength() const 
wavelength of the experiment (in Angstroems) 
REAL mLinearPolarRate
Linear Polarization Rate (default:0, X-Ray tube unmonochromatized) 
REAL GetMaxSinThetaOvLambda() const 
Get the maximum value for sin(theta)/lambda. 
CrystVector_REAL mFhklCalcVariance
The variance on all calculated structure factors, taking into account the positionnal errors and the ...
virtual void CalcResonantScattFactor() const 
bool HasCrystal() const 
Has a Crystal structure associated yet ? 
REAL mXRayTubeAlpha2Alpha1Ratio
Ratio alpha2/alpha1 (should be 0.5) 
const RefinableObjClock & GetClockRadiation() const 
Last time the nature (X-Rays/Neutron, number of wavelengths)radiation has been changed. 
RefinableObjClock mClockStructFactor
Clock for the structure factor. 
const RefParType * gpRefParTypeScattDataCorrInt_Ellipsoid
Parameter type for the ellipsoid coefficient. 
string mXRayTubeName
Name of the X-Ray tube used, if relevant. 
long mNbRefl
Number of H,K,L reflections. 
virtual void PrintFhklCalcDetail(ostream &os=cout) const 
Print H, K, L sin(theta)/lambda theta F^2 Re(F) Im(F) [Re(F) Im(F)]_i, where [Re(F) Im(F)]_i are the ...
virtual void SetCrystal(Crystal &crystal)
Set the crystal for this experiment. 
CrystVector_REAL mWavelength
Wavelength of the Experiment, in Angstroems. 
const RefParType * gpRefParTypeScattDataProfile
Type for reflection profile. 
map< const ScatteringPower *, CrystVector_REAL > mvTemperatureFactor
Thermic factors for each ScatteringPower, as vectors with NbRefl elements. 
const RefParType * gpRefParTypeScattDataProfileAsym
Type for reflection profile asymmetry. 
RadiationType GetRadiationType() const 
Get the radiation type (X-Rays, Neutron) 
CrystVector_REAL mH2Pi
H,K,L coordinates, multiplied by 2PI. 
Class to compute structure factors for a set of reflections and a Crystal. 
virtual const Radiation & GetRadiation() const =0
Get the radiation object for this data. 
const RefinableObjClock & GetClockWavelength() const 
Last time the wavelength has been changed. 
Radiation()
Default constructor. 
const CrystVector_REAL & GetL() const 
Return the 1D array of L coordinates for all reflections. 
Generic Refinable Object. 
const RefParType * gpRefParTypeScattDataScale
Type for scattering data scale factors. 
CrystVector_int mMultiplicity
Multiplicity for each reflections (mostly for powder diffraction) 
virtual void GenHKLFullSpace2(const REAL maxsithsl, const bool unique=false)
Generate a list of h,k,l to describe a full reciprocal space, up to a given maximum theta value...
RefinableObjClock mClockTheta
Clock the last time theta was computed. 
void CalcGeomStructFactor() const 
Compute the 'Geometrical Structure Factor' for each ScatteringPower of the Crystal. 
map< const ScatteringPower *, CrystVector_REAL > mvLuzzatiFactor
The Luzzati 'D' factor for each scattering power and each reflection. 
const CrystVector_REAL & GetReflZ() const 
Return the 1D array of orthonormal z coordinates for all reflections (recipr. space) ...
virtual void GenHKLFullSpace(const REAL maxTheta, const bool unique=false)
Generate a list of h,k,l to describe a full reciprocal space, up to a given maximum theta value...
virtual CrystVector_long SortReflectionBySinThetaOverLambda(const REAL maxSTOL=-1.)
const RefParType * gpRefParTypeScattDataBackground
Parameter type for background intensity. 
Abstract base class for all objects in wxCryst. 
REAL GetXRayTubeDeltaLambda() const 
Get the wavelength difference for Alpha1 and Alpha2. 
CrystVector_REAL mTheta
theta for the crystal and the HKL in ReciprSpace (in radians) 
WX Class for PowderPattern objects. 
const RefParType * gpRefParTypeScattDataCorrIntPO_Amplitude
Parameter type for the amplitude of preferred orientation. 
RefinableObjClock mClockThermicFact
Clock the last time temperature factors were computed. 
void CalcStructFactor() const 
Compute the overall structure factor (real and imaginary part). 
CrystVector_REAL mH
H,K,L coordinates. 
virtual const CrystMatrix_REAL & GetBMatrix() const 
Get access to the B matrix used to compute reflection positions. 
const map< const ScatteringPower *, CrystVector_REAL > & GetScatteringFactor() const 
Scattering factors for each ScatteringPower, as vectors with NbRefl elements. 
void CalcLuzzatiFactor() const 
Calculate the Luzzati factor associated to each ScatteringPower and each reflection, for maximum likelihood optimization. 
WavelengthType GetWavelengthType() const 
Get the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...) 
CrystVector_long mIntH
H,K,L integer coordinates. 
CrystVector_REAL mSinThetaLambda
 for the crystal and the reflections in ReciprSpace 
const CrystVector_REAL & GetK2Pi() const 
Return the 1D array of K coordinates for all reflections, multiplied by 2*pi. 
void SetIsIgnoringImagScattFact(const bool b)
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
void SetWavelength(const REAL)
Set the (monochromatic) wavelength of the beam. 
const CrystVector_REAL & GetReflY() const 
Return the 1D array of orthonormal y coordinates for all reflections (recipr. space) ...
const CrystVector_REAL & GetFhklCalcSq() const 
Returns the Array of calculated |F(hkl)|^2 for all reflections. 
const CrystVector_REAL & GetReflX() const 
Return the 1D array of orthonormal x coordinates for all reflections (recipr. space) ...
virtual void SetMaxSinThetaOvLambda(const REAL max)
Set the maximum value for sin(theta)/lambda. 
void CalcScattFactor() const 
WavelengthType
Incident beam characteristics : monochromatic, X-Ray tube with Alpha1 and alpha2, MAD (a few waveleng...
const CrystVector_REAL & GetFhklObsSq() const 
Returns the Array of observed |F(hkl)|^2 for all reflections. 
RefinableObjClock mClockScattFactorResonant
Clock the last time resonant scattering factors were computed. 
RefObjOpt mRadiationType
Neutron ? X-Ray ? (Electron: unimplemented) 
const RefParType * gpRefParTypeScattDataProfileWidth
Type for reflection profile width. 
REAL mGlobalBiso
Global Biso, affecting the overall structure factor for all reflections (but not the structure factor...
const RefParType * gpRefParTypeScattDataCorrIntAbsorp
Parameter type for absorption correction. 
virtual const string & GetClassName() const 
Name for this class ("RefinableObj", "Crystal",...). 
void SetRadiationType(const RadiationType)
Set the radiation type (X-Rays, Neutron) 
CrystVector_REAL mFhklObsSq
Observed squared structure factors (zero-sized if none) 
const CrystVector_REAL & GetWavelength() const 
Get the wavelength(s) in Angstroems. 
const Crystal & GetCrystal() const 
Const access to the data's crystal. 
const RefParType * gpRefParTypeScattDataProfileType
Type for reflection profiles type (e.g. gaussian/lorentzian mix) 
const CrystVector_REAL & GetFhklCalcReal() const 
Access to real part of F(hkl)calc. 
CrystVector_REAL mFhklCalcSq
F(HKL)^2 calc for each reflection. 
WX Class for DiffractionDataSingleCrystal objects. 
virtual ScatteringData * CreateCopy() const =0
So-called virtual copy constructor. 
const RefParType * gpRefParTypeScattDataCorrIntPolar
Parameter type for polarization correction. 
long mNbReflUsed
Number of reflections which are below the max. 
CrystVector_long EliminateExtinctReflections()
const CrystVector_REAL & GetL2Pi() const 
Return the 1D array of L coordinates for all reflections, multiplied by 2*pi. 
map< const ScatteringPower *, CrystVector_REAL > mvScatteringFactor
Scattering factors for each ScatteringPower, as vectors with NbRefl elements. 
Crystal * mpCrystal
Pointer to the crystal corresponding to this experiment. 
const RefParType * gpRefParTypeScattDataCorr
Generic type for scattering data correction parameter. 
CrystVector_int mExpectedIntensityFactor
Expected intensity factor for all reflections. 
void CalcTemperatureFactor() const 
long GetNbRefl() const 
Return the number of reflections in this experiment. 
const RefinableObjClock & GetClockTheta() const 
Clock the last time the sin(theta)/lambda and theta arrays were re-computed. 
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++. 
REAL GetXRayTubeAlpha2Alpha1Ratio() const 
Get the Kalpha2/Kalpha1 ratio. 
const RefParType * gpRefParTypeScattDataCorrIntPO_Direction
Parameter type for preferred orientation direction. 
RefinableObjClock mClockStructFactorSq
Clock for the square modulus of the structure factor. 
RefinableObjClock mClockFhklObsSq
Last time observed squared structure factors were altered. 
RefinableObjClock mClockGlobalBiso
last time the global Biso factor was modified 
virtual void PrintFhklCalc(ostream &os=cout) const 
Print H, K, L F^2 Re(F) Im(F) theta sin(theta)/lambda for all reflections. 
bool mUseFastLessPreciseFunc
Use faster, but less precise, approximations for functions? (integer approximations to compute sin an...
RefinableObjClock mClockGlobalTemperatureFact
last time the global temperature factor was computed 
virtual void SetApproximationFlag(const bool allow)
Enable or disable numerical approximations. 
virtual void SetHKL(const CrystVector_REAL &h, const CrystVector_REAL &k, const CrystVector_REAL &l)
input H,K,L 
const RefParType * gpRefParTypeScattDataCorrIntExtinc
Parameter type for extinction correction. 
RadiationType
Type of radiation used. 
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization. 
const RefParType * gpRefParTypeScattDataCorrIntPO_Fraction
Parameter type for fraction of preferred orientation. 
Crystal class: Unit cell, spacegroup, scatterers. 
void SetWavelengthType(const WavelengthType &type)
Set the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...) 
virtual void XMLOutput(ostream &os, int indent=0) const 
Output to stream in well-formed XML. 
class to input or output a well-formatted xml beginning or ending tag. 
class of refinable parameter types. 
void CalcStructFactVariance() const 
Calculate the variance associated to the calculated structure factor. 
const CrystVector_REAL & GetK() const 
Return the 1D array of K coordinates for all reflections. 
const RefParType * gpRefParTypeScattData
Generic type for scattering data. 
CrystVector_REAL mFhklCalcReal
real &imaginary parts of F(HKL)calc 
Class to define the radiation (type, monochromaticity, wavelength(s)) of an experiment. 
const CrystVector_REAL & GetH2Pi() const 
Return the 1D array of H coordinates for all reflections, multiplied by 2*pi. 
const RefParType * gpRefParTypeObjCryst
Top RefParType for the ObjCryst++ library. 
bool IsIgnoringImagScattFact() const 
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
CrystVector_REAL mX
reflection coordinates in an orthonormal base