Mantid
Loading...
Searching...
No Matches
SaveNexusProcessed.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 +
7#pragma once
8
11#include "MantidDataHandling/DllConfig.h"
13#include <boost/optional.hpp>
14#include <climits>
15#include <nexus/NeXusFile.hpp>
16
17namespace Mantid {
18namespace NeXus {
19class NexusFileIO;
20}
21namespace DataHandling {
37class MANTID_DATAHANDLING_DLL SaveNexusProcessed : public API::SerialAlgorithm {
38public:
40 const std::string name() const override { return "SaveNexusProcessed"; }
42 const std::string summary() const override {
43 return "The SaveNexusProcessed algorithm will write the given Mantid "
44 "workspace to a Nexus file. SaveNexusProcessed may be invoked by "
45 "SaveNexus.";
46 }
47
49 int version() const override { return 1; }
50 const std::vector<std::string> seeAlso() const override {
51 return {"SaveISISNexus", "SaveNexus", "LoadNexusProcessed"};
52 }
54 const std::string category() const override { return "DataHandling\\Nexus"; }
55
56 void saveSpectraDetectorMapNexus(const API::MatrixWorkspace &ws, ::NeXus::File *file,
57 const std::vector<int> &wsIndices,
58 const ::NeXus::NXcompression compression = ::NeXus::LZW) const;
59
60 void saveSpectrumNumbersNexus(const API::MatrixWorkspace &ws, ::NeXus::File *file, const std::vector<int> &wsIndices,
61 const ::NeXus::NXcompression compression = ::NeXus::LZW) const;
62
63 virtual bool saveLegacyInstrument() { return true; }
64
65protected:
67 bool processGroups() override;
68
70 void init() override;
72 void exec() override;
73
74private:
75 void getWSIndexList(std::vector<int> &indices, const Mantid::API::MatrixWorkspace_const_sptr &matrixWorkspace);
76
77 template <class T>
78 static void appendEventListData(const std::vector<T> &events, size_t offset, double *tofs, float *weights,
79 float *errorSquareds, int64_t *pulsetimes);
80
81 void execEvent(Mantid::NeXus::NexusFileIO *nexusFile, const bool uniformSpectra, const std::vector<int> &spec);
83 void setOtherProperties(IAlgorithm *alg, const std::string &propertyName, const std::string &propertyValue,
84 int perioidNum) override;
85 void doExec(const Mantid::API::Workspace_sptr &inputWorkspace, std::shared_ptr<Mantid::NeXus::NexusFileIO> &nexusFile,
86 const bool keepFile = false, boost::optional<size_t> entryNumber = boost::optional<size_t>());
87
93 double m_timeProgInit{0.0};
95 std::unique_ptr<API::Progress> m_progress;
96};
97
98} // namespace DataHandling
99} // namespace Mantid
IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:45
Base MatrixWorkspace Abstract Class.
Base class for algorithms that can only run serially (Parallel::ExecutionMode::MasterOnly) in an MPI ...
DataHandling/SaveNexusProcessed.h.
DataObjects::EventWorkspace_const_sptr m_eventWorkspace
Pointer to the local workspace, cast to EventWorkspace.
const std::string summary() const override
Summary of algorithms purpose.
API::MatrixWorkspace_const_sptr m_inputWorkspace
Pointer to the local workspace.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
int version() const override
Algorithm's version for identification overriding a virtual method.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
std::unique_ptr< API::Progress > m_progress
Progress bar.
Utility method for saving NeXus format of Mantid Workspace This class interfaces to the C Nexus API.
Definition: NexusFileIO.h:38
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
Helper class which provides the Collimation Length for SANS instruments.