Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
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
#include "MantidAlgorithms/CreateTransmissionWorkspaceAuto2.h"
#include "MantidAlgorithms/BoostOptionalToAlgorithmProperty.h"
#include "MantidAPI/WorkspaceUnitValidator.h"
#include "MantidKernel/ListValidator.h"
using namespace Mantid::Kernel;
using namespace Mantid::API;
namespace Mantid {
namespace Algorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(CreateTransmissionWorkspaceAuto2)
//----------------------------------------------------------------------------------------------
/// Sets documentation strings for this algorithm
const std::string CreateTransmissionWorkspaceAuto2::summary() const {
return "Creates a transmission run workspace in Wavelength from input TOF "
"workspaces.";
}
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void CreateTransmissionWorkspaceAuto2::init() {
declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>(
"FirstTransmissionRun", "", Direction::Input,
boost::make_shared<WorkspaceUnitValidator>("TOF")),
"Input workspace.");
declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>(
"SecondTransmissionRun", "", Direction::Input,
PropertyMode::Optional,
boost::make_shared<WorkspaceUnitValidator>("TOF")),
"Second transmission run workspace in TOF.");
// Analysis mode
const std::vector<std::string> analysisMode{"PointDetectorAnalysis",
"MultiDetectorAnalysis"};
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
auto analysisModeValidator =
boost::make_shared<StringListValidator>(analysisMode);
declareProperty("AnalysisMode", analysisMode[0], analysisModeValidator,
"Analysis mode. This property is only used when "
"ProcessingInstructions is not set.",
Direction::Input);
// Processing instructions
declareProperty(make_unique<PropertyWithValue<std::string>>(
"ProcessingInstructions", "", Direction::Input),
"Grouping pattern of workspace indices to yield only the"
" detectors of interest. See GroupDetectors for syntax.");
// Wavelength range
declareProperty("WavelengthMin", Mantid::EMPTY_DBL(),
"Wavelength Min in angstroms", Direction::Input);
declareProperty("WavelengthMax", Mantid::EMPTY_DBL(),
"Wavelength Max in angstroms", Direction::Input);
// Monitor properties
initMonitorProperties();
// Properties for stitching transmission runs
initStitchProperties();
declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>(
"OutputWorkspace", "", Direction::Output),
"Output transmission workspace in wavelength.");
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void CreateTransmissionWorkspaceAuto2::exec() {
IAlgorithm_sptr alg = createChildAlgorithm("CreateTransmissionWorkspace");
alg->initialize();
// First transmission run
MatrixWorkspace_sptr firstWS = getProperty("FirstTransmissionRun");
// Transmission properties
populateTransmissionProperties(alg);
// Instrument
auto instrument = firstWS->getInstrument();
// Other mandatory properties
double wavMin = checkForMandatoryInstrumentDefault<double>(
this, "WavelengthMin", instrument, "LambdaMin");
alg->setProperty("WavelengthMin", wavMin);
double wavMax = checkForMandatoryInstrumentDefault<double>(
this, "WavelengthMax", instrument, "LambdaMax");
alg->setProperty("WavelengthMax", wavMax);
// Monitor properties
populateMonitorProperties(alg, instrument);
// Processing instructions
populateProcessingInstructions(alg, instrument, firstWS);