Skip to content

Commit

Permalink
Refs #5453 and #5606. Handling detcal file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reuter committed Sep 19, 2012
1 parent bc56bf0 commit 1323ed4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,33 @@ namespace Mantid
const double binOffset = -monPeak;
reductionManager->declareProperty(new PropertyWithValue<double>("TofRangeOffset", binOffset));

if ("ISIS" == facility)
{
std::string detcalFile("");
if (reductionManager->existsProperty("SampleDetCalFilename"))
{
detcalFile = reductionManager->getPropertyValue("SampleDetCalFilename");
}
// Try to get it from run object.
else
{
detcalFile = inputWS->run().getProperty("Filename")->value();
}
if (!detcalFile.empty())
{
const bool relocateDets = reductionManager->getProperty("RelocateDetectors");
IAlgorithm_sptr loaddetinfo = this->createSubAlgorithm("LoadDetectorInfo");
loaddetinfo->setProperty("Workspace", outWsName);
loaddetinfo->setProperty("DataFilename", detcalFile);
loaddetinfo->setProperty("RelocateDets", relocateDets);
loaddetinfo->execute();
}
else
{
throw std::runtime_error("Cannot find detcal filename in run object or as parameter.");
}
}

// Subtract time-independent background if necessary
const bool doTibSub = reductionManager->getProperty("TimeIndepBackgroundSub");
if (doTibSub)
Expand Down Expand Up @@ -385,7 +412,6 @@ namespace Mantid
// Do ISIS
else
{
// TODO: More setup work needs to be done.
IAlgorithm_sptr flatBg = this->createSubAlgorithm("FlatBackground");
flatBg->setAlwaysStoreInADS(true);
flatBg->setProperty("InputWorkspace", outWsName);
Expand Down
20 changes: 18 additions & 2 deletions Code/Mantid/Framework/WorkflowAlgorithms/src/DgsReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ namespace Mantid
this->declareProperty(new WorkspaceProperty<>("SampleInputWorkspace", "",
Direction::Input, PropertyMode::Optional),
"Workspace to be reduced");
this->declareProperty(new FileProperty("DetCalFilename", "",
FileProperty::OptionalLoad), "A detector calibration file.");
this->declareProperty("RelocateDetectors", false,
"Move detectors to position specified in cal file.");
auto mustBePositive = boost::make_shared<BoundedValidator<double> >();
mustBePositive->setLower(0.0);
this->declareProperty("IncidentEnergyGuess", EMPTY_DBL(), mustBePositive,
Expand Down Expand Up @@ -108,6 +112,8 @@ namespace Mantid

this->setPropertyGroup("SampleInputFile", sampleSetup);
this->setPropertyGroup("SampleInputWorkspace", sampleSetup);
this->setPropertyGroup("DetCalFilename", sampleSetup);
this->setPropertyGroup("RelocateDetectors", sampleSetup);
this->setPropertyGroup("IncidentEnergyGuess", sampleSetup);
this->setPropertyGroup("UseIncidentEnergyGuess", sampleSetup);
this->setPropertyGroup("TimeZeroGuess", sampleSetup);
Expand Down Expand Up @@ -398,8 +404,18 @@ namespace Mantid
// Do ISIS
else
{
std::string detCalFilename = prop + "DetCalFilename";
this->reductionManager->declareProperty(new PropertyWithValue<std::string>(detCalFilename, inputData));
std::string detCalFileFromAlg = this->getProperty("DetCalFilename");
std::string detCalFileProperty = prop + "DetCalFilename";
std::string detCalFilename("");
if (!detCalFileFromAlg.empty())
{
detCalFilename = detCalFileFromAlg;
}
else
{
detCalFilename = inputData;
}
this->reductionManager->declareProperty(new PropertyWithValue<std::string>(detCalFileProperty, detCalFilename));
}

inputWS = this->load(inputData);
Expand Down

0 comments on commit 1323ed4

Please sign in to comment.