Mantid
Loading...
Searching...
No Matches
ConvertCWSDExpToMomentum.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10#include "MantidAPI/Run.h"
22
23using namespace Mantid::API;
24using namespace Mantid::Kernel;
25using namespace Mantid::DataObjects;
26using namespace Mantid::Geometry;
27
28namespace Mantid::MDAlgorithms {
29
30DECLARE_ALGORITHM(ConvertCWSDExpToMomentum)
31
32
35 : m_iColScan(0), m_iColPt(1), m_iColFilename(2), m_iColStartDetID(3), m_iMonitorCounts(4), m_iTime(5),
36 m_setQRange(true), m_isBaseName(false), m_removeBackground(false) {}
37
41 declareProperty(std::make_unique<WorkspaceProperty<ITableWorkspace>>("InputWorkspace", "", Direction::Input),
42 "Name of table workspace for data file names in the experiment.");
43
44 declareProperty(std::make_unique<FileProperty>("InstrumentFilename", "", FileProperty::OptionalLoad, ".xml"));
45
46 declareProperty("DetectorSampleDistanceShift", 0.0, "Amount of shift in sample-detector distance from 0.3750 meter.");
47
48 declareProperty("DetectorCenterXShift", 0.0, "Amount of shift of detector center in X-direction from (115, 128).");
49
50 declareProperty("DetectorCenterYShift", 0.0, "Amount of shift of detector center in Y-direction from (115, 128).");
51
52 declareProperty("UserDefinedWavelength", EMPTY_DBL(), "User defined wave length if it is specified.");
53
54 declareProperty("CreateVirtualInstrument", false, "Flag to create virtual instrument.");
55
56 declareProperty(std::make_unique<WorkspaceProperty<ITableWorkspace>>("DetectorTableWorkspace", "", Direction::Input,
58 "Name of table workspace containing all the detectors.");
59
60 declareProperty(std::make_unique<WorkspaceProperty<IMDEventWorkspace>>("OutputWorkspace", "", Direction::Output),
61 "Name of MDEventWorkspace containing all experimental data.");
62
63 declareProperty(std::make_unique<ArrayProperty<double>>("SourcePosition"),
64 "A vector of 3 doubles for position of source.");
65
66 declareProperty(std::make_unique<ArrayProperty<double>>("SamplePosition"),
67 "A vector of 3 doubles for position of sample.");
68
69 declareProperty(std::make_unique<ArrayProperty<double>>("PixelDimension"),
70 "A vector of 8 doubles to determine a cubic pixel's size.");
71
72 declareProperty("IsBaseName", true,
73 "It is specified as true if the data "
74 "file names listed in InputWorkspace are "
75 "base name without directory.");
76
77 declareProperty(std::make_unique<WorkspaceProperty<MatrixWorkspace>>("BackgroundWorkspace", "", Direction::Input,
79 "Name of optional background workspace.");
80
81 declareProperty(std::make_unique<FileProperty>("Directory", "", FileProperty::OptionalDirectory),
82 "Directory where data files are if InputWorkspace gives data file name "
83 "as the base file name as indicated by 'IsBaseName'.");
84}
85
86//----------------------------------------------------------------------------------------------
91 // Parse inputs
92 std::string errmsg;
93 bool createvirtual = getProperty("CreateVirtualInstrument");
94 bool inputvalid = getInputs(createvirtual, errmsg);
95 if (!inputvalid) {
96 g_log.error() << "Importing error: " << errmsg << "\n";
97 throw std::runtime_error(errmsg);
98 }
99 m_detSampleDistanceShift = getProperty("DetectorSampleDistanceShift");
100 m_detXShift = getProperty("DetectorCenterXShift");
101 m_detYShift = getProperty("DetectorCenterYShift");
102
103 // background
104 std::string bkgdwsname = getPropertyValue("BackgroundWorkspace");
105 if (!bkgdwsname.empty()) {
106 m_removeBackground = true;
107 m_backgroundWS = getProperty("BackgroundWorkspace");
108 // check background
109 if (m_backgroundWS->getNumberHistograms() != 256 * 256)
110 throw std::invalid_argument("Input background workspace does not have "
111 "correct number of spectra.");
112 } else {
113 m_removeBackground = false;
114 }
115
116 // Create output MDEventWorkspace
118
119 if (createvirtual)
121
122 // Add MDEventWorkspace
123 addMDEvents(createvirtual);
124
125 setProperty("OutputWorkspace", m_outputWS);
126
127 // Output
128 for (size_t i = 0; i < 3; ++i) {
129 g_log.notice() << "Q-sample at dimension " << i << ": " << m_minQVec[i] << ", " << m_maxQVec[i] << "\n";
130 }
131}
132
133//----------------------------------------------------------------------------------------------
137 // Get detector list from input table workspace
138 std::vector<Kernel::V3D> vec_detpos;
139 std::vector<detid_t> vec_detid;
140 g_log.information("Start to parse detector parameter tables.");
141 parseDetectorTable(vec_detpos, vec_detid);
142
143 // Create a virtual instrument
144 g_log.information("Start to create virtual instrument.");
148 throw std::runtime_error("Failed to create virtual instrument.");
149 g_log.information() << "Virtual Instrument has " << m_virtualInstrument->getDetectorIDs().size() << "Detectors\n";
150}
151
152//----------------------------------------------------------------------------------------------
158
159 // Create workspace in Q_sample with dimenion as 3
160 size_t nDimension = 3;
161 IMDEventWorkspace_sptr mdws = MDEventFactory::CreateMDWorkspace(nDimension, "MDEvent");
162
163 // Extract Dimensions and add to the output workspace.
164 std::vector<std::string> vec_ID(3);
165 vec_ID[0] = "Q_sample_x";
166 vec_ID[1] = "Q_sample_y";
167 vec_ID[2] = "Q_sample_z";
168
169 std::vector<std::string> dimensionNames(3);
170 dimensionNames[0] = "Q_sample_x";
171 dimensionNames[1] = "Q_sample_y";
172 dimensionNames[2] = "Q_sample_z";
173
175
176 // Add dimensions
177 // FIXME - Should I give out a better value???
178 if (m_extentMins.size() != 3 || m_extentMaxs.size() != 3 || m_numBins.size() != 3) {
179 // Default dimenion
180 m_extentMins.resize(3, -10.0);
181 m_extentMaxs.resize(3, 10.0);
182 m_numBins.resize(3, 100);
183 }
184 // Sample-Q range
185 m_minQVec.resize(3);
186 m_maxQVec.resize(3);
187
188 for (size_t d = 0; d < 3; ++d)
189 g_log.debug() << "Direction " << d << ", Range = " << m_extentMins[d] << ", " << m_extentMaxs[d] << "\n";
190
191 // Set Q Sample frame
193
194 for (size_t i = 0; i < nDimension; ++i) {
195 std::string id = vec_ID[i];
196 std::string name = dimensionNames[i];
198 id, name, frame, static_cast<coord_t>(m_extentMins[i]), static_cast<coord_t>(m_extentMaxs[i]), m_numBins[i])));
199 }
200
201 // Set coordinate system
202 mdws->setCoordinateSystem(coordinateSystem);
203
204 return mdws;
205}
206
207//----------------------------------------------------------------------------------------------
214 MatrixWorkspace_sptr spicews;
215
216 // Check whether to add / or \ to m_dataDir
217 std::string sep;
218 if (!m_dataDir.empty()) {
219#if defined _WIN32 || defined _WIN64
220 if (*m_dataDir.rbegin() != '\\') {
221 sep = "\\";
222 }
223#else
224 if (*m_dataDir.rbegin() != '/') {
225 sep = "/";
226 }
227#endif
228 }
229
230 // Init some variables
231 size_t numrows = m_expDataTableWS->rowCount();
232 if (numrows > 1 && !usevirtual) {
233 g_log.warning("There are more than 1 experiment to import. "
234 "Make sure that all of them have the same instrument.");
235 }
236
237 // Loop through all data files in the experiment
238 for (size_t ir = 0; ir < numrows; ++ir) {
239 std::string rawfilename = m_expDataTableWS->cell<std::string>(ir, m_iColFilename);
240 detid_t start_detid = 0;
241 if (usevirtual)
242 start_detid = m_expDataTableWS->cell<detid_t>(ir, m_iColStartDetID);
243
244 // Load data
245 bool loaded;
246 std::string errmsg;
247
248 std::stringstream filess;
249 if (m_isBaseName)
250 filess << m_dataDir << sep;
251 filess << rawfilename;
252 std::string filename(filess.str());
253
254 spicews = loadSpiceData(filename, loaded, errmsg);
255 if (!loaded) {
256 g_log.error(errmsg);
257 continue;
258 }
260 removeBackground(spicews);
261
262 // Convert from MatrixWorkspace to MDEvents and add events to
263 int scanid = m_expDataTableWS->cell<int>(ir, m_iColScan);
264 g_log.notice() << "[DB] Scan = " << scanid << "\n";
265 int runid = m_expDataTableWS->cell<int>(ir, m_iColPt);
266 g_log.notice() << "Pt = " << runid << "\n"
267 << m_iTime << "-th for time/duration"
268 << "\n";
269 double time(0.);
270 try {
271 float time_f = m_expDataTableWS->cell<float>(ir, m_iTime);
272 time = static_cast<double>(time_f);
273 } catch (const std::runtime_error &) {
274 time = m_expDataTableWS->cell<double>(ir, m_iTime);
275 }
276
277 int monitor_counts = m_expDataTableWS->cell<int>(ir, m_iMonitorCounts);
278 if (!usevirtual)
279 start_detid = 0;
280 convertSpiceMatrixToMomentumMDEvents(spicews, usevirtual, start_detid, scanid, runid, time, monitor_counts);
281 }
282
283 // Set box extents
284 std::vector<API::IMDNode *> boxes;
285
286 // Set extents for all MDBoxes
287 progress(0.90, "Set up MDBoxes' dimensions. ");
288 m_outputWS->getBoxes(boxes, 1000, true);
289 auto it1 = boxes.begin();
290 auto it1_end = boxes.end();
291 for (; it1 != it1_end; it1++) {
292 auto box = *it1;
293 for (size_t dim = 0; dim < 3; ++dim) {
294 auto *mdbox = dynamic_cast<DataObjects::MDBox<MDEvent<3>, 3> *>(box);
295 if (!mdbox)
296 throw std::runtime_error("Unable to cast to MDBox");
297 mdbox->setExtents(dim, -10, 10);
298 mdbox->calcVolume();
299 mdbox->refreshCache(nullptr);
300 }
301 }
302}
303
304//----------------------------------------------------------------------------------------------
314 Kernel::DblMatrix &rotationMatrix) {
315 // Check sample logs
316 if (!dataws->run().hasProperty("_omega") || !dataws->run().hasProperty("_chi") || !dataws->run().hasProperty("_phi"))
317 throw std::runtime_error("Data workspace does not have sample log _phi, _chi or _omega. "
318 "Unable to set goniometer and calcualte roation matrix R.");
319
320 // Call algorithm SetGoniometer
321 auto setalg = createChildAlgorithm("SetGoniometer");
322 setalg->initialize();
323 setalg->setProperty("Workspace", dataws);
324 setalg->setProperty("Axis0", "_omega,0,1,0,-1");
325 setalg->setProperty("Axis1", "_chi,0,0,1,-1");
326 setalg->setProperty("Axis2", "_phi,0,1,0,-1");
327 setalg->execute();
328
329 if (setalg->isExecuted()) {
330 rotationMatrix = dataws->run().getGoniometer().getR();
331 g_log.debug() << "Ratation matrix: " << rotationMatrix.str() << "\n";
332 rotationMatrix.Invert();
333 g_log.debug() << "Ratation matrix: " << rotationMatrix.str() << "\n";
334 } else
335 throw std::runtime_error("Unable to set Goniometer.");
336}
337
338//----------------------------------------------------------------------------------------------
354 const detid_t &startdetid, const int scannumber,
355 const int runnumber, double measuretime,
356 int monitor_counts) {
357 // Create transformation matrix from which the transformation is
358 Kernel::DblMatrix rotationMatrix;
359 setupTransferMatrix(dataws, rotationMatrix);
360
361 g_log.information() << "Before insert new event, output workspace has " << m_outputWS->getNEvents() << "Events.\n";
362
363 // Creates a new instance of the MDEventInserte to output workspace
364 MDEventWorkspace<MDEvent<3>, 3>::sptr mdws_mdevt_3 =
365 std::dynamic_pointer_cast<MDEventWorkspace<MDEvent<3>, 3>>(m_outputWS);
366 MDEventInserter<MDEventWorkspace<MDEvent<3>, 3>::sptr> inserter(mdws_mdevt_3);
367
368 // Calcualte k_i: it is assumed that all k_i are same for one Pt.
369 // number, i.e., one 2D XML file
370 Kernel::V3D sourcePos = dataws->getInstrument()->getSource()->getPos();
371 Kernel::V3D samplePos = dataws->getInstrument()->getSample()->getPos();
372 if (dataws->x(0).size() != 2)
373 throw std::runtime_error("Input matrix workspace has wrong dimension in X-axis.");
374 double momentum = 0.5 * (dataws->x(0)[0] + dataws->x(0)[1]);
375 Kernel::V3D ki = (samplePos - sourcePos) * (momentum / sourcePos.norm());
376
377 g_log.debug() << "Source at " << sourcePos.toString() << ", Norm = " << sourcePos.norm()
378 << ", momentum = " << momentum << "\n"
379 << "k_i = " << ki.toString() << "\n";
380
381 // Go though each spectrum to conver to MDEvent
382 size_t numspec = dataws->getNumberHistograms();
383 const auto &specInfo = dataws->spectrumInfo();
384 double maxsignal = 0;
385 size_t nummdevents = 0;
386 for (size_t iws = 0; iws < numspec; ++iws) {
387 // Get detector positions and signal
388 double signal = dataws->y(iws)[0];
389 // Skip event with 0 signal
390 if (fabs(signal) < 0.001)
391 continue;
392 double error = sqrt(fabs(signal));
393 Kernel::V3D detpos = specInfo.position(iws);
394 std::vector<Mantid::coord_t> q_sample(3);
395
396 // Calculate Q-sample and new detector ID in virtual instrument.
397 Kernel::V3D qlab = convertToQSample(samplePos, ki, detpos, momentum, q_sample, rotationMatrix);
398 detid_t native_detid = specInfo.detector(iws).getID();
399 detid_t detid = native_detid + startdetid;
400
401 // Insert
402 inserter.insertMDEvent(static_cast<float>(signal), static_cast<float>(error * error),
403 static_cast<uint16_t>(runnumber), 0, detid, q_sample.data());
404 updateQRange(q_sample);
405
406 g_log.debug() << "Q-lab = " << qlab.toString() << "\n";
407 g_log.debug() << "Insert DetID " << detid << ", signal = " << signal << ", with q_sample = " << q_sample[0] << ", "
408 << q_sample[1] << ", " << q_sample[2] << "\n";
409
410 // Update some statistical inforamtion
411 if (signal > maxsignal)
412 maxsignal = signal;
413 ++nummdevents;
414 }
415
416 g_log.information() << "Imported Matrixworkspace of run number " << runnumber << ": Max. Signal = " << maxsignal
417 << ", Add " << nummdevents << " MDEvents "
418 << "\n";
419
420 // Add experiment info including instrument, goniometer and run number
421 ExperimentInfo_sptr expinfo = std::make_shared<ExperimentInfo>();
422 if (usevirtual)
423 expinfo->setInstrument(m_virtualInstrument);
424 else {
425 Geometry::Instrument_const_sptr tmp_inst = dataws->getInstrument();
426 expinfo->setInstrument(tmp_inst);
427 }
428 expinfo->mutableRun().setGoniometer(dataws->run().getGoniometer(), false);
429 int scan_run_number = scannumber * 1000 + runnumber;
430 expinfo->mutableRun().addProperty("run_number", scan_run_number);
431 expinfo->mutableRun().addProperty("duration", measuretime);
432 expinfo->mutableRun().addProperty("monitor", monitor_counts);
433 // Add all the other propertys from original data workspace
434 const std::vector<Kernel::Property *> vec_property = dataws->run().getProperties();
435 for (auto property : vec_property) {
436 expinfo->mutableRun().addProperty(property->clone());
437 }
438
439 m_outputWS->addExperimentInfo(expinfo);
440}
441
442//----------------------------------------------------------------------------------------------
449bool ConvertCWSDExpToMomentum::getInputs(bool virtualinstrument, std::string &errmsg) {
450 std::stringstream errss;
451
452 // Table workspace for data file names and starting detector IDs (for virtual
453 // instrument)
454 m_expDataTableWS = getProperty("InputWorkspace");
455 const std::vector<std::string> datacolnames = m_expDataTableWS->getColumnNames();
456 if (datacolnames.size() != 6) {
457 errss << "InputWorkspace must have 6 columns. But now it has " << datacolnames.size() << " columns. \n";
458 } else {
459 if (datacolnames[m_iColFilename] != "File Name" && datacolnames[m_iColFilename] != "Filename")
460 errss << "Data file name Table (InputWorkspace)'s Column " << m_iColFilename
461 << " must be 'File Name' or 'Filename' but not " << datacolnames[m_iColFilename] << ". "
462 << "\n";
463 if (datacolnames[m_iColStartDetID] != "Starting DetID" && datacolnames[m_iColStartDetID] != "StartDetID")
464 errss << "Data file name Table (InputWorkspace)'s Column " << m_iColStartDetID
465 << " must be 'Staring DetID' or 'StartDetID' but not " << datacolnames[m_iColStartDetID] << ". "
466 << "\n";
467 }
468 g_log.warning("Finished parsing Data Table");
469
470 // FIXME/TODO: Add the code to read monitor counts from input table workspace
471
472 // Set up parameters for creating virtual instrument
473 g_log.warning() << "About to deal with virtual instrument" << virtualinstrument << "\n";
474 if (virtualinstrument) {
475 // Table workspace for detector positions
476 m_detectorListTableWS = getProperty("DetectorTableWorkspace");
477 const std::vector<std::string> detcolnames = m_detectorListTableWS->getColumnNames();
478 if (detcolnames.size() != 5) {
479 errss << "Detector table (DetectorTableWorkspace) must have 5 columns"
480 << "\n";
481 }
482
483 // Sample and source position
484 std::vector<double> sourcepos = getProperty("SourcePosition");
485 if (sourcepos.size() != 3)
486 errss << "SourcePosition must have 3 items. Input has " << sourcepos.size() << " instead.\n";
487 else {
488 m_sourcePos.setX(sourcepos[0]);
489 m_sourcePos.setY(sourcepos[1]);
490 m_sourcePos.setZ(sourcepos[2]);
491 }
492
493 std::vector<double> samplepos = getProperty("SamplePosition");
494 if (samplepos.size() != 3) {
495 errss << "SamplePosition must have 3 items. Input has " << samplepos.size() << " instead.\n";
496 } else {
497 m_samplePos.setX(samplepos[0]);
498 m_samplePos.setY(samplepos[1]);
499 m_samplePos.setZ(samplepos[2]);
500 }
501 }
502
503 m_isBaseName = getProperty("IsBaseName");
504 if (m_isBaseName)
505 m_dataDir = getPropertyValue("Directory");
506
507 errmsg = errss.str();
508
509 return (errmsg.empty());
510}
511
512//----------------------------------------------------------------------------------------------
524 const Kernel::V3D &detPos, const double &momentum,
525 std::vector<coord_t> &qSample,
526 const Kernel::DblMatrix &rotationMatrix) {
527
528 // Use detector position and wavelength/Q to calcualte Q_lab
529 Kernel::V3D kf;
530 kf = (detPos - samplePos) * (momentum / (detPos - samplePos).norm());
531 Kernel::V3D q_lab = ki - kf;
532
533 // Calculate q_sample from qlab and R matrix
534 Kernel::V3D q_sample = rotationMatrix * q_lab;
535 qSample.resize(3);
536 qSample[0] = static_cast<float>(q_sample.X());
537 qSample[1] = static_cast<float>(q_sample.Y());
538 qSample[2] = static_cast<float>(q_sample.Z());
539
540 return q_lab;
541}
542
543//----------------------------------------------------------------------------------------------
552 std::string &errmsg) {
553 // Init output
555 errmsg = "";
556
557 // Load SPICE file
558 try {
559 auto loader = createChildAlgorithm("LoadSpiceXML2DDet");
560 loader->initialize();
561 loader->setProperty("Filename", filename);
562 // std::vector<size_t> sizelist(2);
563 // sizelist[0] = 256;
564 // sizelist[1] = 256;
565 // loader->setProperty("DetectorGeometry", sizelist);
566 loader->setProperty("LoadInstrument", true);
567 loader->setProperty("ShiftedDetectorDistance", m_detSampleDistanceShift);
568 loader->setProperty("DetectorCenterXShift", m_detXShift);
569 loader->setProperty("DetectorCenterYShift", m_detYShift);
570
571 // TODO/FIXME - This is not a nice solution for detector geometry
572 // std::string idffile = getPropertyValue("InstrumentFilename");
573 // if (idffile.size() > 0) {
574 // loader->setProperty("InstrumentFilename", idffile);
575 // loader->setProperty("DetectorGeometry", "512, 512");
576 // }
577
578 double wavelength = getProperty("UserDefinedWavelength");
579
580 if (wavelength != EMPTY_DBL())
581 loader->setProperty("UserSpecifiedWaveLength", wavelength);
582
583 loader->execute();
584
585 dataws = loader->getProperty("OutputWorkspace");
586 loaded = static_cast<bool>(dataws);
587 } catch (std::runtime_error &runerror) {
588 loaded = false;
589 errmsg = runerror.what();
590 }
591
592 return dataws;
593}
594
595//----------------------------------------------------------------------------------------------
601void ConvertCWSDExpToMomentum::parseDetectorTable(std::vector<Kernel::V3D> &vec_detpos,
602 std::vector<detid_t> &vec_detid) {
603 // Set vectors' sizes
604 size_t numrows = m_detectorListTableWS->rowCount();
605 vec_detpos.resize(numrows);
606 vec_detid.resize(numrows);
607
608 // Parse table
609 for (size_t i = 0; i < numrows; ++i) {
610 detid_t detid = m_detectorListTableWS->cell<int>(i, 0);
611 vec_detid[i] = detid;
612
613 double x = m_detectorListTableWS->cell<double>(i, 1);
614 double y = m_detectorListTableWS->cell<double>(i, 2);
615 double z = m_detectorListTableWS->cell<double>(i, 3);
616 Kernel::V3D detpos(x, y, z);
617 vec_detpos[i] = detpos;
618 }
619}
620
621//----------------------------------------------------------------------------------------------
626void ConvertCWSDExpToMomentum::updateQRange(const std::vector<Mantid::coord_t> &vec_q) {
627 for (size_t i = 0; i < vec_q.size(); ++i) {
628 if (m_setQRange) {
629 m_minQVec[i] = vec_q[i];
630 m_maxQVec[i] = vec_q[i];
631 m_setQRange = false;
632 } else if (vec_q[i] < m_minQVec[i])
633 m_minQVec[i] = vec_q[i];
634 else if (vec_q[i] > m_maxQVec[i])
635 m_maxQVec[i] = vec_q[i];
636 }
637}
638
644 if (dataws->getNumberHistograms() != m_backgroundWS->getNumberHistograms())
645 throw std::runtime_error("Impossible to have this situation");
646
647 size_t numhist = dataws->getNumberHistograms();
648 for (size_t i = 0; i < numhist; ++i) {
649 double bkgd_y = m_backgroundWS->y(i)[0];
650 if (fabs(bkgd_y) > 1.E-2) {
651 dataws->mutableY(i)[0] -= bkgd_y;
652 dataws->mutableE(i)[0] = std::sqrt(dataws->y(i)[0]);
653 }
654 }
655}
656
657} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
double error
#define fabs(x)
Definition Matrix.cpp:22
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Kernel::Logger & g_log
Definition Algorithm.h:422
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
@ OptionalDirectory
to specify a directory that does not have to exist
A property class for workspaces.
Templated class for a multi-dimensional event "box".
Definition MDBox.h:45
static API::IMDEventWorkspace_sptr CreateMDWorkspace(size_t nd, const std::string &eventType="MDLeanEvent", const Mantid::API::MDNormalization &preferredNormalization=Mantid::API::MDNormalization::VolumeNormalization, const Mantid::API::MDNormalization &preferredNormalizationHisto=Mantid::API::MDNormalization::VolumeNormalization)
Create a MDEventWorkspace of the given type.
MDEventInserter : Helper class that provides a generic interface for adding events to an MDWorkspace ...
Templated class for the multi-dimensional event workspace.
QSample : Q in the sample frame.
Definition QSample.h:20
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
Definition Logger.cpp:145
void notice(const std::string &msg)
Logs at notice level.
Definition Logger.cpp:126
void error(const std::string &msg)
Logs at error level.
Definition Logger.cpp:108
void warning(const std::string &msg)
Logs at warning level.
Definition Logger.cpp:117
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
T Invert()
LU inversion routine.
Definition Matrix.cpp:924
std::string str() const
Convert the matrix into a simple linear string expression.
Definition Matrix.cpp:1562
Class for 3D vectors.
Definition V3D.h:34
constexpr double X() const noexcept
Get x.
Definition V3D.h:238
constexpr double Y() const noexcept
Get y.
Definition V3D.h:239
std::string toString() const
Definition V3D.cpp:332
void setZ(const double zz) noexcept
Set is z position.
Definition V3D.h:236
double norm() const noexcept
Definition V3D.h:269
void setX(const double xx) noexcept
Set is x position.
Definition V3D.h:224
void setY(const double yy) noexcept
Set is y position.
Definition V3D.h:230
constexpr double Z() const noexcept
Get z.
Definition V3D.h:240
ConvertCWSDExpToMomentum : TODO: DESCRIPTION.
void addMDEvents(bool usevirtual)
Add MDEvents to MDEventWorkspace from data set in the experiment Run number is determined by the row ...
API::IMDEventWorkspace_sptr createExperimentMDWorkspace()
Create output workspace.
void parseDetectorTable(std::vector< Kernel::V3D > &vec_detpos, std::vector< detid_t > &vec_detid)
Parase detetor table workspace to vector of detector positions.
void updateQRange(const std::vector< Mantid::coord_t > &vec_q)
Update (sample) Q range.
const std::string name() const override
Algorithm's name.
void init() override
Init to declare property.
API::MatrixWorkspace_sptr loadSpiceData(const std::string &filename, bool &loaded, std::string &errmsg)
Load SPICE data to Matrix workspace.
bool getInputs(bool virtualinstrument, std::string &errmsg)
Examine input.
double m_detSampleDistanceShift
Shifts in detector position set from user (calibration): all in the unit as meter.
Kernel::V3D convertToQSample(const Kernel::V3D &samplePos, const Kernel::V3D &ki, const Kernel::V3D &detPos, const double &momentum, std::vector< Mantid::coord_t > &qSample, const Kernel::DblMatrix &rotationMatrix)
Convert |Q| with detector position to Q_sample.
void removeBackground(const API::MatrixWorkspace_sptr &dataws)
Remove background from.
void setupTransferMatrix(const API::MatrixWorkspace_sptr &dataws, Kernel::DblMatrix &rotationMatrix)
Set goniometer to matrix workspace and get its rotation matrix R (from Q-sample to Q-lab and output 1...
void convertSpiceMatrixToMomentumMDEvents(const API::MatrixWorkspace_sptr &dataws, bool usevirtual, const detid_t &startdetid, const int scannumber, const int runnumber, double measuretime, int monitor_counts)
Convert a SPICE 2D Det MatrixWorkspace to MDEvents and append to an MDEventWorkspace It is optional t...
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
MANTID_GEOMETRY_DLL Geometry::Instrument_sptr createVirtualInstrument(Kernel::V3D sourcePos, Kernel::V3D samplePos, const std::vector< Kernel::V3D > &vecdetpos, const std::vector< detid_t > &vecdetid)
std::shared_ptr< MDHistoDimension > MDHistoDimension_sptr
Shared pointer to a MDHistoDimension.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
Definition MDTypes.h:27
int32_t detid_t
Typedef for a detector ID.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
Definition EmptyValues.h:42
@ Input
An input workspace.
Definition Property.h:53
@ Output
An output workspace.
Definition Property.h:54