Mantid
Loading...
Searching...
No Matches
SaveToSNSHistogramNexus.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 "MantidAPI/Progress.h"
12#include "MantidAPI/Sample.h"
13#include "MantidDataHandling/DllConfig.h"
17#include <climits>
18// clang-format off
19#include <nexus/NeXusFile.hpp>
20#include <nexus/NeXusException.hpp>
21// clang-format on
22
23namespace Mantid {
24namespace DataHandling {
35class MANTID_DATAHANDLING_DLL SaveToSNSHistogramNexus final : public API::Algorithm {
36public:
40 const std::string name() const override { return "SaveToSNSHistogramNexus"; };
42 const std::string summary() const override {
43 return "Saves a workspace into SNS histogrammed NeXus format, using an "
44 "original file as the starting point. This only works for "
45 "instruments with Rectangular Detectors.";
46 }
47
49 int version() const override { return 1; };
50 const std::vector<std::string> seeAlso() const override { return {"SaveNexus"}; }
52 const std::string category() const override { return "DataHandling\\Nexus"; }
53
54private:
56 void init() override;
57
59 void exec() override;
60
62 std::string m_outputFilename;
64 std::string m_inputFilename;
67
68 // Map from detector ID to WS index
70
71 // Progress reporting
72 std::unique_ptr<API::Progress> m_progress;
73
75
76 // Stuff needed by the copy_file() functions
77 struct link_to_make {
78 char from[1024]; /* path of directory with link */
79 char name[256]; /* name of link */
80 char to[1024]; /* path of real item */
81 };
82
83 struct link_to_make links_to_make[1024];
85 char current_path[1024];
86
87 NXhandle inId, outId;
88
89 int add_path(const char *path);
90 int remove_path(const char *path);
91
92 int WriteGroup(int is_definition);
93 int WriteAttributes(int is_definition);
94 int copy_file(const char *inFile, int nx_read_access, const char *outFile, int nx_write_access);
95
96 int WriteOutDataOrErrors(const Geometry::RectangularDetector_const_sptr &det, int x_pixel_slab,
97 const char *field_name, const char *errors_field_name, bool doErrors, bool doBoth,
98 int is_definition, const std::string &bank);
99
100 int WriteDataGroup(const std::string &bank, int is_definition);
101
102 //
103 // // For iterating through the HDF file...
104 // void data(char *bank);
105 // herr_t attr_info(hid_t object_in_id, hid_t object_out_id);
106 // void time_of_flight(char *bank);
107 // herr_t file_info_bank(hid_t loc_id, const char *name, void *opdata);
108 // herr_t file_info_inst_bank(hid_t loc_id, const char *name, void
109 // *opdata);
110 // herr_t file_info_inst(hid_t loc_id, const char *name, void *opdata);
111 // herr_t file_info(hid_t loc_id, const char *name, void *opdata);
112 //
113 // // Bunch of variables used by the HDF5 iterating functions
114 // hid_t file_in_id, file_out_id;
115 // hid_t grp_in_id, grp_out_id;
116 // hid_t subgrp_in_id, subgrp_out_id;
117 // hid_t subsubgrp_in_id, subsubgrp_out_id;
118 // hid_t dataset_in_id, dataset_out_id;
119 // hid_t dataspace;
120 // hid_t filespace, memspace; /* file and memory dataspace
121 // identifiers */
122 // herr_t status;
123 // char cbank0[10],cbank[100];
124 // char ibank0[10],ibank[100];
125 // int mpi_size, mpi_rank;
126};
127
128} // namespace DataHandling
129} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
Save a Workspace2D or an EventWorkspace into a NeXus file whose format corresponds to that expected a...
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....
std::string m_outputFilename
The name and path of the output file.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
const std::string summary() const override
Summary of algorithms purpose.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
std::string m_inputFilename
The name and path of the input file.
int version() const override
Algorithm's version for identification overriding a virtual method.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< const RectangularDetector > RectangularDetector_const_sptr
Helper class which provides the Collimation Length for SANS instruments.
std::unordered_map< detid_t, size_t > detid2index_map
Map with key = detector ID, value = workspace index.