Skip to content

Commit

Permalink
Re #6151 added scattering beam center option for sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Dec 5, 2012
1 parent 30db5f8 commit c6ea811
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DLLExport SetupHFIRReduction : public API::Algorithm
void exec();
void setupTransmission(boost::shared_ptr<Kernel::PropertyManager> reductionManager);
void setupBackground(boost::shared_ptr<Kernel::PropertyManager> reductionManager);

void setupSensitivity(boost::shared_ptr<Kernel::PropertyManager> reductionManager);
};

} // namespace Algorithms
Expand Down
110 changes: 62 additions & 48 deletions Code/Mantid/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ void SetupHFIRReduction::init()
setPropertySettings("SensitivityBeamCenterFile",
new VisibleWhenProperty("SensitivityBeamCenterMethod", IS_NOT_EQUAL_TO, "None"));

declareProperty("SensitivityBeamCenterRadius", EMPTY_DBL(),
"Radius of the beam area used the exclude the beam when calculating "
"the center of mass of the scattering pattern [pixels]. Default=3.0");
setPropertySettings("SensitivityBeamCenterRadius",
new VisibleWhenProperty("BeamCenterMethod", IS_EQUAL_TO, "Scattering"));

declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputSensitivityWorkspace","", Direction::Output, PropertyMode::Optional));

setPropertyGroup("SensitivityFile", eff_grp);
Expand All @@ -167,6 +173,7 @@ void SetupHFIRReduction::init()
setPropertyGroup("SensitivityBeamCenterX", eff_grp);
setPropertyGroup("SensitivityBeamCenterY", eff_grp);
setPropertyGroup("SensitivityBeamCenterFile", eff_grp);
setPropertyGroup("SensitivityBeamCenterRadius", eff_grp);
setPropertyGroup("OutputSensitivityWorkspace", eff_grp);

// Transmission
Expand Down Expand Up @@ -524,8 +531,54 @@ void SetupHFIRReduction::exec()
} else
reductionManager->declareProperty(new PropertyWithValue<std::string>("TransmissionNormalisation", "Timer") );

// Sensitivity correction, transmission and background
setupSensitivity(reductionManager);
setupTransmission(reductionManager);
setupBackground(reductionManager);

// Geometry correction
const double thickness = getProperty("SampleThickness");
if (!isEmpty(thickness))
{
IAlgorithm_sptr thickAlg = createSubAlgorithm("NormaliseByThickness");
thickAlg->setProperty("SampleThickness", thickness);

algProp = new AlgorithmProperty("GeometryAlgorithm");
algProp->setValue(thickAlg->toString());
reductionManager->declareProperty(algProp);
}

// Azimuthal averaging
const bool doAveraging = getProperty("DoAzimuthalAverage");
if (doAveraging)
{
const std::string binning = getPropertyValue("IQBinning");
const std::string n_bins = getPropertyValue("IQNumberOfBins");
const bool log_binning = getProperty("IQLogBinning");
const std::string n_subpix = getPropertyValue("NumberOfSubpixels");
const bool err_weighting = getProperty("ErrorWeighting");

IAlgorithm_sptr iqAlg = createSubAlgorithm("SANSAzimuthalAverage1D");
iqAlg->setPropertyValue("Binning", binning);
iqAlg->setPropertyValue("NumberOfBins", n_bins);
iqAlg->setProperty("LogBinning", log_binning);
iqAlg->setPropertyValue("NumberOfSubpixels", n_subpix);
iqAlg->setProperty("ErrorWeighting", err_weighting);
iqAlg->setPropertyValue("ReductionProperties", reductionManagerName);

algProp = new AlgorithmProperty("IQAlgorithm");
algProp->setValue(iqAlg->toString());
g_log.information() << iqAlg->toString() << std::endl;
reductionManager->declareProperty(algProp);
}

setPropertyValue("OutputMessage", "HFIR reduction options set");
}

