30using namespace Kernel;
35 : m_filename(), m_numberOfSpectra(), m_cache_options(), m_specTimeRegimes(), m_noTimeRegimes(0), m_prog(0.0),
36 m_prog_start(0.0), m_prog_end(1.0), m_lengthIn(0), m_timeChannelsVec(), m_total_specs(0), m_periodList() {}
41 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
42 mustBePositive->setLower(1);
44 "The index number of the first spectrum to read. Only used if\n"
45 "SpectrumMax is set.");
47 "The number of the last spectrum to read. Only used if explicitly\n"
50 "A comma-separated list of individual spectra to read. Only used if\n"
53 "A comma-separated list of individual periods to read. Only used if\n"
56 std::vector<std::string> monitorOptions;
57 monitorOptions.emplace_back(
"Include");
58 monitorOptions.emplace_back(
"Exclude");
59 monitorOptions.emplace_back(
"Separate");
60 std::map<std::string, std::string> monitorOptionsAliases;
61 monitorOptionsAliases[
"1"] =
"Separate";
62 monitorOptionsAliases[
"0"] =
"Exclude";
64 std::make_shared<StringListValidator>(monitorOptions, monitorOptionsAliases),
65 "Option to control the loading of monitors.\n"
66 "Allowed options are Include,Exclude, Separate.\n"
67 "Include:The default is Include option which loads the "
68 "monitors into the output workspace.\n"
69 "Exclude:The Exclude option excludes monitors from the "
71 "Separate:The Separate option loads monitors into a separate "
72 "workspace called OutputWorkspace_monitor.\n"
74 "1: Equivalent to Separate.\n"
75 "0: Equivalent to Exclude.\n");
92 bool bincludeMonitors, bseparateMonitors, bexcludeMonitors;
122 localWorkspace->updateSpectraUsing(detectorMapping);
126 Run &run = localWorkspace->mutableRun();
130 const int period_number = firstPeriod + 1;
142 g_log.
debug(
"Populating the instrument parameters...");
144 localWorkspace->populateInstrumentParameters();
151 std::vector<specnum_t> monitorSpecList;
153 if (bincludeMonitors) {
162 }
catch (std::out_of_range &) {
169 if (normalwsSpecs > 0) {
174 if (bseparateMonitors) {
180 if (bseparateMonitors) {
181 if (normalwsSpecs == 0) {
186 ws_grp = monitorws_grp;
188 localWorkspace->setMonitorWorkspace(monitorWorkspace);
205 if (period > firstPeriod) {
206 if (localWorkspace) {
209 if (bseparateMonitors) {
212 }
catch (std::out_of_range &) {
214 "monitors in the selected specra range.\n";
216 }
catch (std::runtime_error &) {
218 "in creating one of the output workspaces\n";
223 const int period_number = period + 1;
225 std::stringstream prevPeriod;
227 if (localWorkspace) {
228 Run &runObj = localWorkspace->mutableRun();
234 if (monitorWorkspace) {
235 Run &runObj = monitorWorkspace->mutableRun();
244 if (bexcludeMonitors) {
247 if (bincludeMonitors) {
250 if (bseparateMonitors) {
251 separateMonitors(file, period, monitorSpecList, localWorkspace, monitorWorkspace);
256 localWorkspace->updateSpectraUsing(detectorMapping);
258 if (monitorWorkspace)
259 monitorWorkspace->updateSpectraUsing(detectorMapping);
263 if (bseparateMonitors) {
264 if (normalwsSpecs > 0) {
268 localWorkspace = monitorWorkspace;
293 int64_t histCurrent = -1;
310 throw std::runtime_error(
"Error reading raw file");
318 if (++histCurrent % 100 == 0) {
319 setProg(
static_cast<double>(histCurrent) / histTotal);
338 int64_t histCurrent = -1;
350 throw std::runtime_error(
"Error reading raw file");
357 if (++histCurrent % 100 == 0) {
358 setProg(
double(histCurrent) / histTotal);
381 int64_t histCurrent = -1;
383 int64_t mwsIndex = 0;
394 throw std::runtime_error(
"Error reading raw file");
407 if (++histCurrent % 100 == 0) {
408 setProg(
static_cast<double>(histCurrent) / histTotal);
447 throw std::logic_error(
"Unexpected period number found.");
469 throw std::runtime_error(
"Values in PeriodList must be between 1 and "
470 "total number of periods.");
488 const int64_t monitorwsSpecs) {
489 if (normalwsSpecs <= 0 && bexcludeMonitors) {
490 throw std::out_of_range(
"All the spectra in the selected range for this "
491 "workspace are monitors and Exclude monitors "
494 if (bseparateMonitors) {
495 if (normalwsSpecs <= 0 && monitorwsSpecs <= 0) {
496 throw std::out_of_range(
"Workspace size is zero,Error in creating output workspace.");
507 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 void ProcessLoadMonitorOptions(bool &bincludeMonitors, bool &bseparateMonitors, bool &bexcludeMonitors, API::Algorithm *const pAlgo)
The method to interpret LoadMonitors property options and convert then into boolean values.
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 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.