33using namespace Kernel;
36using namespace HistogramData;
38using namespace DataObjects;
43const std::string
BEAMLINE{
"/raw_data_1/beamline"};
48 : m_filename(), m_entrynumber(0), m_isFileMultiPeriod(false), m_multiPeriodsLoaded(false) {}
71 Nexus::File file(descriptor.
filename());
73 std::string def = file.getStrData();
74 if (def ==
"muonTD" || def ==
"pulsedTD") {
84 std::vector<std::string> extensions{
".nxs",
".nxs_v2",
".nxs_v1"};
86 "The name of the Nexus file to load");
89 "The name of the workspace to be created as the output of the\n"
90 "algorithm. For multiperiod files, one workspace will be\n"
91 "generated for each period");
93 auto mustBePositiveSpectra = std::make_shared<BoundedValidator<specnum_t>>();
94 mustBePositiveSpectra->setLower(0);
98 auto mustBePositive = std::make_shared<BoundedValidator<int64_t>>();
99 mustBePositive->setLower(0);
100 declareProperty(
"EntryNumber",
static_cast<int64_t
>(0), mustBePositive,
101 "0 indicates that every entry is loaded, into a separate "
102 "workspace within a group. "
103 "A positive number identifies one entry to be loaded, into "
106 std::vector<std::string> FieldOptions{
"Transverse",
"Longitudinal"};
107 declareProperty(
"MainFieldDirection",
"Transverse", std::make_shared<StringListValidator>(FieldOptions),
108 "Output the main field direction if specified in Nexus file "
109 "(default longitudinal).",
113 declareProperty(
"FirstGoodData", 0.0,
"First good data in units of micro-seconds (default to 0.0)",
118 "A vector of time zero values");
122 "TableWorkspace containing time zero values per spectra.");
124 declareProperty(
"CorrectTime",
true,
"Boolean flag controlling whether time should be corrected by timezero.",
129 "Table or a group of tables containing detector dead times.");
133 "Table or a group of tables with information about the "
134 "detector grouping.");
143 m_nexusLoader = std::make_unique<LoadMuonNexusV2NexusHelper>(entry);
159 setProperty(
"DetectorGroupingTable", loadedGrouping);
181 if (numberOfPeriods > 1) {
205 struct ScopedNumThreadsSetter {
206 ScopedNumThreadsSetter(
const int numThreads) {
212 int globalNumberOfThreads;
214 ScopedNumThreadsSetter restoreDefaultThreadsOnExit(1);
217 auto ISISLoader = std::dynamic_pointer_cast<API::Algorithm>(childAlg);
218 ISISLoader->copyPropertiesFrom(*
this);
219 ISISLoader->execute();
234 assert(workspaceGroup);
235 auto numberHistograms = std::dynamic_pointer_cast<Workspace2D>(workspaceGroup->getItem(0))->getNumberHistograms();
256 std::string mainFieldDirection =
m_nexusLoader->loadMainFieldDirectionFromNexus();
257 setProperty(
"MainFieldDirection", mainFieldDirection);
259 double timeZero =
m_nexusLoader->loadTimeZeroFromNexusFile();
262 auto firstGoodData =
m_nexusLoader->loadFirstGoodDataFromNexus();
265 auto lastGoodData =
m_nexusLoader->loadLastGoodDataFromNexus();
268 auto timeZeroVector =
m_nexusLoader->loadTimeZeroListFromNexusFile(numSpectra);
277 auto newUnit = std::dynamic_pointer_cast<Kernel::Units::Label>(Kernel::UnitFactory::Instance().
create(
"Label"));
280 if (workspaceGroup) {
281 for (
int i = 0; i < workspaceGroup->getNumberOfEntries(); ++i) {
282 auto workspace2D = std::dynamic_pointer_cast<Workspace2D>(workspaceGroup->getItem(i));
283 workspace2D->getAxis(0)->unit() = newUnit;
294 auto sequences =
m_nexusLoader->getPeriodSequenceString(numberOfPeriods);
296 auto requested =
m_nexusLoader->getPeriodFramesRequested(numberOfPeriods);
297 auto rawFrames =
m_nexusLoader->getPeriodRawFrames(numberOfPeriods);
298 auto output =
m_nexusLoader->getPeriodOutput(numberOfPeriods);
302 if (workspaceGroup) {
303 for (
int i = 0; i < workspaceGroup->getNumberOfEntries(); ++i) {
304 auto workspace2D = std::dynamic_pointer_cast<Workspace2D>(workspaceGroup->getItem(i));
305 auto &run = workspace2D->mutableRun();
306 run.addProperty(
"period_labels", labels);
307 run.addProperty(
"period_sequences", sequences);
308 run.addProperty(
"period_type", types);
309 run.addProperty(
"frames_period_requested", requested);
310 run.addProperty(
"frames_period_raw", rawFrames);
311 run.addProperty(
"period_output", output);
312 run.addProperty(
"total_counts_period", counts);
318 run.addProperty(
"period_sequences", sequences);
319 run.addProperty(
"period_type", types);
320 run.addProperty(
"frames_period_requested", requested);
321 run.addProperty(
"frames_period_raw", rawFrames);
322 run.addProperty(
"period_output", output);
323 run.addProperty(
"total_counts_period", counts);
IPeaksWorkspace_sptr workspace
#define PARALLEL_SET_NUM_THREADS(MaxCores)
#define PARALLEL_GET_MAX_THREADS
#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname)
DECLARE_NEXUS_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro wh...
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 void copyPropertiesFrom(const Algorithm &alg)
Make m_properties point to the same PropertyManager as alg.m_properties.
const std::shared_ptr< Kernel::Unit > & unit() const
The unit for this axis.
Run & mutableRun()
Writable version of the run object.
@ Load
allowed here which will be passed to the algorithm
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
virtual Axis * getAxis(const std::size_t &axisIndex) const
Get a non owning pointer to a workspace axis.
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) override
Create a Child Algorithm.
Class to hold a set of workspaces.
A property class for workspaces.
Base Workspace Abstract Class.
std::unique_ptr< LoadMuonStrategy > m_loadMuonStrategy
bool m_multiPeriodsLoaded
void isEntryMultiPeriod()
Determines whether the file is multi period If multi period the function determines whether multi per...
std::string m_filename
The name and path of the input file.
void applyTimeAxisUnitCorrection(API::Workspace &workspace)
std::unique_ptr< LoadMuonNexusV2NexusHelper > m_nexusLoader
void chooseLoaderStrategy(const API::Workspace_sptr &workspace)
Determines the loading strategy used by the Algorithm.
LoadMuonNexusV2()
Empty default constructor.
int64_t m_entrynumber
The number of the input entry.
int confidence(Nexus::NexusDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
void init() override
Overwrites Algorithm method.
void loadMuonProperties(size_t numSpectra)
Loads Muon specific data from the nexus entry and sets the appropriate output properties.
void execLoader() override
Overwrites Algorithm method.
API::Workspace_sptr runLoadISISNexus()
Runs the child algorithm LoadISISNexus, which loads data into an output workspace.
void loadPeriodInfo(API::Workspace &workspace)
Concrete workspace implementation.
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.
static const UnitLabel Microsecond
Microsecond.
Implements NXentry Nexus class.
Implements NXroot Nexus class.
NXEntry openEntry(const std::string &name)
Opens an entry – a topmost Nexus class.
bool isEntry(const std::string &entryName, const std::string &groupClass) const noexcept
Checks if a full-address entry exists for a particular groupClass in a Nexus dataset.
const std::string & filename() const noexcept
Returns a copy of the current file name.
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Kernel::Logger g_log("ExperimentInfo")
static logger object
const std::string BEAMLINE
const std::string RAWDATA
const std::string DEFINITION
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
int32_t specnum_t
Typedef for a spectrum Number.
@ Input
An input workspace.
@ Output
An output workspace.