Mantid
Loading...
Searching...
No Matches
MuonWorkspaceCreationHelper.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
13
17
19
20// Create y-values for a fake muon dataset.
23 yDataAsymmetry(const double amp, const double phi);
24 double operator()(const double t, size_t spec);
25
26private:
27 double m_amp; // Amplitude of the oscillations
28 double m_phi; // Phase of the sinusoid
29 const double m_omega = 5.0; // Frequency of the oscillations
30 const double tau = Mantid::PhysicalConstants::MuonLifetime * 1e6; // Muon life time in microseconds
31};
32
33// Generate y-values which increment by 1 each time the function is called
36 double operator()(const double t, size_t spec);
37
38private:
40};
41
42// Errors
43struct eData {
44 double operator()(const double, size_t);
45};
46
58template <typename Function = yDataAsymmetry>
60 Function dataGenerator = yDataAsymmetry()) {
62 dataGenerator, static_cast<int>(nspec), 0.0, 1.0, (1.0 / static_cast<double>(maxt)), true, eData());
63
64 for (auto g = 0u; g < nspec; ++g) {
65 auto &spec = ws->getSpectrum(g);
66 spec.addDetectorID(g + 1);
67 spec.setSpectrumNo(g + 1);
68 }
69 // Add number of good frames (required for Asymmetry calculation)
70 ws->mutableRun().addProperty("goodfrm", 10);
71 // Add instrument and run number
72 std::shared_ptr<Mantid::Geometry::Instrument> inst1 = std::make_shared<Mantid::Geometry::Instrument>();
73 inst1->setName("EMU");
74 ws->setInstrument(inst1);
75 ws->mutableRun().addProperty("run_number", 12345);
76
77 return ws;
78}
79
85Mantid::API::MatrixWorkspace_sptr createCountsWorkspace(size_t nspec, size_t maxt, double seed,
86 size_t detectorIDseed = 1);
87
88Mantid::API::MatrixWorkspace_sptr createCountsWorkspace(size_t nspec, size_t maxt, double seed, size_t detectorIDseed,
89 bool hist, double xStart, double xEnd);
90
96Mantid::API::WorkspaceGroup_sptr createMultiPeriodWorkspaceGroup(const int &nPeriods, size_t nspec, size_t maxt,
97 const std::string &wsGroupName);
98
99Mantid::API::WorkspaceGroup_sptr createMultiPeriodAsymmetryData(const int &nPeriods, size_t nspec, size_t maxt,
100 const std::string &wsGroupName);
101
106Mantid::API::ITableWorkspace_sptr createDeadTimeTable(const size_t &nspec, std::vector<double> &deadTimes);
107
111Mantid::API::ITableWorkspace_sptr createTimeZeroTable(const size_t &numSpec, const std::vector<double> &timeZeros);
112
113// Creates a single - point workspace with instrument and runNumber set.
114Mantid::API::MatrixWorkspace_sptr createWorkspaceWithInstrumentandRun(const std::string &instrName, int runNumber,
115 size_t nSpectra = 1);
116
117// Creates a grouped workspace containing multiple workspaces with multiple
118// spectra, the detector IDs are consequtive across the spectra, starting from 1
120 size_t maxt,
121 const std::string &wsGroupName);
122
123} // namespace MuonWorkspaceCreationHelper
int nSpectra
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
static constexpr double MuonLifetime
Muon lifetime.
Mantid::API::WorkspaceGroup_sptr createWorkspaceGroupConsecutiveDetectorIDs(const int &nWorkspaces, size_t nspec, size_t maxt, const std::string &wsGroupName)
Creates a grouped workspace containing multiple workspaces with multiple spectra, the detector IDs ar...
Mantid::API::ITableWorkspace_sptr createTimeZeroTable(const size_t &numSpec, const std::vector< double > &timeZeros)
Create a simple time zero TableWorkspace with one column (time zero)
Mantid::API::WorkspaceGroup_sptr createMultiPeriodAsymmetryData(const int &nPeriods, size_t nspec, size_t maxt, const std::string &wsGroupName)
Mantid::API::MatrixWorkspace_sptr createCountsWorkspace(size_t nspec, size_t maxt, double seed, size_t detectorIDseed=1)
Create a matrix workspace appropriate for Group Counts.
Mantid::API::WorkspaceGroup_sptr createMultiPeriodWorkspaceGroup(const int &nPeriods, size_t nspec, size_t maxt, const std::string &wsGroupName)
Create a WorkspaceGroup and add to the ADS, populate with MatrixWorkspaces simulating periods as used...
Mantid::API::MatrixWorkspace_sptr createAsymmetryWorkspace(std::size_t nspec, std::size_t maxt, Function dataGenerator=yDataAsymmetry())
Create a matrix workspace appropriate for Group Asymmetry.
Mantid::API::ITableWorkspace_sptr createDeadTimeTable(const size_t &nspec, std::vector< double > &deadTimes)
Create a simple dead time TableWorkspace with two columns (spectrum number and dead time).
Mantid::API::MatrixWorkspace_sptr createWorkspaceWithInstrumentandRun(const std::string &instrName, int runNumber, size_t nSpectra=1)
Creates a single-point workspace with instrument and runNumber set.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceFromFunction(fT yFunc, int nSpec, double x0, double x1, double dx, bool isHist=false, gT eFunc=ReturnOne())
Creates a 2D workspace from taking the function values from the input function.
double operator()(const double t, size_t spec)