Newer
Older
/*WIKI*
Creates a model for a chopper using the given parameters. The parameters are given as a string to allow flexibility for each chopper model having different parameterisation.
The chopper point is an index that can be used for multi-chopper instruments. The indices start from zero, with this being closest to moderator.
Available models with parameter names:
* FermiChopper -
** AngularVelocity - The angular velocity value or log name
** ChopperRadius - The radius, in metres, of the whole chopper
** SlitThickness - The thickness, in metres, of the slit
** SlitRadius - The radius of curvature, in metres, of the slit
** JitterSigma - The FWHH value for the jitter calculation in microseconds
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
** Ei - The Ei for this run as a value or log name
*WIKI*/
#include "MantidDataHandling/CreateChopperModel.h"
#include "MantidAPI/FermiChopperModel.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/MandatoryValidator.h"
namespace Mantid
{
namespace DataHandling
{
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(CreateChopperModel);
using Kernel::Direction;
using API::WorkspaceProperty;
using API::MatrixWorkspace_sptr;
using Kernel::BoundedValidator;
using Kernel::Direction;
using Kernel::ListValidator;
using Kernel::MandatoryValidator;
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string CreateChopperModel::name() const { return "CreateChopperModel";};
/// Algorithm's version for identification. @see Algorithm::version
int CreateChopperModel::version() const { return 1;};
/// Algorithm's category for identification. @see Algorithm::category
const std::string CreateChopperModel::category() const { return "DataHandling";}
//----------------------------------------------------------------------------------------------
/// Sets documentation strings for this algorithm
void CreateChopperModel::initDocs()
{
this->setWikiSummary("Creates a chopper model for a given workspace");
this->setOptionalMessage("Creates a chopper model for a given workspace");
}
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void CreateChopperModel::init()
{
declareProperty(new WorkspaceProperty<>("Workspace","",Direction::InOut), "An workspace to attach the model");
std::vector<std::string> keys(1, "FermiChopperModel");
declareProperty("ModelType", "", boost::make_shared<ListValidator<std::string>>(keys),
"The string identifier for the model", Direction::Input);
declareProperty("Parameters", "", boost::make_shared<MandatoryValidator<std::string>>(),
"The parameters for the model as comma-separated list of name=value pairs");
auto mustBePositive = boost::make_shared<BoundedValidator<int>>();
mustBePositive->setLower(0);
declareProperty("ChopperPoint", 0, mustBePositive, "The index of the chopper point. (Default=0)");
}
//----------------------------------------------------------------------------------------------
/**
* Execute the algorithm.
*/
void CreateChopperModel::exec()
{
const std::string modelType = getProperty("ModelType");
if(modelType != "FermiChopperModel")
{
throw std::invalid_argument("Invalid chopper model type.");
}
MatrixWorkspace_sptr workspace = getProperty("Workspace");
API::ChopperModel *chopper = new API::FermiChopperModel;
chopper->setRun(workspace->run());
chopper->initialize(getProperty("Parameters"));
int index = getProperty("ChopperPoint");
workspace->setChopperModel(chopper, static_cast<size_t>(index));
}
} // namespace DataHandling
} // namespace Mantid