29using namespace Kernel;
34 : m_filename(), m_numberOfSpectra(), m_cache_options(), m_specTimeRegimes(), m_noTimeRegimes(0), m_prog(0.0),
35 m_prog_start(0.0), m_prog_end(1.0), m_lengthIn(0), m_timeChannelsVec(), m_total_specs(0), m_periodList() {}
40 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
41 mustBePositive->setLower(1);
43 "The index number of the first spectrum to read. Only used if\n"
44 "SpectrumMax is set.");
46 "The number of the last spectrum to read. Only used if explicitly\n"
49 "A comma-separated list of individual spectra to read. Only used if\n"
52 "A comma-separated list of individual periods to read. Only used if\n"
55 std::vector<std::string> monitorOptions;
56 monitorOptions.emplace_back(
"Include");
57 monitorOptions.emplace_back(
"Exclude");
58 monitorOptions.emplace_back(
"Separate");
59 std::map<std::string, std::string> monitorOptionsAliases;
60 monitorOptionsAliases[
"1"] =
"Separate";
61 monitorOptionsAliases[
"0"] =
"Exclude";
63 std::make_shared<StringListValidator>(monitorOptions, monitorOptionsAliases),
64 "Option to control the loading of monitors.\n"
65 "Allowed options are Include,Exclude, Separate.\n"
66 "Include:The default is Include option which loads the "
67 "monitors into the output workspace.\n"
68 "Exclude:The Exclude option excludes monitors from the "
70 "Separate:The Separate option loads monitors into a separate "
71 "workspace called OutputWorkspace_monitor.\n"
73 "1: Equivalent to Separate.\n"
74 "0: Equivalent to Exclude.\n");
91 bool bincludeMonitors, bseparateMonitors, bexcludeMonitors;
121 localWorkspace->updateSpectraUsing(detectorMapping);
125 Run &run = localWorkspace->mutableRun();
129 const int period_number = firstPeriod + 1;
141 g_log.
debug(
"Populating the instrument parameters...");
143 localWorkspace->populateInstrumentParameters();
150 std::vector<specnum_t> monitorSpecList;
152 if (bincludeMonitors) {
161 }
catch (std::out_of_range &) {
168 if (normalwsSpecs > 0) {
173 if (bseparateMonitors) {
179 if (bseparateMonitors) {
180 if (normalwsSpecs == 0) {
185 ws_grp = monitorws_grp;
187 localWorkspace->setMonitorWorkspace(monitorWorkspace);
204 if (period > firstPeriod) {
205 if (localWorkspace) {
208 if (bseparateMonitors) {
211 }
catch (std::out_of_range &) {
213 "monitors in the selected specra range.\n";
215 }
catch (std::runtime_error &) {
217 "in creating one of the output workspaces\n";
222 const int period_number = period + 1;
224 std::stringstream prevPeriod;
226 if (localWorkspace) {
227 Run &runObj = localWorkspace->mutableRun();
233 if (monitorWorkspace) {
234 Run &runObj = monitorWorkspace->mutableRun();
243 if (bexcludeMonitors) {
246 if (bincludeMonitors) {
249 if (bseparateMonitors) {
250 separateMonitors(file, period, monitorSpecList, localWorkspace, monitorWorkspace);
255 localWorkspace->updateSpectraUsing(detectorMapping);
257 if (monitorWorkspace)
258 monitorWorkspace->updateSpectraUsing(detectorMapping);
262 if (bseparateMonitors) {
263 if (normalwsSpecs > 0) {
267 localWorkspace = monitorWorkspace;
292 int64_t histCurrent = -1;
309 throw std::runtime_error(
"Error reading raw file");
317 if (++histCurrent % 100 == 0) {
318 setProg(
static_cast<double>(histCurrent) / histTotal);
337 int64_t histCurrent = -1;
349 throw std::runtime_error(
"Error reading raw file");
356 if (++histCurrent % 100 == 0) {
357 setProg(
double(histCurrent) / histTotal);
380 int64_t histCurrent = -1;
382 int64_t mwsIndex = 0;
393 throw std::runtime_error(
"Error reading raw file");
406 if (++histCurrent % 100 == 0) {
407 setProg(
static_cast<double>(histCurrent) / histTotal);
446 throw std::logic_error(
"Unexpected period number found.");
468 throw std::runtime_error(
"Values in PeriodList must be between 1 and "
469 "total number of periods.");
487 const int64_t monitorwsSpecs) {
488 if (normalwsSpecs <= 0 && bexcludeMonitors) {
489 throw std::out_of_range(
"All the spectra in the selected range for this "
490 "workspace are monitors and Exclude monitors "
493 if (bseparateMonitors) {
494 if (normalwsSpecs <= 0 && monitorwsSpecs <= 0) {
495 throw std::out_of_range(
"Workspace size is zero,Error in creating output workspace.");
506 return (find(monitorIndexes.begin(), monitorIndexes.end(), spectrumNum) != monitorIndexes.end());
#define DECLARE_FILELOADER_ALGORITHM(classname)
DECLARE_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro when wri...
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.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
void interruption_point()
This is called during long-running operations, and check if the algorithm has requested that it be ca...
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
void removeLogData(const std::string &name, const bool delproperty=true)
Remove a named log entry.
This class stores information regarding an experimental run as a series of log entries.
A minimal class to hold the mapping between the spectrum number and its related detector ID numbers f...
std::vector< std::shared_ptr< HistogramData::HistogramX > > m_timeChannelsVec
time channels vector
int64_t m_lengthIn
Read in the time bin boundaries.
int64_t m_noTimeRegimes
number of time regime
std::vector< int > m_periodList
A list of periods to read. Each value is between 1 and m_numberOfPeriods.
void exec() override
Overwrites Algorithm method.
int getPreviousPeriod(int period) const
get the previous period number
void separateMonitors(FILE *file, const int64_t &period, const std::vector< specnum_t > &monitorList, const DataObjects::Workspace2D_sptr &ws_sptr, const DataObjects::Workspace2D_sptr &mws_sptr)
creates two output workspaces none normal workspace and separate one for monitors
void setProg(double)
sets progress taking account of progress time taken up by ChildAlgorithms
std::string m_filename
The name and path of the input file.
bool isPeriodIncluded(int period) const
check if a period should be loaded
void includeMonitors(FILE *file, const int64_t &period, const DataObjects::Workspace2D_sptr &ws_sptr)
creates output workspace whcih includes monitors
double m_prog_start
Start and ends values of progress counter.
void validateWorkspaceSizes(bool bexcludeMonitors, bool bseparateMonitors, const int64_t normalwsSpecs, const int64_t monitorwsSpecs)
validate workspace sizes
int64_t m_total_specs
total number of specs
LoadRaw3()
Default constructor.
double m_prog
The current value of the progress counter.
bool isSelectedPeriods() const
return true if loading a selection of periods
void setOptionalProperties()
sets optional properties
void skipPeriod(FILE *file, const int64_t &period)
skip all spectra in a period
void init() override
Overwrites Algorithm method.
bool isMonitor(const std::vector< specnum_t > &monitorIndexes, specnum_t spectrumNum)
returns true if the given spectrum is a monitor
void excludeMonitors(FILE *file, const int &period, const std::vector< specnum_t > &monitorList, const DataObjects::Workspace2D_sptr &ws_sptr)
creates output workspace, monitors excluded from this workspace
specnum_t m_numberOfSpectra
The number of spectra in the raw file.
std::vector< std::shared_ptr< HistogramData::HistogramX > > getTimeChannels(const int64_t ®imes, const int64_t &lengthIn)
Constructs the time channel (X) vector(s)
void reset()
resets the isisraw shared pointer
void calculateWorkspacesizes(const std::vector< specnum_t > &monitorSpecList, specnum_t &normalwsSpecs, specnum_t &monitorwsSpecs)
calculate workspace sizes if separate or exclude monitors are selected
void readTitle(FILE *file, std::string &title)
Reads title from the isisraw class.
void skipData(FILE *file, int hist)
skips histrogram data from raw file.
static void setWorkspaceProperty(const std::string &propertyName, const std::string &title, const API::WorkspaceGroup_sptr &grpws_sptr, const DataObjects::Workspace2D_sptr &ws_sptr, int64_t numberOfPeriods, bool bMonitor, API::Algorithm *const pAlg)
sets the workspace property
static DataObjects::Workspace2D_sptr createWorkspace(const DataObjects::Workspace2D_sptr &ws_sptr, int64_t nVectors=-1, int64_t xLengthIn=-1, int64_t yLengthIn=-1)
creates shared pointer to workspace from parent workspace
static void ProcessLoadMonitorOptions(bool &bincludeMonitors, bool &bseparateMonitors, bool &bexcludeMonitors, const API::Algorithm *pAlgo)
The method to interpret LoadMonitors property options and convert then into boolean values.
static void createMonitorWorkspace(DataObjects::Workspace2D_sptr &monws_sptr, const DataObjects::Workspace2D_sptr &normalws_sptr, API::WorkspaceGroup_sptr &mongrp_sptr, const int64_t mwsSpecs, const int64_t nwsSpecs, const int64_t numberOfPeriods, const int64_t lengthIn, const std::string &title, API::Algorithm *const pAlg)
creates monitor workspace
ISISRAW2 & isisRaw() const
return an reference to the ISISRAW2 reader
void init() override
Overwrites Algorithm method.
specnum_t m_spec_max
The value of the spectrum_max property.
std::vector< specnum_t > m_spec_list
The value of the spectrum_list property.
bool readData(FILE *file, int hist)
reads data
void createPeriodLogs(int64_t period, const DataObjects::Workspace2D_sptr &local_workspace)
Create the period specific logs.
specnum_t m_spec_min
The value of the spectrum_min property.
void runLoadLog(const std::string &fileName, const DataObjects::Workspace2D_sptr &, double, double)
load log algorithm
void setRunNumber(API::Run &run)
Stores the run number in the sample's logs.
void loadRunParameters(const API::MatrixWorkspace_sptr &localWorkspace, ISISRAW *const =nullptr) const
Read in run parameters Public so that LoadRaw2 can use it.
void runLoadInstrument(const std::string &fileName, const DataObjects::Workspace2D_sptr &, double, double)
loadinstrument Child Algorithm
FILE * openRawFile(const std::string &fileName)
Opens Raw File.
void readworkspaceParameters(specnum_t &numberOfSpectra, int &numberOfPeriods, int64_t &lengthIn, int64_t &noTimeRegimes)
reads workspace parameters like number of histograms,size of vectors etc
bool m_list
Has the spectrum_list property been set?
void setProtonCharge(API::Run &run)
set proton charge
static API::WorkspaceGroup_sptr createGroupWorkspace()
creates shared pointer to group workspace
specnum_t calculateWorkspaceSize()
calculate workspace size
void setWorkspaceData(const DataObjects::Workspace2D_sptr &newWorkspace, const std::vector< std::shared_ptr< HistogramData::HistogramX > > &timeChannelsVec, int64_t wsIndex, specnum_t nspecNum, int64_t noTimeRegimes, int64_t lengthIn, int64_t binStart)
This method sets the raw file data to workspace vectors.
void checkOptionalProperties()
Validates the optional 'spectra to read' properties, if they have been set.
std::vector< specnum_t > getmonitorSpectrumList(const API::SpectrumDetectorMapping &mapping)
gets the monitor spectrum list from the workspace
int m_numberOfPeriods
The number of periods in the raw file.
Support for a property that holds an array of values.
void debug(const std::string &msg)
Logs at debug level.
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
int32_t specnum_t
Typedef for a spectrum Number.