Commit 3569bd7a authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Allow to choose between channel number and TOF

As requested by instrument scientists at ILL, this allows, when using the TOF loader, to choose between
having bins determined by time of flight values or by the bare channel number. Default is the latter.
parent aaf83ba1
......@@ -70,6 +70,7 @@ private:
static double calculateError(double in) { return sqrt(in); }
API::MatrixWorkspace_sptr m_localWorkspace;
bool m_convertToTOF;
std::string m_instrumentName = ""; ///< Name of the instrument
std::string m_instrumentPath = ""; ///< Name of the instrument path
......
......@@ -72,6 +72,7 @@ void LoadILLTOF2::init() {
declareProperty(std::make_unique<WorkspaceProperty<>>("OutputWorkspace", "",
Direction::Output),
"The name to use for the output workspace");
declareProperty("convertToTOF", false, Direction::Input);
}
/**
......@@ -80,6 +81,7 @@ void LoadILLTOF2::init() {
void LoadILLTOF2::exec() {
// Retrieve filename
const std::string filenameData = getPropertyValue("Filename");
m_convertToTOF = getProperty("convertToTOF");
// open the root node
NeXus::NXRoot dataRoot(filenameData);
......@@ -369,9 +371,15 @@ void LoadILLTOF2::loadDataIntoTheWorkSpace(
// Put tof in an array
auto &X0 = m_localWorkspace->mutableX(0);
if (monitor.containsDataSet("time_of_flight")) {
for (size_t i = 0; i < m_numberOfChannels + 1; ++i) {
X0[i] = m_timeOfFlightDelay + m_channelWidth * static_cast<double>(i) -
m_channelWidth / 2; // to make sure the bin centre is correct
if (m_convertToTOF) {
for (size_t i = 0; i < m_numberOfChannels + 1; ++i) {
X0[i] = m_timeOfFlightDelay + m_channelWidth * static_cast<double>(i) -
m_channelWidth / 2; // to make sure the bin centre is correct
}
} else {
for (size_t i = 0; i < m_numberOfChannels + 1; ++i) {
X0[i] = static_cast<double>(i); // just take the channel index
}
}
} else {
// Diffraction PANTHER
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment