Mantid
Loading...
Searching...
No Matches
SingleCrystalDiffractionTestHelper.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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
15
16#include <random>
17#include <tuple>
18
19namespace Mantid {
20namespace SingleCrystalDiffractionTestHelper {
21
23
24public:
26
28 void setNumPixels(const int numPixels);
32 void setRebinParameters(const std::vector<double> &rebinParams) { m_rebinParams = rebinParams; }
33 void addBackground(const bool useBackground) { m_useBackground = useBackground; }
35 void setBackgroundParameters(const int nEvents, const double detRange, const double tofRange) {
36 m_backgroundParameters = std::make_tuple(nEvents, detRange, tofRange);
37 }
39 void setRandomSeed(const int seed) { m_generator.seed(seed); }
41 void addPeakByHKL(const Mantid::Kernel::V3D &hkl, const int numEvents,
42 const std::tuple<double, double, double> &sigmas);
44 std::tuple<Mantid::API::MatrixWorkspace_sptr, Mantid::DataObjects::PeaksWorkspace_sptr> build();
45
46private:
47 using HKLPeakDescriptor = std::tuple<Mantid::Kernel::V3D, int, std::tuple<double, double, double>>;
48
50 void createInstrument();
58 void createPeaks();
60 void createPeak(const HKLPeakDescriptor &descriptor);
62 void createBackground(const int peakIndex);
64 void rebinWorkspace();
65
67 std::unique_ptr<Mantid::Kernel::NearestNeighbours<3>> m_detectorSearcher;
69 std::vector<HKLPeakDescriptor> m_peakDescriptors;
78
79 // Instance variables for builder settings
80
90 std::vector<double> m_rebinParams;
92 std::tuple<int, double, double> m_backgroundParameters;
93
94 // Other instance varianbles
95
97 std::mt19937 m_generator;
98};
99} // namespace SingleCrystalDiffractionTestHelper
100} // namespace Mantid
Class for 3D vectors.
Definition: V3D.h:34
void rebinWorkspace()
Rebin the event workspace to a histogram workspace.
void outputAsHistogram(const bool outputAsHistogram)
Set whether to create an event workspace or a histogram workspace.
Mantid::API::MatrixWorkspace_sptr m_workspace
Handle to the final output workspace (event OR histogram)
std::tuple< Mantid::API::MatrixWorkspace_sptr, Mantid::DataObjects::PeaksWorkspace_sptr > build()
Make a tuple of event workspace and peaks workspace.
std::tuple< int, double, double > m_backgroundParameters
background parameters
std::unique_ptr< Mantid::Kernel::NearestNeighbours< 3 > > m_detectorSearcher
Nearest neighbour search tree for detectors.
void createBackground(const int peakIndex)
Create a flat background for the workspace.
void createEventWorkspace()
Create an empty event workspace with the instrument attached.
int m_numPixels
number of pixels along a single axis on the detector bank
void addPeakByHKL(const Mantid::Kernel::V3D &hkl, const int numEvents, const std::tuple< double, double, double > &sigmas)
Add a HKL peak to the diffraction dataset.
void setBackgroundParameters(const int nEvents, const double detRange, const double tofRange)
Set the parameters for the uniform background.
Mantid::DataObjects::PeaksWorkspace_sptr m_peaksWorkspace
Handle to the peaks workspace.
void createNeighbourSearch()
Create a neighbour search tree for finding nearest neighbours.
std::vector< HKLPeakDescriptor > m_peakDescriptors
List of peak descriptors for creating peaks.
Mantid::DataObjects::EventWorkspace_sptr m_eventWorkspace
Handle to the event workspace.
std::tuple< Mantid::Kernel::V3D, int, std::tuple< double, double, double > > HKLPeakDescriptor
void setNumPixels(const int numPixels)
Set the total number of peaks to use.
void setRandomSeed(const int seed)
Set the random seed for generating events.
void createPeaksWorkspace()
Create a peaks workspace with the request HKL peaks.
void createPeak(const HKLPeakDescriptor &descriptor)
Create a single HKL peak in the event workspace.
Mantid::Geometry::Instrument_sptr m_instrument
Handle to the instrument object.
void setRebinParameters(const std::vector< double > &rebinParams)
Set the rebin parameters to use.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::size_t numEvents(::NeXus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix, const NexusHDF5Descriptor &descriptor)
Get the number of events in the currently opened group.
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.