ObjCryst::PowderPatternBackground Class Reference

Phase to compute a background contribution to a powder pattern using an interpolation. More...

Inheritance diagram for ObjCryst::PowderPatternBackground:

Inheritance graph
[legend]
Collaboration diagram for ObjCryst::PowderPatternBackground:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 PowderPatternBackground (const PowderPatternBackground &)
virtual const string & GetClassName () const
 Name for this class ("RefinableObj", "Crystal",.
virtual void SetParentPowderPattern (PowderPattern &)
 Set the PowderPattern object which uses this component.
virtual const CrystVector_REAL & GetPowderPatternCalc () const
 Get the calculated powder pattern for this component.
virtual pair< const
CrystVector_REAL *, const
RefinableObjClock * > 
GetPowderPatternIntegratedCalc () const
 Get the integrated values of the powder pattern.
void ImportUserBackground (const string &filename)
 Import background points from a file (with two columns 2theta (or tof), intensity).
void SetInterpPoints (const CrystVector_REAL tth, const CrystVector_REAL backgd)
const std::pair< const
CrystVector_REAL *, const
CrystVector_REAL * > 
GetInterpPoints () const
virtual void XMLOutput (ostream &os, int indent=0) const
 Output to stream in well-formed XML.
virtual void XMLInput (istream &is, const XMLCrystTag &tag)
 Input From stream.
virtual void GetGeneGroup (const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
 Get the gene group assigned to each parameter.
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.
virtual const CrystVector_REAL & GetPowderPatternCalcVariance () const
 Get the variance associated to each point of the calculated powder pattern, for this component.
virtual pair< const
CrystVector_REAL *, const
RefinableObjClock * > 
GetPowderPatternIntegratedCalcVariance () const
 Get the variance associated to each point of the calculated powder pattern, for this component (integrated version).
virtual bool HasPowderPatternCalcVariance () const
 Does this component have a variance associated with each calculated point ? i.e., do we use maximum likelihood to take into account incomplete models ?
virtual void TagNewBestConfig () const
 During a global optimization, tells the object that the current config is the latest "best" config.
void OptimizeBayesianBackground ()
 Optimize the background using a Bayesian approach.
void FixParametersBeyondMaxresolution (RefinableObj &obj)
 Fix parameters corresponding to points of the pattern that are not actually calculated.

Protected Member Functions

virtual void CalcPowderPattern () const
 Calc the powder pattern.
virtual void CalcPowderPatternIntegrated () const
 Calc the integrated powder pattern.
virtual void Prepare ()
virtual const CrystVector_long & GetBraggLimits () const
 Get the pixel positions separating the integration intervals around reflections.
virtual void SetMaxSinThetaOvLambda (const REAL max)
 Set the maximum value for sin(theta)/lambda.
void InitRefParList ()
void InitOptions ()
void InitSpline () const

Protected Attributes

int mBackgroundNbPoint
 Number of fitting points for background.
CrystVector_REAL mBackgroundInterpPointX
 Vector of 2theta values for the fitting points of the background.
CrystVector_REAL mBackgroundInterpPointIntensity
 Values of background at interpolating points.
CrystVector_long mPointOrder
 Subscript of the points, sorted the correct order, taking into account the type of radiation (monochromatic/TOF).
CrystVector_REAL mvSplinePixel
 Vector of pixel values between each interval, for faster CubicSpline calculations.
CubicSpline mvSpline
 Spline used for interpolation.
RefinableObjClock mClockBackgroundPoint
 Modification of the interpolated points.
RefinableObjClock mClockSpline
 Initialization of the spline.
REAL mMaxSinThetaOvLambda
 Maximum sin(theta)/lambda for all calculations (10 by default).
REAL mModelVariance
 Constant error (sigma) on the calculated pattern, due to an incomplete model.
RefObjOpt mInterpolationModel
 Type of interpolation performed: linear or cubic spline.

Friends

class PowderPattern


Detailed Description

Phase to compute a background contribution to a powder pattern using an interpolation.

Currently only linear interpolation is available. (in the works: cubic spline interpolation background)

Definition at line 194 of file PowderPattern.h.


Member Function Documentation

const string & ObjCryst::PowderPatternBackground::GetClassName (  )  const [virtual]

Name for this class ("RefinableObj", "Crystal",.

..). This is only useful to distinguish different classes when picking up objects from the RefinableObj Global Registry

Reimplemented from ObjCryst::PowderPatternComponent.

Definition at line 145 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::SetParentPowderPattern ( PowderPattern  )  [virtual]

Set the PowderPattern object which uses this component.

This sets all necessary pattern parameters (2theta/tof range, wavelength, radiation type...) accordingly.

Implements ObjCryst::PowderPatternComponent.

Definition at line 151 of file PowderPattern.cpp.

const CrystVector_REAL & ObjCryst::PowderPatternBackground::GetPowderPatternCalc (  )  const [virtual]

Get the calculated powder pattern for this component.

Note that the pattern is not scaled.

Implements ObjCryst::PowderPatternComponent.

Definition at line 161 of file PowderPattern.cpp.

pair< const CrystVector_REAL *, const RefinableObjClock * > ObjCryst::PowderPatternBackground::GetPowderPatternIntegratedCalc (  )  const [virtual]

Get the integrated values of the powder pattern.

Note:
: the integration intervals are those given by the parent PowderPattern, so that all PowderPatternComponent's intervals are taken into account
This avoids explicitely calculating the full profile powder pattern.

Implements ObjCryst::PowderPatternComponent.

Definition at line 168 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::XMLOutput ( ostream &  os,
int  indent = 0 
) const [virtual]

Output to stream in well-formed XML.

Todo:
Use inheritance.. as for XMLInputTag()...

Reimplemented from ObjCryst::RefinableObj.

Definition at line 1393 of file ObjCryst/IO.cpp.

void ObjCryst::PowderPatternBackground::XMLInput ( istream &  is,
const XMLCrystTag tag 
) [virtual]

Input From stream.

Todo:
Add an bool XMLInputTag(is,tag) function to recognize all the tags from the stream. So that each inherited class can use the XMLInputTag function from its parent (ie take advantage of inheritance). The children class would first try to interpret the tag, then if unsuccessful would pass it to its parent (thus allowing overloading), etc...

Reimplemented from ObjCryst::RefinableObj.

Definition at line 1439 of file ObjCryst/IO.cpp.

void ObjCryst::PowderPatternBackground::GetGeneGroup ( const RefinableObj obj,
CrystVector_uint &  groupIndex,
unsigned int &  firstGroup 
) const [virtual]

Get the gene group assigned to each parameter.

Each parameter (a gene in terms of genetic algorithms) can be assigned to a gene group. Thus when mating two configurations, genes will be exchanged by groups. By default (in the base RefinabeObj class), each parameter is alone in its group. Derived classes can group genes for a better s** life.

The number identifying a gene group only has a meaning in a given object. It can also change on subsequent calls, and thus is not unique.

Parameters:
obj the , supplied by an algorithm class (OptimizationObj,..), which contains a list of parameters, some of which (but possibly all or none) are parameters belonging to this object.
groupIndex a vector of unsigned integers, one for each parameter in the input object, giving an unsigned integer value as gene group index. At the beginning this vector should contain only zeros (no group assigned).
firstGroup this is the number of groups which have already been assigned, plus one. The gene groups returned by this object will start from this value, and increment firstGroup for each gene group used, so that different RefinableObj cannot share a gene group.
Note:
this function is not optimized, and should only be called at the beginning of a refinement.

Reimplemented from ObjCryst::RefinableObj.

Definition at line 252 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::BeginOptimization ( const bool  allowApproximations = false,
const bool  enableRestraints = false 
) [virtual]

This should be called by any optimization class at the begining of an optimization.

This will also check that everything is ready, eg call the RefinableObj::Prepare() function. This also affects all sub-objects.

Note:
this may be called several time for some objects which are used by several other objects.
Parameters:
allowApproximations,: if true, then the object can use faster but less precise functions during the optimization. This is useful for global optimization not using derivatives.
enableRestraints,: if true, then restrained parameters will be allowed to go beyond theur hard limits. This implies that the algorithm will take into account the cost (penalty) related to the restraints. Objects which do not use restraints will simply ignore this. WARNING: this parameter may be removed with the new likelihood scheme.

Reimplemented from ObjCryst::RefinableObj.

Definition at line 268 of file PowderPattern.cpp.

const CrystVector_REAL & ObjCryst::PowderPatternBackground::GetPowderPatternCalcVariance (  )  const [virtual]

Get the variance associated to each point of the calculated powder pattern, for this component.

Warning:
: this is experimental, with the aim of using Maximum Likelihood to improve structure determination.

Implements ObjCryst::PowderPatternComponent.

Definition at line 274 of file PowderPattern.cpp.

pair< const CrystVector_REAL *, const RefinableObjClock * > ObjCryst::PowderPatternBackground::GetPowderPatternIntegratedCalcVariance (  )  const [virtual]

Get the variance associated to each point of the calculated powder pattern, for this component (integrated version).

Warning:
: this is experimental, with the aim of using Maximum Likelihood to improve structure determination.

Implements ObjCryst::PowderPatternComponent.

Definition at line 281 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::TagNewBestConfig (  )  const [virtual]

During a global optimization, tells the object that the current config is the latest "best" config.

This can be used by the object to make more intellingent random moves (use with caution: highly experimental !).

Reimplemented from ObjCryst::RefinableObj.

Definition at line 297 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::OptimizeBayesianBackground (  ) 

Optimize the background using a Bayesian approach.

The background parameters must be un-fixed before.

The minimization will a maximum of 50 Simplex runs (see the SimplexObj documentation), each with 200 cycles.

See the class documentation for PowderPatternBackgroundBayesianMinimiser.

Definition at line 301 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::FixParametersBeyondMaxresolution ( RefinableObj obj  ) 

Fix parameters corresponding to points of the pattern that are not actually calculated.

This is necessary for modelling using splines, to avoid divergence of interpolation points during least squares optimization.

Parameters:
obj,: the object in which are parameters to be fixed. Normally this will be the PowderPatternBackground object itself, but it can also be the parameter list copied such as in a LSQNumObj.

Definition at line 338 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::CalcPowderPattern (  )  const [protected, virtual]

Calc the powder pattern.

As always, recomputation is only done if necessary (ie if a parameter has changed since the last computation)

Implements ObjCryst::PowderPatternComponent.

Definition at line 350 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::CalcPowderPatternIntegrated (  )  const [protected, virtual]

Calc the integrated powder pattern.

This should be optimized so that the full powder pattern is not explicitely computed.

Implements ObjCryst::PowderPatternComponent.

Definition at line 428 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::Prepare (  )  [protected, virtual]

For internal use only.

This will be called by the parent PowderPattern object, before calculating the first powder pattern. Or maybe it should be called automatically by the object itself...

Implements ObjCryst::PowderPatternComponent.

Definition at line 470 of file PowderPattern.cpp.

const CrystVector_long & ObjCryst::PowderPatternBackground::GetBraggLimits (  )  const [protected, virtual]

Get the pixel positions separating the integration intervals around reflections.

Returns:
: an array with the pixel positions, empty if this component has no peaks. The positions should be in increasing order, but could go beyond the pattern limits.

Implements ObjCryst::PowderPatternComponent.

Definition at line 473 of file PowderPattern.cpp.

void ObjCryst::PowderPatternBackground::SetMaxSinThetaOvLambda ( const REAL  max  )  [protected, virtual]

Set the maximum value for sin(theta)/lambda.

All data above still exist but are ignored for all calculations.

Implements ObjCryst::PowderPatternComponent.

Definition at line 480 of file PowderPattern.cpp.


Member Data Documentation

CrystVector_long ObjCryst::PowderPatternBackground::mPointOrder [mutable, protected]

Subscript of the points, sorted the correct order, taking into account the type of radiation (monochromatic/TOF).

Definition at line 258 of file PowderPattern.h.

CrystVector_REAL ObjCryst::PowderPatternBackground::mvSplinePixel [mutable, protected]

Vector of pixel values between each interval, for faster CubicSpline calculations.

Mutable since it copies information from mBackgroundInterpPointX.

Definition at line 261 of file PowderPattern.h.

Spline used for interpolation.

Mutable since it copies information from mBackgroundInterpPointX and mBackgroundInterpPointIntensity.

Definition at line 265 of file PowderPattern.h.

Maximum sin(theta)/lambda for all calculations (10 by default).

This keeps all data in memory, but only the part which is below the max is calculated.

Definition at line 277 of file PowderPattern.h.


The documentation for this class was generated from the following files:

Generated on Sun Sep 28 23:46:13 2008 for FOX/ObjCryst++ by  doxygen 1.5.6