void SetupHFIRReduction::setupSensitivity(boost::shared_ptr<PropertyManager> reductionManager)
{
const std::string reductionManagerName = getProperty("ReductionProperties");

// Sensitivity correction
const std::string sensitivityFile = getPropertyValue("SensitivityFile");
if (sensitivityFile.size() > 0)
{
Expand Down Expand Up @@ -553,15 +606,20 @@ void SetupHFIRReduction::exec()
effAlg->setProperty("BeamCenterX", sensitivityBeamCenterX);
effAlg->setProperty("BeamCenterY", sensitivityBeamCenterY);
}
else if (boost::iequals(centerMethod, "DirectBeam"))
else if (boost::iequals(centerMethod, "DirectBeam") ||
boost::iequals(centerMethod, "Scattering"))
{
const std::string beamCenterFile = getProperty("SensitivityBeamCenterFile");
const double sensitivityBeamRadius = getProperty("SensitivityBeamCenterRadius");
bool useDirectBeam = boost::iequals(centerMethod, "DirectBeam");
if (beamCenterFile.size()>0)
{
IAlgorithm_sptr ctrAlg = createSubAlgorithm("SANSBeamFinder");
ctrAlg->setProperty("Filename", beamCenterFile);
ctrAlg->setProperty("UseDirectBeamMethod", true);
ctrAlg->setProperty("UseDirectBeamMethod", useDirectBeam);
ctrAlg->setProperty("PersistentCorrection", false);
if (useDirectBeam && !isEmpty(sensitivityBeamRadius))
ctrAlg->setProperty("BeamRadius", sensitivityBeamRadius);
ctrAlg->setPropertyValue("ReductionProperties", reductionManagerName);

AlgorithmProperty *algProp = new AlgorithmProperty("SensitivityBeamCenterAlgorithm");
Expand All @@ -576,54 +634,10 @@ void SetupHFIRReduction::exec()
effAlg->setProperty("OutputSensitivityWorkspace", outputSensitivityWS);
effAlg->setPropertyValue("ReductionProperties", reductionManagerName);

algProp = new AlgorithmProperty("SensitivityAlgorithm");
AlgorithmProperty *algProp = new AlgorithmProperty("SensitivityAlgorithm");
algProp->setValue(effAlg->toString());
reductionManager->declareProperty(algProp);


}

setupTransmission(reductionManager);

setupBackground(reductionManager);

// Geometry correction
const double thickness = getProperty("SampleThickness");
if (!isEmpty(thickness))
{
IAlgorithm_sptr thickAlg = createSubAlgorithm("NormaliseByThickness");
thickAlg->setProperty("SampleThickness", thickness);

algProp = new AlgorithmProperty("GeometryAlgorithm");
algProp->setValue(thickAlg->toString());
reductionManager->declareProperty(algProp);
}

// Azimuthal averaging
const bool doAveraging = getProperty("DoAzimuthalAverage");
if (doAveraging)
{
const std::string binning = getPropertyValue("IQBinning");
const std::string n_bins = getPropertyValue("IQNumberOfBins");
const bool log_binning = getProperty("IQLogBinning");
const std::string n_subpix = getPropertyValue("NumberOfSubpixels");
const bool err_weighting = getProperty("ErrorWeighting");

IAlgorithm_sptr iqAlg = createSubAlgorithm("SANSAzimuthalAverage1D");
iqAlg->setPropertyValue("Binning", binning);
iqAlg->setPropertyValue("NumberOfBins", n_bins);
iqAlg->setProperty("LogBinning", log_binning);
iqAlg->setPropertyValue("NumberOfSubpixels", n_subpix);
iqAlg->setProperty("ErrorWeighting", err_weighting);
iqAlg->setPropertyValue("ReductionProperties", reductionManagerName);

algProp = new AlgorithmProperty("IQAlgorithm");
algProp->setValue(iqAlg->toString());
g_log.information() << iqAlg->toString() << std::endl;
reductionManager->declareProperty(algProp);
}

setPropertyValue("OutputMessage", "HFIR reduction options set");
}

void SetupHFIRReduction::setupBackground(boost::shared_ptr<PropertyManager> reductionManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def SensitivityDirectBeamCenter(datafile):

def SensitivityScatteringBeamCenter(datafile, beam_radius=3.0):
find_data(datafile, instrument=ReductionSingleton().get_instrument())
ReductionSingleton().set_sensitivity_beam_center(sans_reduction_steps.ScatteringBeamCenter(datafile, beam_radius=beam_radius).set_persistent(False))
ReductionSingleton().reduction_properties["SensitivityBeamCenterMethod"]="Scattering"
ReductionSingleton().reduction_properties["SensitivityBeamCenterRadius"]=beam_radius
ReductionSingleton().reduction_properties["SensitivityBeamCenterFile"]=datafile

def NoSensitivityCorrection():
ReductionSingleton().reduction_properties["SensitivityFile"] = None
Expand Down

0 comments on commit c6ea811

Please sign in to comment.