-
Notifications
You must be signed in to change notification settings - Fork 122
/
ConvolutionFitSequential.cpp
633 lines (564 loc) · 23.4 KB
/
ConvolutionFitSequential.cpp
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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
#include "MantidWorkflowAlgorithms/ConvolutionFitSequential.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/Axis.h"
#include "MantidAPI/FunctionDomain1D.h"
#include "MantidAPI/FunctionFactory.h"
#include "MantidAPI/IFunction.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/StringContainsValidator.h"
#include "MantidKernel/VectorHelper.h"
#include <cmath>
namespace {
Mantid::Kernel::Logger g_log("ConvolutionFitSequential");
}
namespace Mantid {
namespace Algorithms {
using namespace API;
using namespace Kernel;
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(ConvolutionFitSequential)
//----------------------------------------------------------------------------------------------
/// Algorithms name for identification. @see Algorithm::name
const std::string ConvolutionFitSequential::name() const {
return "ConvolutionFitSequential";
}
/// Algorithm's version for identification. @see Algorithm::version
int ConvolutionFitSequential::version() const { return 1; }
/// Algorithm's category for identification. @see Algorithm::category
const std::string ConvolutionFitSequential::category() const {
return "Workflow\\MIDAS";
}
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string ConvolutionFitSequential::summary() const {
return "Performs a sequential fit for a convolution workspace";
}
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void ConvolutionFitSequential::init() {
declareProperty(
make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input),
"The input workspace for the fit.");
auto scv = boost::make_shared<StringContainsValidator>();
auto requires = std::vector<std::string>{"Convolution", "Resolution"};
scv->setRequiredStrings(requires);
declareProperty("Function", "", scv,
"The function that describes the parameters of the fit.",
Direction::Input);
std::vector<std::string> backType{"Fixed Flat", "Fit Flat", "Fit Linear"};
declareProperty("BackgroundType", "Fixed Flat",
boost::make_shared<StringListValidator>(backType),
"The Type of background used in the fitting",
Direction::Input);
declareProperty(
"StartX", EMPTY_DBL(), boost::make_shared<MandatoryValidator<double>>(),
"The start of the range for the fit function.", Direction::Input);
declareProperty(
"EndX", EMPTY_DBL(), boost::make_shared<MandatoryValidator<double>>(),
"The end of the range for the fit function.", Direction::Input);
auto boundedV = boost::make_shared<BoundedValidator<int>>();
boundedV->setLower(0);
declareProperty("SpecMin", 0, boundedV, "The first spectrum to be used in "
"the fit. Spectra values can not be "
"negative",
Direction::Input);
declareProperty("SpecMax", 0, boundedV, "The final spectrum to be used in "
"the fit. Spectra values can not be "
"negative",
Direction::Input);
declareProperty("Convolve", true,
"If true, the fit is treated as a convolution workspace.",
Direction::Input);
declareProperty("Minimizer", "Levenberg-Marquardt",
boost::make_shared<MandatoryValidator<std::string>>(),
"Minimizer to use for fitting. Minimizers available are "
"'Levenberg-Marquardt', 'Simplex', 'FABADA',\n"
"'Conjugate gradient (Fletcher-Reeves imp.)', 'Conjugate "
"gradient (Polak-Ribiere imp.)' and 'BFGS'");
declareProperty("MaxIterations", 500, boundedV,
"The maximum number of iterations permitted",
Direction::Input);
declareProperty("PeakRadius", 0,
"A value of the peak radius the peak functions should use. A "
"peak radius defines an interval on the x axis around the "
"centre of the peak where its values are calculated. Values "
"outside the interval are not calculated and assumed zeros."
"Numerically the radius is a whole number of peak widths "
"(FWHM) that fit into the interval on each side from the "
"centre. The default value of 0 means the whole x axis.");
declareProperty(make_unique<WorkspaceProperty<>>("OutputWorkspace", "",
Direction::Output),
"The OutputWorkspace containing the results of the fit.");
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void ConvolutionFitSequential::exec() {
// Initialise variables with properties
MatrixWorkspace_sptr inputWs = getProperty("InputWorkspace");
const std::string function = getProperty("Function");
const std::string backType =
convertBackToShort(getProperty("backgroundType"));
const double startX = getProperty("StartX");
const double endX = getProperty("EndX");
const int specMin = getProperty("SpecMin");
const int specMax = getProperty("Specmax");
const bool convolve = getProperty("Convolve");
const int maxIter = getProperty("MaxIterations");
const std::string minimizer = getProperty("Minimizer");
const int peakRadius = getProperty("PeakRadius");
// Inspect function to obtain fit Type and background
const auto functionValues = findValuesFromFunction(function);
const auto LorentzNum = functionValues[0];
const auto funcName = functionValues[1];
// Check if a delta function is being used
auto delta = false;
std::string usingDelta = "false";
auto pos = function.find("Delta");
if (pos != std::string::npos) {
delta = true;
usingDelta = "true";
}
// Log information to result log
m_log.information("Input files: " + inputWs->getName());
m_log.information("Fit type: Delta=" + usingDelta + "; Lorentzians=" +
LorentzNum);
m_log.information("Background type: " + backType);
// Output workspace name
auto outputWsName = inputWs->getName();
pos = outputWsName.rfind('_');
if (pos != std::string::npos) {
outputWsName = outputWsName.substr(0, pos + 1);
}
outputWsName += "conv_";
if (delta) {
outputWsName += "Delta";
}
if (LorentzNum.compare("0") != 0) {
outputWsName += LorentzNum + "L";
} else {
outputWsName += convertFuncToShort(funcName);
}
outputWsName += backType + "_s";
outputWsName += std::to_string(specMin);
outputWsName += "_to_";
outputWsName += std::to_string(specMax);
// Convert input workspace to get Q axis
const std::string tempFitWsName = "__convfit_fit_ws";
convertInputToElasticQ(inputWs, tempFitWsName);
Progress plotPeakStringProg(this, 0.0, 0.05, specMax - specMin);
// Construct plotpeak string
std::string plotPeakInput;
for (int i = specMin; i < specMax + 1; i++) {
auto nextWs = tempFitWsName + ",i";
nextWs += std::to_string(i);
plotPeakInput += nextWs + ";";
plotPeakStringProg.report("Constructing PlotPeak name");
}
// passWSIndex
auto passIndex = false;
if (funcName.find("Diff") != std::string::npos ||
funcName.find("Stretched") != std::string::npos) {
passIndex = true;
}
// Run PlotPeaksByLogValue
auto plotPeaks = createChildAlgorithm("PlotPeakByLogValue", 0.05, 0.90, true);
plotPeaks->setProperty("Input", plotPeakInput);
plotPeaks->setProperty("OutputWorkspace", outputWsName);
plotPeaks->setProperty("Function", function);
plotPeaks->setProperty("StartX", startX);
plotPeaks->setProperty("EndX", endX);
plotPeaks->setProperty("FitType", "Sequential");
plotPeaks->setProperty("CreateOutput", true);
plotPeaks->setProperty("OutputCompositeMembers", true);
plotPeaks->setProperty("ConvolveMembers", convolve);
plotPeaks->setProperty("MaxIterations", maxIter);
plotPeaks->setProperty("Minimizer", minimizer);
plotPeaks->setProperty("PassWSIndexToFunction", passIndex);
plotPeaks->setProperty("PeakRadius", peakRadius);
plotPeaks->executeAsChildAlg();
ITableWorkspace_sptr outputWs = plotPeaks->getProperty("OutputWorkspace");
// Delete workspaces
Progress deleteProgress(this, 0.90, 0.91, 2);
auto deleter = createChildAlgorithm("DeleteWorkspace", -1.0, -1.0, false);
deleter->setProperty("WorkSpace",
outputWsName + "_NormalisedCovarianceMatrices");
deleter->executeAsChildAlg();
deleteProgress.report("Deleting PlotPeak Output");
deleter->setProperty("WorkSpace", outputWsName + "_Parameters");
deleter->executeAsChildAlg();
deleteProgress.report("Deleting PlotPeak Output");
const auto paramTableName = outputWsName + "_Parameters";
AnalysisDataService::Instance().add(paramTableName, outputWs);
// Construct output workspace
const auto resultWsName = outputWsName + "_Result";
Progress workflowProg(this, 0.91, 0.94, 4);
auto paramNames = std::vector<std::string>();
if (funcName.compare("DeltaFunction") == 0) {
paramNames.emplace_back("Height");
} else {
auto func = FunctionFactory::Instance().createFunction(funcName);
if (delta) {
paramNames.emplace_back("Height");
}
for (size_t i = 0; i < func->nParams(); i++) {
paramNames.push_back(func->parameterName(i));
workflowProg.report("Finding parameters to process");
}
if (funcName.compare("Lorentzian") == 0) {
// remove peak centre
size_t pos = find(paramNames.begin(), paramNames.end(), "PeakCentre") -
paramNames.begin();
paramNames.erase(paramNames.begin() + pos);
paramNames.emplace_back("EISF");
}
}
// Run calcEISF if Delta
if (delta) {
calculateEISF(outputWs);
}
// Construct comma separated list for ProcessIndirectFitParameters
std::string paramNamesList;
const size_t maxNames = paramNames.size();
for (size_t i = 0; i < maxNames; i++) {
paramNamesList += paramNames.at(i);
if (i != (maxNames - 1)) {
paramNamesList += ",";
}
workflowProg.report("Constructing indirectFitParams input");
}
// Run ProcessIndirectFitParameters
auto pifp =
createChildAlgorithm("ProcessIndirectFitParameters", 0.94, 0.96, true);
pifp->setProperty("InputWorkspace", outputWs);
pifp->setProperty("ColumnX", "axis-1");
pifp->setProperty("XAxisUnit", "MomentumTransfer");
pifp->setProperty("ParameterNames", paramNamesList);
pifp->setProperty("OutputWorkspace", resultWsName);
pifp->executeAsChildAlg();
MatrixWorkspace_sptr resultWs = pifp->getProperty("OutputWorkspace");
AnalysisDataService::Instance().addOrReplace(resultWsName, resultWs);
// Handle sample logs
auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false);
logCopier->setProperty("InputWorkspace", inputWs);
logCopier->setProperty("OutputWorkspace", resultWs);
logCopier->executeAsChildAlg();
resultWs = logCopier->getProperty("OutputWorkspace");
// Create Sample Log
auto sampleLogStrings = std::map<std::string, std::string>();
sampleLogStrings["sample_filename"] = inputWs->getName();
sampleLogStrings["convolve_members"] = (convolve == 1) ? "true" : "false";
sampleLogStrings["fit_program"] = "ConvFit";
sampleLogStrings["background"] = backType;
sampleLogStrings["delta_function"] = usingDelta;
auto sampleLogNumeric = std::map<std::string, std::string>();
sampleLogNumeric["lorentzians"] =
boost::lexical_cast<std::string>(LorentzNum);
Progress logAdderProg(this, 0.96, 0.97, 6);
// Add String Logs
auto logAdder = createChildAlgorithm("AddSampleLog", -1.0, -1.0, false);
for (auto &sampleLogString : sampleLogStrings) {
logAdder->setProperty("Workspace", resultWs);
logAdder->setProperty("LogName", sampleLogString.first);
logAdder->setProperty("LogText", sampleLogString.second);
logAdder->setProperty("LogType", "String");
logAdder->executeAsChildAlg();
logAdderProg.report("Add text logs");
}
// Add Numeric Logs
for (auto &logItem : sampleLogNumeric) {
logAdder->setProperty("Workspace", resultWs);
logAdder->setProperty("LogName", logItem.first);
logAdder->setProperty("LogText", logItem.second);
logAdder->setProperty("LogType", "Number");
logAdder->executeAsChildAlg();
logAdderProg.report("Adding Numerical logs");
}
// Copy Logs to GroupWorkspace
logCopier = createChildAlgorithm("CopyLogs", 0.97, 0.98, false);
logCopier->setProperty("InputWorkspace", resultWs);
std::string groupName = outputWsName + "_Workspaces";
logCopier->setProperty("OutputWorkspace", groupName);
logCopier->executeAsChildAlg();
// Rename Workspaces in group
WorkspaceGroup_sptr groupWs =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(outputWsName +
"_Workspaces");
const auto groupWsNames = groupWs->getNames();
auto renamer = createChildAlgorithm("RenameWorkspace", -1.0, -1.0, false);
Progress renamerProg(this, 0.98, 1.0, specMax + 1);
for (int i = specMin; i < specMax + 1; i++) {
renamer->setProperty("InputWorkspace", groupWsNames.at(i - specMin));
auto outName = outputWsName + "_";
outName += std::to_string(i);
outName += "_Workspace";
renamer->setProperty("OutputWorkspace", outName);
renamer->executeAsChildAlg();
renamerProg.report("Renaming group workspaces");
}
setProperty("OutputWorkspace", resultWs);
}
/**
* Check function to establish if it is for one lorentzian or Two
* @param subFunction The unchecked substring of the function
* @return true if the function is two lorentzian false if one lorentzian
*/
bool ConvolutionFitSequential::checkForTwoLorentz(
const std::string &subFunction) {
auto pos = subFunction.rfind("Lorentzian");
return pos != std::string::npos;
}
/**
* Finds specific values embedded in the function supplied to the algorithm
* @param function The full function string
* @return all values of interest from the function (0 - fitType, 1 -
* functionName)
*/
std::vector<std::string>
ConvolutionFitSequential::findValuesFromFunction(const std::string &function) {
std::vector<std::string> result;
std::string fitType;
std::string functionName;
auto startPos = function.rfind("name=");
if (startPos != std::string::npos) {
fitType = function.substr(startPos, function.size());
auto nextPos = fitType.find_first_of(',');
fitType = fitType.substr(5, nextPos - 5);
functionName = fitType;
if (fitType.compare("Lorentzian") == 0) {
std::string newSub = function.substr(0, startPos);
bool isTwoL = checkForTwoLorentz(newSub);
if (isTwoL) {
fitType = "2";
} else {
fitType = "1";
}
} else {
fitType = "0";
}
result.push_back(fitType);
}
result.push_back(functionName);
return result;
}
/**
* Searchs for a given fit parameter within the a vector of columnNames
* @param suffix - The string to search for within the columnName
* @param columns - A vector of column names to be searched through
* @return A vector of all the column names that contained the given suffix
* string
*/
std::vector<std::string> ConvolutionFitSequential::searchForFitParams(
const std::string &suffix, const std::vector<std::string> &columns) {
auto fitParams = std::vector<std::string>();
const size_t totalColumns = columns.size();
for (size_t i = 0; i < totalColumns; i++) {
auto pos = columns.at(i).rfind(suffix);
if (pos != std::string::npos) {
auto endCheck = pos + suffix.size();
if (endCheck == columns.at(i).size()) {
fitParams.push_back(columns.at(i));
}
}
}
return fitParams;
}
/**
* Squares all the values inside a vector of type double
* @param target - The vector to be squared
* @return The vector after being squared
*/
std::vector<double>
ConvolutionFitSequential::squareVector(std::vector<double> target) {
std::transform(target.begin(), target.end(), target.begin(),
VectorHelper::Squares<double>());
return target;
}
/**
* Creates a vector of type double using the values of another vector
* @param original - The original vector to be cloned
* @return A clone of the original vector
*/
std::vector<double>
ConvolutionFitSequential::cloneVector(const std::vector<double> &original) {
return std::vector<double>(original.begin(), original.end());
}
/**
* Converts the input workspaces to spectrum axis to ElasticQ and adds it to the
* ADS to be used by PlotPeakBylogValue
* @param inputWs - The MatrixWorkspace to be converted
* @param wsName - The desired name of the output workspace
*/
void ConvolutionFitSequential::convertInputToElasticQ(
API::MatrixWorkspace_sptr &inputWs, const std::string &wsName) {
auto axis = inputWs->getAxis(1);
if (axis->isSpectra()) {
auto convSpec = createChildAlgorithm("ConvertSpectrumAxis");
// Store in ADS to allow use by PlotPeakByLogValue
convSpec->setAlwaysStoreInADS(true);
convSpec->setProperty("InputWorkSpace", inputWs);
convSpec->setProperty("OutputWorkSpace", wsName);
convSpec->setProperty("Target", "ElasticQ");
convSpec->setProperty("EMode", "Indirect");
convSpec->executeAsChildAlg();
} else if (axis->isNumeric()) {
// Check that units are Momentum Transfer
if (axis->unit()->unitID() != "MomentumTransfer") {
throw std::runtime_error("Input must have axis values of Q");
}
auto cloneWs = createChildAlgorithm("CloneWorkspace");
// Store in ADS to allow use by PlotPeakByLogValue
cloneWs->setAlwaysStoreInADS(true);
cloneWs->setProperty("InputWorkspace", inputWs);
cloneWs->setProperty("OutputWorkspace", wsName);
cloneWs->executeAsChildAlg();
} else {
throw std::runtime_error(
"Input workspace must have either spectra or numeric axis.");
}
}
/**
* Calculates the EISF if the fit includes a Delta function
* @param tableWs - The TableWorkspace to append the EISF calculation to
*/
void ConvolutionFitSequential::calculateEISF(
API::ITableWorkspace_sptr &tableWs) {
// Get height data from parameter table
const auto columns = tableWs->getColumnNames();
const auto height = searchForFitParams("Height", columns).at(0);
const auto heightErr = searchForFitParams("Height_Err", columns).at(0);
auto heightY = tableWs->getColumn(height)->numeric_fill<>();
auto heightE = tableWs->getColumn(heightErr)->numeric_fill<>();
// Get amplitude column names
const auto ampNames = searchForFitParams("Amplitude", columns);
const auto ampErrorNames = searchForFitParams("Amplitude_Err", columns);
// For each lorentzian, calculate EISF
size_t maxSize = ampNames.size();
if (ampErrorNames.size() > maxSize) {
maxSize = ampErrorNames.size();
}
for (size_t i = 0; i < maxSize; i++) {
// Get amplitude from column in table workspace
const auto ampName = ampNames.at(i);
auto ampY = tableWs->getColumn(ampName)->numeric_fill<>();
const auto ampErrorName = ampErrorNames.at(i);
auto ampErr = tableWs->getColumn(ampErrorName)->numeric_fill<>();
// Calculate EISF and EISF error
// total = heightY + ampY
auto total = cloneVector(heightY);
std::transform(total.begin(), total.end(), ampY.begin(), total.begin(),
std::plus<double>());
// eisfY = heightY / total
auto eisfY = cloneVector(heightY);
std::transform(eisfY.begin(), eisfY.end(), total.begin(), eisfY.begin(),
std::divides<double>());
// heightE squared
auto heightESq = cloneVector(heightE);
heightESq = squareVector(heightESq);
// ampErr squared
auto ampErrSq = cloneVector(ampErr);
ampErrSq = squareVector(ampErrSq);
// totalErr = heightE squared + ampErr squared
auto totalErr = cloneVector(heightESq);
std::transform(totalErr.begin(), totalErr.end(), ampErrSq.begin(),
totalErr.begin(), std::plus<double>());
// heightY squared
auto heightYSq = cloneVector(heightY);
heightYSq = squareVector(heightYSq);
// total Squared
auto totalSq = cloneVector(total);
totalSq = squareVector(totalSq);
// errOverTotalSq = totalErr / total squared
auto errOverTotalSq = cloneVector(totalErr);
std::transform(errOverTotalSq.begin(), errOverTotalSq.end(),
totalSq.begin(), errOverTotalSq.begin(),
std::divides<double>());
// heightESqOverYSq = heightESq / heightYSq
auto heightESqOverYSq = cloneVector(heightESq);
std::transform(heightESqOverYSq.begin(), heightESqOverYSq.end(),
heightYSq.begin(), heightESqOverYSq.begin(),
std::divides<double>());
// sqrtESqOverYSq = squareRoot( heightESqOverYSq )
auto sqrtESqOverYSq = cloneVector(heightESqOverYSq);
std::transform(sqrtESqOverYSq.begin(), sqrtESqOverYSq.end(),
sqrtESqOverYSq.begin(),
static_cast<double (*)(double)>(sqrt));
// eisfYSumRoot = eisfY * sqrtESqOverYSq
auto eisfYSumRoot = cloneVector(eisfY);
std::transform(eisfYSumRoot.begin(), eisfYSumRoot.end(),
sqrtESqOverYSq.begin(), eisfYSumRoot.begin(),
std::multiplies<double>());
// eisfErr = eisfYSumRoot + errOverTotalSq
auto eisfErr = cloneVector(eisfYSumRoot);
std::transform(eisfErr.begin(), eisfErr.end(), errOverTotalSq.begin(),
eisfErr.begin(), std::plus<double>());
// Append the calculated values to the table workspace
auto columnName =
ampName.substr(0, (ampName.size() - std::string("Amplitude").size()));
columnName += "EISF";
auto errorColumnName = ampErrorName.substr(
0, (ampName.size() - std::string("Amplitude_Err").size()));
errorColumnName += "EISF_Err";
tableWs->addColumn("double", columnName);
tableWs->addColumn("double", errorColumnName);
size_t maxEisf = eisfY.size();
if (eisfErr.size() > maxEisf) {
maxEisf = eisfErr.size();
}
Column_sptr col = tableWs->getColumn(columnName);
Column_sptr errCol = tableWs->getColumn(errorColumnName);
for (size_t j = 0; j < maxEisf; j++) {
col->cell<double>(j) = eisfY.at(j);
errCol->cell<double>(j) = eisfErr.at(j);
}
}
}
/**
* Converts the user input for background into short hand for use in the
* workspace naming
* @param original - The original user input to the function
* @return The short hand of the users input
*/
std::string
ConvolutionFitSequential::convertBackToShort(const std::string &original) {
auto result = original.substr(0, 3);
const auto pos = original.find(' ');
if (pos != std::string::npos) {
result += original.at(pos + 1);
}
return result;
}
/**
* Converts the user input for function into short hand for use in the workspace
* naming
* @param original - The original user input to the function
* @return The short hand of the users input
*/
std::string
ConvolutionFitSequential::convertFuncToShort(const std::string &original) {
std::string result;
if (original.compare("DeltaFunction") != 0) {
if (original.at(0) == 'E') {
result += "E";
} else if (original.at(0) == 'I') {
result += "I";
} else {
return "SFT";
}
const auto pos = original.find("Circle");
if (pos != std::string::npos) {
result += "DC";
} else {
result += "DS";
}
}
return result;
}
} // namespace Algorithms
} // namespace Mantid