Mantid
Loading...
Searching...
No Matches
LoadMappingTable.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 +
8#include "LoadRaw/isisraw2.h"
12
13namespace Mantid::DataHandling {
14
15using namespace Kernel;
16using namespace API;
17
18DECLARE_ALGORITHM(LoadMappingTable)
19
21
23 declareProperty(std::make_unique<FileProperty>("Filename", "", FileProperty::Load),
24 "The name of the RAW file from which to obtain the mapping "
25 "information, including its full or relative path.");
26 declareProperty(std::make_unique<WorkspaceProperty<>>("Workspace", "Anonymous", Direction::InOut),
27 "The name of the input and output workspace on which to perform the "
28 "algorithm.");
29}
30
32 // Get the raw file name
33 m_filename = getPropertyValue("Filename");
34 // Get the input workspace
35 const MatrixWorkspace_sptr localWorkspace = getProperty("Workspace");
36
38 auto iraw = std::make_unique<ISISRAW2>();
39
40 if (iraw->readFromFile(m_filename.c_str(), false) != 0) // ReadFrom File with no data
41 {
42 g_log.error("Unable to open file " + m_filename);
43 throw Kernel::Exception::FileError("Unable to open File:", m_filename);
44 }
45 progress(0.5);
46 const int number_spectra = iraw->i_det; // Number of entries in the spectra/udet table
47 if (number_spectra == 0) {
48 g_log.warning("The spectra to detector mapping table is empty");
49 }
50 // Fill in the mapping in the workspace's ISpectrum objects
51 localWorkspace->updateSpectraUsing(SpectrumDetectorMapping(iraw->spec, iraw->udet, number_spectra));
52 progress(1);
53}
54
55} // namespace Mantid::DataHandling
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
Kernel::Logger & g_log
Definition: Algorithm.h:451
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Definition: Algorithm.cpp:231
@ Load
allowed here which will be passed to the algorithm
Definition: FileProperty.h:52
A minimal class to hold the mapping between the spectrum number and its related detector ID numbers f...
A property class for workspaces.
Loads the mapping table between spectra and IDetector from a raw file.
void init() override
Overwrites Algorithm method.
std::string m_filename
The name and path of the input file.
void exec() override
Overwrites Algorithm method.
Records the filename and the description of failure.
Definition: Exception.h:98
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ InOut
Both an input & output workspace.
Definition: Property.h:55