Skip to content

Commit

Permalink
Added optional vana workspace Re #9197
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Ferraz Leal committed Mar 18, 2014
1 parent 9f6600b commit c28334b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 18 deletions.
Expand Up @@ -70,6 +70,7 @@ namespace DataHandling {
// Execution code
void exec();

int getEPPFromVanadium(const std::string &,Mantid::API::MatrixWorkspace_sptr);
void loadInstrumentDetails(NeXus::NXEntry&);
void initWorkSpace(NeXus::NXEntry& entry);
void initInstrumentSpecific();
Expand Down
72 changes: 55 additions & 17 deletions Code/Mantid/Framework/DataHandling/src/LoadILL.cpp
Expand Up @@ -105,20 +105,26 @@ namespace Mantid
/**
* Initialise the algorithm
*/
void LoadILL::init()
{
declareProperty(
new FileProperty("Filename", "", FileProperty::Load, ".nxs"),
"File path of the Data file to load");
declareProperty(
new FileProperty("FilenameVanadium", "", FileProperty::OptionalLoad, ".nxs"),
"File path of the Vanadium file to load (Optional)");
void LoadILL::init() {
declareProperty(
new FileProperty("Filename", "", FileProperty::Load, ".nxs"),
"File path of the Data file to load");

declareProperty(
new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output),
"The name to use for the output workspace");
declareProperty(
new FileProperty("FilenameVanadium", "", FileProperty::OptionalLoad,
".nxs"),
"File path of the Vanadium file to load (Optional)");

}
declareProperty(
new WorkspaceProperty<API::MatrixWorkspace>("WorkspaceVanadium", "",
Direction::Input, PropertyMode::Optional),
"Vanadium Workspace file to load (Optional)");

declareProperty(
new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output),
"The name to use for the output workspace");

}


/**
Expand All @@ -129,6 +135,7 @@ namespace Mantid
// Retrieve filename
std::string filenameData = getPropertyValue("Filename");
std::string filenameVanadium = getPropertyValue("FilenameVanadium");
MatrixWorkspace_sptr vanaWS = getProperty("WorkspaceVanadium");

// open the root node
NeXus::NXRoot dataRoot(filenameData);
Expand All @@ -141,11 +148,7 @@ namespace Mantid
runLoadInstrument(); // just to get IDF contents
initInstrumentSpecific();

int calculatedDetectorElasticPeakPosition = -1;
if (filenameVanadium != "") {
g_log.information() << "Calculating the elastic peak position from the Vanadium." << std::endl;
calculatedDetectorElasticPeakPosition = validateVanadium(filenameVanadium);
}
int calculatedDetectorElasticPeakPosition = getEPPFromVanadium(filenameVanadium,vanaWS);

loadDataIntoTheWorkSpace(dataFirstEntry,calculatedDetectorElasticPeakPosition);

Expand All @@ -159,6 +162,38 @@ namespace Mantid
setProperty("OutputWorkspace", m_localWorkspace);
}


int LoadILL::getEPPFromVanadium(const std::string &filenameVanadium,
MatrixWorkspace_sptr vanaWS) {
int calculatedDetectorElasticPeakPosition = -1;

if (vanaWS != NULL) {

// Check if it has been store on the run object for this workspace
if (vanaWS->run().hasProperty("EPP")) {
Kernel::Property* prop = vanaWS->run().getProperty("EPP");
calculatedDetectorElasticPeakPosition = boost::lexical_cast<int>(
prop->value());
g_log.information()
<< "Using EPP from Vanadium WorkSpace : value = "
<< calculatedDetectorElasticPeakPosition << "\n";
} else {
g_log.error(
"No EPP Property in the Vanadium Workspace. Following regular procedure...");
//throw std::invalid_argument("No EPP value has been set or stored within the run information.");
}
}
if (calculatedDetectorElasticPeakPosition == -1 && filenameVanadium != "") {
g_log.information()
<< "Calculating the elastic peak position from the Vanadium."
<< std::endl;
calculatedDetectorElasticPeakPosition = validateVanadium(
filenameVanadium);
}
return calculatedDetectorElasticPeakPosition;
}


/**
*
*/
Expand Down Expand Up @@ -496,6 +531,9 @@ namespace Mantid
else
calculatedDetectorElasticPeakPosition = vanaCalculatedDetectorElasticPeakPosition;

//set it as a Property
API::Run & runDetails = m_localWorkspace->mutableRun();
runDetails.addProperty("EPP", calculatedDetectorElasticPeakPosition);

double theoreticalElasticTOF = (m_loader.calculateTOF(m_l1,m_wavelength) + m_loader.calculateTOF(m_l2,m_wavelength))
* 1e6; //microsecs
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/instrument/Facilities.xml
Expand Up @@ -436,7 +436,7 @@

</facility>

<facility name="ILL" FileExtensions=".nxs,.hdf,.inx,.asc">
<facility name="ILL" zeropadding="6" FileExtensions=".nxs,.hdf,.inx,.asc">

<instrument name="IN4">
<technique>Neutron Spectroscopy</technique>
Expand Down

0 comments on commit c28334b

Please sign in to comment.