17#include "MantidIndexing/IndexInfo.h"
41 const auto &firstEntryName = descriptor.firstEntryNameType().first;
42 if (descriptor.pathExists(
"/" + firstEntryName +
"/data/hmm_xy"))
57 "The input filename of the stored data");
79 double wavelength =
static_cast<double>(data.
getFloat(
"wavelength"));
87 double wavelength_spread =
static_cast<double>(entry.
getFloat(
"instrument/velocity_selector/wavelength_spread"));
88 double wavelength0 = wavelength - wavelength_spread / 2;
89 double wavelength1 = wavelength + wavelength_spread / 2;
92 size_t ny = hmm.
dim1();
93 size_t nx = hmm.
dim2();
94 size_t nHist = ny * nx;
102 std::string instrumentname =
"QUOKKA";
109 instrument->add(samplepos);
110 instrument->markAsSamplePos(samplepos);
112 samplepos->
setPos(0.0, 0.0, 0.0);
116 instrument->add(source);
117 instrument->markAsSource(source);
120 double l1 =
static_cast<double>(entry.
getFloat(
"instrument/parameters/L1"));
121 source->
setPos(0.0, 0.0, -1.0 * l1);
127 double height =
static_cast<double>(entry.
getFloat(
"instrument/detector/active_height"));
128 double width =
static_cast<double>(entry.
getFloat(
"instrument/detector/active_width"));
135 double pixel_height =
height /
static_cast<double>(ny);
136 double pixel_width = width /
static_cast<double>(nx);
138 std::string pixel_height_str = boost::lexical_cast<std::string>(pixel_height / 2);
139 std::string pixel_width_str = boost::lexical_cast<std::string>(pixel_width / 2);
141 std::string pixel_depth_str =
"0.00001";
148 std::string detXML =
"<cuboid id=\"pixel\">"
149 "<left-front-bottom-point x= \"" +
150 pixel_width_str +
"\" y=\"-" + pixel_height_str +
152 "<left-front-top-point x= \"" +
153 pixel_width_str +
"\" y=\"-" + pixel_height_str +
"\" z=\"" + pixel_depth_str +
155 "<left-back-bottom-point x=\"-" +
156 pixel_width_str +
"\" y=\"-" + pixel_height_str +
158 "<right-front-bottom-point x= \"" +
159 pixel_width_str +
"\" y= \"" + pixel_height_str +
165 bank->
initialize(shape,
int(nx), 0, pixel_width,
int(ny), 0, pixel_height, 1,
true,
int(nx));
166 for (
int i = 0; i < static_cast<int>(ny); ++i)
167 for (
int j = 0; j < static_cast<int>(nx); ++j) {
168 instrument->markAsDetector(bank->
getAtXY(j, i).get());
174 auto outputWorkspace =
175 DataObjects::create<DataObjects::Workspace2D>(instrument, Indexing::IndexInfo(nHist), HistogramData::BinEdges(2));
179 outputWorkspace->setYUnitLabel(
"Counts");
181 using namespace HistogramData;
182 const BinEdges binEdges = {wavelength0, wavelength1};
184 auto x =
static_cast<int>(
index % nx);
185 auto y =
static_cast<int>(
index / nx);
186 auto c = hmm(0,
x,
y);
188 Counts yValue = {
static_cast<double>(c)};
189 outputWorkspace->setHistogram(
index, binEdges, yValue);
192 outputWorkspace->setTitle(entry.
getString(
"experiment/title"));
193 setProperty(
"OutputWorkspace", std::move(outputWorkspace));
std::map< DeltaEMode::Type, std::string > index
#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.
@ Load
allowed here which will be passed to the algorithm
A property class for workspaces.
Loads a Quokka data file.
void exec() override
Execution code.
void init() override
Initialisation code.
Component is a wrapper for a Component which can modify some of its parameters, e....
void setPos(double, double, double) override
Set the IComponent position, x, y, z respective to parent (if present)
virtual void setPos(double, double, double)=0
Set the IComponent position, x, y, z respective to parent (if present)
Object Component class, this class brings together the physical attributes of the component to the po...
RectangularDetector is a type of CompAssembly, an assembly of components.
std::shared_ptr< Detector > getAtXY(const int X, const int Y) const
Return a pointer to the component in the assembly at the (X,Y) pixel position.
void initialize(std::shared_ptr< IObject > shape, int xpixels, double xstart, double xstep, int ypixels, double ystart, double ystep, int idstart, bool idfillbyfirst_y, int idstepbyrow, int idstep=1)
Create all the detector pixels of this rectangular detector.
Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.
std::shared_ptr< CSGObject > createShape(Poco::XML::Element *pElem)
Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain t...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
float getFloat(const std::string &name) const
Returns a float.
std::string getString(const std::string &name) const
Returns a string.
Templated class implementation of NXDataSet.
void load(const int blocksize=1, int i=-1, int j=-1, int k=-1, int l=-1) override
Implementation of the virtual NXDataSet::load(...) method.
int dim2() const
Returns the number of elements along the third dimension.
int dim1() const
Returns the number of elements along the second dimension.
Implements NXdata Nexus class.
NXInt openIntData()
Opens data of int type.
Implements NXentry Nexus class.
NXData openNXData(const std::string &name) const
Opens a NXData.
Implements NXroot Nexus class.
NXEntry openFirstEntry()
Open the first NXentry in the file.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Output
An output workspace.