Skip to content
Snippets Groups Projects
Commit fbb5b348 authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #13494 shift TOF from value in TOPAZ Param file

parent 01084d0d
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,7 @@ public:
void populateInstrumentParameters();
void setTitle(std::string title);
void applyFilter(boost::function<void (API::MatrixWorkspace_sptr)> filter);
virtual bool threadSafe() const;
};
typedef boost::shared_ptr<EventWorkspaceCollection> EventWorkspaceCollection_sptr;
......
......@@ -290,5 +290,14 @@ void EventWorkspaceCollection::applyFilter(boost::function<void (MatrixWorkspace
}
}
//-----------------------------------------------------------------------------
/** Returns true if the EventWorkspace is safe for multithreaded operations.
*/
bool EventWorkspaceCollection::threadSafe() const {
// Since there is a mutex lock around sorting, EventWorkspaces are always
// safe.
return true;
}
} // namespace DataHandling
} // namespace Mantid
......@@ -1800,7 +1800,8 @@ void LoadEventNexus::loadEvents(API::Progress *const prog,
}
prog->report("Initializing all pixels");
// Remove used banks if parameter is set
// Remove unused banks if parameter is set
if (m_ws->getInstrument()->hasParameter("remove-unused-banks")) {
std::vector<double> instrumentUnused =
m_ws->getInstrument()->getNumberParameter("remove-unused-banks", true);
......@@ -1941,6 +1942,28 @@ void LoadEventNexus::loadEvents(API::Progress *const prog,
"may indicate errors in the raw "
"TOF data." << std::endl;
// Use T0 offset from TOPAZ Parameter file if it exists
if (m_ws->getInstrument()->hasParameter("T0")) {
std::vector<double> instrumentT0 =
m_ws->getInstrument()->getNumberParameter("T0", true);
if (!instrumentT0.empty()) {
const double mT0 = instrumentT0.front();
if (mT0 != 0.0) {
int64_t numHistograms = static_cast<int64_t>(m_ws->getNumberHistograms());
PARALLEL_FOR1(m_ws)
for (int64_t i = 0; i < numHistograms; ++i) {
PARALLEL_START_INTERUPT_REGION
// Do the offsetting
m_ws->getEventList(i).addTof(mT0);
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
// set T0 in the run parameters
API::Run &run = m_ws->mutableRun();
run.addProperty<double>("T0", mT0, true);
}
}
}
// Now, create a default X-vector for histogramming, with just 2 bins.
Kernel::cow_ptr<MantidVec> axis;
MantidVec &xRef = axis.access();
......
......@@ -180,15 +180,18 @@ void LoadIsawDetCal::exec() {
if (instname .compare("WISH") == 0) center(0.0, 0.0, -0.01 * mL1, "undulator", inname);
else center(0.0, 0.0, -0.01 * mL1, "moderator", inname);
// mT0 and time of flight are both in microsec
IAlgorithm_sptr alg1 = createChildAlgorithm("ChangeBinOffset");
alg1->setProperty<MatrixWorkspace_sptr>("InputWorkspace", inputW);
alg1->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", inputW);
alg1->setProperty("Offset", mT0);
alg1->executeAsChildAlg();
inputW = alg1->getProperty("OutputWorkspace");
// set T0 in the run parameters
API::Run &run = inputW->mutableRun();
run.addProperty<double>("T0", mT0, true);
// Check to see if LoadEventNexus had T0 from TOPAZ Parameter file
if (!run.hasProperty("T0")) {
IAlgorithm_sptr alg1 = createChildAlgorithm("ChangeBinOffset");
alg1->setProperty<MatrixWorkspace_sptr>("InputWorkspace", inputW);
alg1->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", inputW);
alg1->setProperty("Offset", mT0);
alg1->executeAsChildAlg();
inputW = alg1->getProperty("OutputWorkspace");
// set T0 in the run parameters
run.addProperty<double>("T0", mT0, true);
}
}
if (line[0] != '5')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment