33using Mantid::Types::Event::TofEvent;
56 const std::tuple<double, double, double> &sigmas) {
107 auto lattice = std::make_unique<OrientedLattice>(6, 6, 6, 90, 90, 90);
108 lattice->setUFromVectors(
V3D(6, 0, 0),
V3D(0, 6, 0));
157 const auto hkl = std::get<0>(descriptor);
158 const auto nEvents = std::get<1>(descriptor);
159 const auto sigmas = std::get<2>(descriptor);
167 const auto detectorId = peak->getDetectorID();
168 const auto tofExact = peak->getTOF();
170 const auto detPos = info.position(info.indexOf(detectorId));
172 const auto xSigma = std::get<0>(sigmas);
173 const auto ySigma = std::get<1>(sigmas);
174 const auto tofSigma = std::get<2>(sigmas);
182 for (
int i = 0; i < nEvents; ++i) {
187 const auto pos =
V3D(detPos[0] + xOffset, detPos[1] + yOffset, detPos[2]);
188 const auto result =
m_detectorSearcher->findNearest(Eigen::Vector3d(pos[0], pos[1], pos[2]));
189 const auto index = std::get<1>(result[0]);
191 el.addEventQuickly(TofEvent(tof));
205 const auto detectorId = peak.getDetectorID();
206 const auto tofExact = peak.getTOF();
208 const auto detPos = info.position(info.indexOf(detectorId));
214 std::uniform_real_distribution<> backgroundXDist(-backgroundDetSize, backgroundDetSize);
215 std::uniform_real_distribution<> backgroundYDist(-backgroundDetSize, backgroundDetSize);
216 std::uniform_real_distribution<> backgroundTOFDist(tofExact - backgroundTOFSize, tofExact + backgroundTOFSize);
218 for (
int i = 0; i < nBackgroundEvents; ++i) {
223 const auto pos =
V3D(detPos[0] + xOffset, detPos[1] + yOffset, detPos[2]);
224 const auto result =
m_detectorSearcher->findNearest(Eigen::Vector3d(pos[0], pos[1], pos[2]));
225 const auto index = std::get<1>(result[0]);
228 el.addEventQuickly(TofEvent(tof));
237 std::vector<Eigen::Vector3d> points;
238 for (
size_t i = 0; i < info.size(); ++i) {
239 const auto pos = info.position(i);
240 points.emplace_back(pos[0], pos[1], pos[2]);
249 rebinAlg->setChild(
true);
250 rebinAlg->initialize();
253 rebinAlg->setProperty(
"PreserveEvents",
false);
254 rebinAlg->setPropertyValue(
"OutputWorkspace",
"__SXD_test_helper_rebin");
256 m_workspace = rebinAlg->getProperty(
"OutputWorkspace");
std::map< DeltaEMode::Type, std::string > index
void setDetectorID(const detid_t detID)
Clear the list of detector IDs, then add one.
Structure describing a single-crystal peak.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
void rebinWorkspace()
Rebin the event workspace to 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.
bool m_outputAsHistogram
whether to output event or histogram data
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.
std::mt19937 m_generator
Random generator for making events.
Mantid::DataObjects::PeaksWorkspace_sptr m_peaksWorkspace
Handle to the peaks workspace.
void createNeighbourSearch()
Create a neighbour search tree for finding nearest neighbours.
std::vector< double > m_rebinParams
rebin parameters
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 createPeaks()
Create peaks at the requested HKL positions.
void setNumPixels(const int numPixels)
Set the total number of peaks to use.
bool m_useBackground
whether to add a background
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.
int m_totalNPixels
total number of pixels in the detector bank
void createInstrument()
Create a dummy instrument.
Mantid::Geometry::Instrument_sptr createTestInstrumentRectangular(int num_banks, int pixels, double pixelSpacing=0.008, double bankDistanceFromSample=5.0, bool addMonitor=false)
Create a test instrument with n panels of rectangular detectors, pixels*pixels in size,...
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::unique_ptr< Peak > Peak_uptr
std::unique_ptr< IPeak > IPeak_uptr
Helper class which provides the Collimation Length for SANS instruments.