LoadILLPolarizedDiffractionTest.h 32.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once

#include <cxxtest/TestSuite.h>

#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Axis.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidDataHandling/Load.h"
#include "MantidDataHandling/LoadILLPolarizedDiffraction.h"
#include "MantidGeometry/Instrument/ComponentHelper.h"
19
20
#include "MantidGeometry/Instrument/ComponentInfo.h"
#include "MantidGeometry/Instrument/DetectorInfo.h"
21
22
23
24
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/Unit.h"
#include "MantidKernel/V3D.h"
25
#include <tuple>
26
27
28
29
30
31

using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace Mantid::DataHandling;
using namespace Mantid::Geometry;

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
std::tuple<std::string, std::string> commonSetUp() {
  ConfigService::Instance().appendDataSearchSubDir("ILL/D7/");

  auto oldFacility = ConfigService::Instance().getFacility().name();
  ConfigService::Instance().setFacility("ILL");

  auto oldInstrument = ConfigService::Instance().getInstrument().name();
  ConfigService::Instance().setString("default.instrument", "D7");

  return std::make_tuple(oldFacility, oldInstrument);
}

void commonTearDown(const std::string &oldFacility,
                    const std::string &oldInstrument) {
  if (!oldFacility.empty()) {
    ConfigService::Instance().setFacility(oldFacility);
  }
  if (!oldInstrument.empty()) {
    ConfigService::Instance().setString("default.instrument", oldInstrument);
  }
}

54
55
56
57
58
59
60
class LoadILLPolarizedDiffractionTest : public CxxTest::TestSuite {
public:
  // This pair of boilerplate methods prevent the suite being created statically
  // This means the constructor isn't called when running other tests
  static LoadILLPolarizedDiffractionTest *createSuite() {
    return new LoadILLPolarizedDiffractionTest();
  }
61
62
63
  static void destroySuite(LoadILLPolarizedDiffractionTest *suite) {
    delete suite;
  }
64
65

  void setUp() override {
66
    std::tie(m_oldFacility, m_oldInstrument) = commonSetUp();
67
68
  }

69
  void tearDown() override { commonTearDown(m_oldFacility, m_oldInstrument); }
70
71
72
73
74
75
76
77

  void test_Init() {
    LoadILLPolarizedDiffraction alg;
    TS_ASSERT_THROWS_NOTHING(alg.initialize());
    TS_ASSERT(alg.isInitialized());
  }

  void test_D7_monochromatic() {
78
    // Tests monochromatic data loading for D7
79
80
81
82
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())
83
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800"))
Dominik Arominski's avatar
Dominik Arominski committed
84
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
85
86
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
87
88
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", false))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
89
90
91
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

92
    WorkspaceGroup_sptr outputWS = std::shared_ptr<Mantid::API::WorkspaceGroup>(
Dominik Arominski's avatar
Dominik Arominski committed
93
        alg.getProperty("OutputWorkspace"));
94
95
    TS_ASSERT(outputWS)
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 6)
96
97
    do_test_general_features(outputWS, "monochromatic");

98
99
100
101
102
    MatrixWorkspace_sptr workspaceEntry1 =
        std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
            outputWS->getItem(0));
    TS_ASSERT(workspaceEntry1)

103
104
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[1], 3.19, 0.01)
105
106
107
    TS_ASSERT_EQUALS(workspaceEntry1->y(0)[0], 11)
    TS_ASSERT_DELTA(workspaceEntry1->e(0)[0], 3.31, 0.01)

108
109
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[1], 3.19, 0.01)
110
111
112
    TS_ASSERT_EQUALS(workspaceEntry1->y(1)[0], 12)
    TS_ASSERT_DELTA(workspaceEntry1->e(1)[0], 3.46, 0.01)

113
114
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[1], 3.19, 0.01)
115
116
117
    TS_ASSERT_EQUALS(workspaceEntry1->y(130)[0], 4)
    TS_ASSERT_DELTA(workspaceEntry1->e(130)[0], 2.00, 0.01)

118
119
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[1], 3.19, 0.01)
120
121
122
    TS_ASSERT_EQUALS(workspaceEntry1->y(131)[0], 17)
    TS_ASSERT_DELTA(workspaceEntry1->e(131)[0], 4.12, 0.01)

123
124
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[1], 3.19, 0.01)
125
126
127
    TS_ASSERT_EQUALS(workspaceEntry1->y(132)[0], 167943)
    TS_ASSERT_DELTA(workspaceEntry1->e(132)[0], 409.80, 0.01)

128
129
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[1], 3.19, 0.01)
130
131
    TS_ASSERT_EQUALS(workspaceEntry1->y(133)[0], 2042)
    TS_ASSERT_DELTA(workspaceEntry1->e(133)[0], 45.18, 0.01)
132
133
134
  }

  void test_D7_timeOfFlight() {
135
    // Tests loading TOF data for D7
136
137
138
139
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())
140
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "395850"))
Dominik Arominski's avatar
Dominik Arominski committed
141
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
142
143
144
145
146
147
148
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
149
    TS_ASSERT(outputWS->isGroup())
150
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 2)
151
152
    do_test_general_features(outputWS, "TOF");

153
154
155
156
    MatrixWorkspace_sptr workspaceEntry1 =
        std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
            outputWS->getItem(0));
    TS_ASSERT(workspaceEntry1)
157
    TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->unitID(), "TOF")
Dominik Arominski's avatar
Dominik Arominski committed
158
159
    TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->caption(),
                     "Time-of-flight")
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

    TS_ASSERT_DELTA(workspaceEntry1->x(0)[0], 180.00, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[1], 186.64, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(0)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(0)[0], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(0)[511], 3573.04, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[512], 3579.68, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(0)[511], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(0)[511], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(1)[0], 180.00, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[1], 186.64, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(1)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(1)[0], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(1)[511], 3573.04, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[512], 3579.68, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(1)[511], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(1)[511], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(130)[0], 180.00, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[1], 186.64, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(130)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(130)[0], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(130)[365], 2603.60, 0.01)
187
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[366], 2610.24, 0.01)
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
    TS_ASSERT_EQUALS(workspaceEntry1->y(130)[365], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(130)[365], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(131)[0], 180.00, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[1], 186.64, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(131)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(131)[0], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(131)[365], 2603.60, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[366], 2610.24, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(131)[365], 1)
    TS_ASSERT_DELTA(workspaceEntry1->e(131)[365], 1.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(132)[0], 180.00, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[1], 186.64, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(132)[0], 5468)
    TS_ASSERT_DELTA(workspaceEntry1->e(132)[0], 73.94, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(132)[511], 3573.04, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[512], 3579.68, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(132)[511], 5394)
    TS_ASSERT_DELTA(workspaceEntry1->e(132)[511], 73.44, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(133)[0], 180.00, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[1], 186.64, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(133)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(133)[0], 0.00, 0.01)

    TS_ASSERT_DELTA(workspaceEntry1->x(133)[511], 3573.04, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[512], 3579.68, 0.01)
    TS_ASSERT_EQUALS(workspaceEntry1->y(133)[511], 0)
Martyn Gigg's avatar
Martyn Gigg committed
219
    TS_ASSERT_DELTA(workspaceEntry1->e(133)[511], 0.00, 0.01)
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
  void test_D7_timeOfFlight_timechannels() {
    // Tests loading TOF data for D7
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "395850"))
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("TOFUnits", "TimeChannels"))
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
    TS_ASSERT(outputWS->isGroup())
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 2)
    do_test_general_features(outputWS, "TOF");

    MatrixWorkspace_sptr workspaceEntry1 =
        std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
            outputWS->getItem(0));
    TS_ASSERT(workspaceEntry1)
    TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->unitID(), "Label")
    TS_ASSERT_EQUALS(workspaceEntry1->getAxis(0)->unit()->caption(),
                     "Time channel")

    TS_ASSERT_EQUALS(workspaceEntry1->x(0)[0], 0)
    TS_ASSERT_EQUALS(workspaceEntry1->x(0)[1], 1)
    TS_ASSERT_EQUALS(workspaceEntry1->y(0)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(0)[0], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(0)[511], 511)
    TS_ASSERT_EQUALS(workspaceEntry1->x(0)[512], 512)
    TS_ASSERT_EQUALS(workspaceEntry1->y(0)[511], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(0)[511], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(1)[0], 0)
    TS_ASSERT_EQUALS(workspaceEntry1->x(1)[1], 1)
    TS_ASSERT_EQUALS(workspaceEntry1->y(1)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(1)[0], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(1)[511], 511)
    TS_ASSERT_EQUALS(workspaceEntry1->x(1)[512], 512)
    TS_ASSERT_EQUALS(workspaceEntry1->y(1)[511], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(1)[511], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(130)[0], 0)
    TS_ASSERT_EQUALS(workspaceEntry1->x(130)[1], 1)
    TS_ASSERT_EQUALS(workspaceEntry1->y(130)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(130)[0], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(130)[365], 365)
    TS_ASSERT_EQUALS(workspaceEntry1->x(130)[366], 366)
    TS_ASSERT_EQUALS(workspaceEntry1->y(130)[365], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(130)[365], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(131)[0], 0)
    TS_ASSERT_EQUALS(workspaceEntry1->x(131)[1], 1)
    TS_ASSERT_EQUALS(workspaceEntry1->y(131)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(131)[0], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(131)[365], 365)
    TS_ASSERT_EQUALS(workspaceEntry1->x(131)[366], 366)
    TS_ASSERT_EQUALS(workspaceEntry1->y(131)[365], 1)
    TS_ASSERT_DELTA(workspaceEntry1->e(131)[365], 1.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(132)[0], 0)
    TS_ASSERT_EQUALS(workspaceEntry1->x(132)[1], 1)
    TS_ASSERT_EQUALS(workspaceEntry1->y(132)[0], 5468)
    TS_ASSERT_DELTA(workspaceEntry1->e(132)[0], 73.94, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(132)[511], 511)
    TS_ASSERT_EQUALS(workspaceEntry1->x(132)[512], 512)
    TS_ASSERT_EQUALS(workspaceEntry1->y(132)[511], 5394)
    TS_ASSERT_DELTA(workspaceEntry1->e(132)[511], 73.44, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(133)[0], 0)
    TS_ASSERT_EQUALS(workspaceEntry1->x(133)[1], 1)
    TS_ASSERT_EQUALS(workspaceEntry1->y(133)[0], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(133)[0], 0.00, 0.01)

    TS_ASSERT_EQUALS(workspaceEntry1->x(133)[511], 511)
    TS_ASSERT_EQUALS(workspaceEntry1->x(133)[512], 512)
    TS_ASSERT_EQUALS(workspaceEntry1->y(133)[511], 0)
    TS_ASSERT_DELTA(workspaceEntry1->e(133)[511], 0.00, 0.01)
  }

311
312
  void test_D7_multifile_sum() {
    // Tests loading and adding 2 files for D7 with the generic Load on ADS
313
314
315
316
    // This tests indirectly the confidence method

    Load alg;
    alg.initialize();
Dominik Arominski's avatar
Dominik Arominski committed
317
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800+401801"))
318
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
Dominik Arominski's avatar
Dominik Arominski committed
319
320
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
321
322
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", false))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
323
324
325
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

326
327
    WorkspaceGroup_sptr outputWS =
        AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("_outWS");
328
    TS_ASSERT(outputWS)
329
    TS_ASSERT(outputWS->isGroup())
330
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 6)
331
332
    do_test_general_features(outputWS, "monochromatic");

333
    MatrixWorkspace_sptr workspaceEntry1 =
334
        std::static_pointer_cast<Mantid::API::MatrixWorkspace>(
335
336
337
            outputWS->getItem(0));
    TS_ASSERT(workspaceEntry1)

338
339
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[1], 3.19, 0.01)
340
341
342
    TS_ASSERT_EQUALS(workspaceEntry1->y(0)[0], 24)
    TS_ASSERT_DELTA(workspaceEntry1->e(0)[0], 4.89, 0.01)

343
344
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[1], 3.19, 0.01)
345
346
347
    TS_ASSERT_EQUALS(workspaceEntry1->y(1)[0], 19)
    TS_ASSERT_DELTA(workspaceEntry1->e(1)[0], 4.35, 0.01)

348
349
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[1], 3.19, 0.01)
350
351
352
    TS_ASSERT_EQUALS(workspaceEntry1->y(130)[0], 8)
    TS_ASSERT_DELTA(workspaceEntry1->e(130)[0], 2.82, 0.01)

353
354
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[1], 3.19, 0.01)
355
356
357
    TS_ASSERT_EQUALS(workspaceEntry1->y(131)[0], 38)
    TS_ASSERT_DELTA(workspaceEntry1->e(131)[0], 6.16, 0.01)

358
359
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[1], 3.19, 0.01)
360
361
362
    TS_ASSERT_EQUALS(workspaceEntry1->y(132)[0], 335686)
    TS_ASSERT_DELTA(workspaceEntry1->e(132)[0], 579.38, 0.01)

363
364
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[1], 3.19, 0.01)
365
366
    TS_ASSERT_EQUALS(workspaceEntry1->y(133)[0], 4109)
    TS_ASSERT_DELTA(workspaceEntry1->e(133)[0], 64.10, 0.01)
367
368
  }

369
370
371
372
373
374
  void test_D7_multifile_list() {
    // Tests loading 2 files as a list for D7 with the generic Load on ADS
    // This tests indirectly the confidence method

    Load alg;
    alg.initialize();
Dominik Arominski's avatar
Dominik Arominski committed
375
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800,401801"))
376
377
378
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
379
380
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", false))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
381
382
383
384
385
386
387
388
389
390
391
392
393
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

    WorkspaceGroup_sptr outputWS =
        AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("_outWS");
    TS_ASSERT(outputWS)
    TS_ASSERT(outputWS->isGroup())
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 12)
    do_test_general_features(outputWS, "monochromatic");

    MatrixWorkspace_sptr workspaceEntry1 =
        std::static_pointer_cast<Mantid::API::MatrixWorkspace>(
            outputWS->getItem(0));
394
395
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(0)[1], 3.19, 0.01)
396
397
398
    TS_ASSERT_EQUALS(workspaceEntry1->y(0)[0], 11)
    TS_ASSERT_DELTA(workspaceEntry1->e(0)[0], 3.31, 0.01)

399
400
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(1)[1], 3.19, 0.01)
401
402
403
    TS_ASSERT_EQUALS(workspaceEntry1->y(1)[0], 12)
    TS_ASSERT_DELTA(workspaceEntry1->e(1)[0], 3.46, 0.01)

404
405
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(130)[1], 3.19, 0.01)
406
407
408
    TS_ASSERT_EQUALS(workspaceEntry1->y(130)[0], 4)
    TS_ASSERT_DELTA(workspaceEntry1->e(130)[0], 2.00, 0.01)

409
410
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(131)[1], 3.19, 0.01)
411
412
413
    TS_ASSERT_EQUALS(workspaceEntry1->y(131)[0], 17)
    TS_ASSERT_DELTA(workspaceEntry1->e(131)[0], 4.12, 0.01)

414
415
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(132)[1], 3.19, 0.01)
416
417
418
    TS_ASSERT_EQUALS(workspaceEntry1->y(132)[0], 167943)
    TS_ASSERT_DELTA(workspaceEntry1->e(132)[0], 409.80, 0.01)

419
420
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry1->x(133)[1], 3.19, 0.01)
421
422
423
424
425
426
    TS_ASSERT_EQUALS(workspaceEntry1->y(133)[0], 2042)
    TS_ASSERT_DELTA(workspaceEntry1->e(133)[0], 45.18, 0.01)

    MatrixWorkspace_sptr workspaceEntry12 =
        std::static_pointer_cast<Mantid::API::MatrixWorkspace>(
            outputWS->getItem(11));
427
428
    TS_ASSERT_DELTA(workspaceEntry12->x(0)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry12->x(0)[1], 3.19, 0.01)
429
430
431
    TS_ASSERT_EQUALS(workspaceEntry12->y(0)[0], 14)
    TS_ASSERT_DELTA(workspaceEntry12->e(0)[0], 3.74, 0.01)

432
433
    TS_ASSERT_DELTA(workspaceEntry12->x(1)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry12->x(1)[1], 3.19, 0.01)
434
435
436
    TS_ASSERT_EQUALS(workspaceEntry12->y(1)[0], 15)
    TS_ASSERT_DELTA(workspaceEntry12->e(1)[0], 3.87, 0.01)

437
438
    TS_ASSERT_DELTA(workspaceEntry12->x(130)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry12->x(130)[1], 3.19, 0.01)
439
440
441
    TS_ASSERT_EQUALS(workspaceEntry12->y(130)[0], 5)
    TS_ASSERT_DELTA(workspaceEntry12->e(130)[0], 2.23, 0.01)

442
443
    TS_ASSERT_DELTA(workspaceEntry12->x(131)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry12->x(131)[1], 3.19, 0.01)
444
445
446
    TS_ASSERT_EQUALS(workspaceEntry12->y(131)[0], 15)
    TS_ASSERT_DELTA(workspaceEntry12->e(131)[0], 3.87, 0.01)

447
448
    TS_ASSERT_DELTA(workspaceEntry12->x(132)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry12->x(132)[1], 3.19, 0.01)
449
450
451
    TS_ASSERT_EQUALS(workspaceEntry12->y(132)[0], 167220)
    TS_ASSERT_DELTA(workspaceEntry12->e(132)[0], 408.92, 0.01)

452
453
    TS_ASSERT_DELTA(workspaceEntry12->x(133)[0], 3.13, 0.01)
    TS_ASSERT_DELTA(workspaceEntry12->x(133)[1], 3.19, 0.01)
454
455
456
    TS_ASSERT_EQUALS(workspaceEntry12->y(133)[0], 108504)
    TS_ASSERT_DELTA(workspaceEntry12->e(133)[0], 329.39, 0.01)
  }
457

458
459
460
461
462
463
  void test_D7_default_alignment() {
    // Tests default pixel position alignment coming from the IDF file
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())
464
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800"))
465
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
466
467
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
468
469
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", false))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
470
471
472
473
474
475
476
477
478
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
    TS_ASSERT(outputWS->isGroup())
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 6)
    do_test_general_features(outputWS, "monochromatic");

479
480
481
482
483
484
485
    for (auto entry_no = 0; entry_no < outputWS->getNumberOfEntries();
         ++entry_no) {
      MatrixWorkspace_sptr workspaceEntry =
          std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
              outputWS->getItem(entry_no));
      TS_ASSERT(workspaceEntry)

486
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(0) * RAD_2_DEG,
487
                      12.66, 0.01)
488
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(43) * RAD_2_DEG,
489
                      55.45, 0.01)
490
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(44) * RAD_2_DEG,
491
                      58.79, 0.01)
492
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(87) * RAD_2_DEG,
493
                      101.58, 0.01)
494
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(88) * RAD_2_DEG,
495
                      100.78, 0.01)
496
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(131) * RAD_2_DEG,
497
498
                      143.57, 0.01)
    }
499
500
501
502
  }

  void test_D7_nexus_alignment() {
    // Tests pixel position alignment coming from the NeXuS file
503
504
505
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    alg.initialize();
506
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800"))
507
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
508
509
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "Nexus"))
510
511
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", false))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
512
513
514
515
516
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
517
    TS_ASSERT(outputWS->isGroup())
518
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 6)
519
520
    do_test_general_features(outputWS, "monochromatic");

521
522
523
524
525
526
527
    for (auto entry_no = 0; entry_no < outputWS->getNumberOfEntries();
         ++entry_no) {
      MatrixWorkspace_sptr workspaceEntry =
          std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
              outputWS->getItem(entry_no));
      TS_ASSERT(workspaceEntry)

528
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(0) * RAD_2_DEG,
529
                      10.86, 0.01)
530
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(43) * RAD_2_DEG,
531
                      53.81, 0.01)
532
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(44) * RAD_2_DEG,
533
                      57.06, 0.01)
534
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(87) * RAD_2_DEG,
535
                      99.45, 0.01)
536
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(88) * RAD_2_DEG,
537
                      101.38, 0.01)
538
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(131) * RAD_2_DEG,
539
540
                      144.17, 0.01)
    }
541
542
543
  }

  void test_D7_yigfile_alignment() {
544
    // Tests pixel position alignment coming from the YIG calibration IPF file
545
546
547
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    alg.initialize();
548
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800"))
549
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
550
551
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "YIGFile"))
Dominik Arominski's avatar
Dominik Arominski committed
552
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("YIGFilename", "YIG_IPF.xml"))
553
554
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", false))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
555
556
557
558
559
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
560
    TS_ASSERT(outputWS->isGroup())
561
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 6)
562
563
    do_test_general_features(outputWS, "monochromatic");

564
565
566
567
568
569
    for (auto entry_no = 0; entry_no < outputWS->getNumberOfEntries();
         ++entry_no) {
      MatrixWorkspace_sptr workspaceEntry =
          std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
              outputWS->getItem(entry_no));
      TS_ASSERT(workspaceEntry)
570

571
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(0) * RAD_2_DEG,
572
                      10.86, 0.01)
573
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(43) * RAD_2_DEG,
574
                      53.81, 0.01)
575
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(44) * RAD_2_DEG,
576
                      57.06, 0.01)
577
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(87) * RAD_2_DEG,
578
                      99.45, 0.01)
579
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(88) * RAD_2_DEG,
580
                      101.38, 0.01)
581
      TS_ASSERT_DELTA(workspaceEntry->detectorInfo().twoTheta(131) * RAD_2_DEG,
582
583
584
                      144.17, 0.01)
    }
  }
585

586
587
588
589
590
591
592
593
594
595
596
597
598
599
  void test_D7_transpose() {
    // Tests monochromatic data loading for D7
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800"))
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", false))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", true))
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())
600

601
602
603
604
    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
    TS_ASSERT(outputWS->isGroup())
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 6)
605

606
607
608
609
610
611
612
613
614
615
616
    for (auto entry_no = 0; entry_no < outputWS->getNumberOfEntries();
         entry_no++) {
      MatrixWorkspace_sptr workspaceEntry =
          std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
              outputWS->getItem(entry_no));
      TS_ASSERT(workspaceEntry)
      TS_ASSERT_EQUALS(workspaceEntry->getNumberHistograms(), 1)
      TS_ASSERT_EQUALS(workspaceEntry->blocksize(), 134)
      TS_ASSERT(!workspaceEntry->isHistogramData())
      TS_ASSERT(!workspaceEntry->isDistribution())
      TS_ASSERT_EQUALS(workspaceEntry->YUnitLabel(), "Counts")
Dominik Arominski's avatar
Dominik Arominski committed
617
618
      TS_ASSERT_EQUALS(workspaceEntry->getAxis(0)->unit()->caption(),
                       "Spectrum")
619
620
    }
  }
621

622
623
624
625
626
627
628
629
630
631
632
633
634
635
  void test_D7_convert_spectral_axis() {
    // Tests monochromatic data loading for D7
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    TS_ASSERT_THROWS_NOTHING(alg.initialize())
    TS_ASSERT(alg.isInitialized())
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "401800"))
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", true))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())
636

637
638
639
640
    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
    TS_ASSERT(outputWS->isGroup())
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 6)
641

642
643
644
645
646
647
648
649
650
651
652
    for (auto entry_no = 0; entry_no < outputWS->getNumberOfEntries();
         entry_no++) {
      MatrixWorkspace_sptr workspaceEntry =
          std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
              outputWS->getItem(entry_no));
      TS_ASSERT(workspaceEntry)
      TS_ASSERT_EQUALS(workspaceEntry->getNumberHistograms(), 134)
      TS_ASSERT_EQUALS(workspaceEntry->blocksize(), 1)
      TS_ASSERT(workspaceEntry->isHistogramData())
      TS_ASSERT(!workspaceEntry->isDistribution())
      TS_ASSERT_EQUALS(workspaceEntry->YUnitLabel(), "Counts")
653
      TS_ASSERT_EQUALS(workspaceEntry->getAxis(0)->unit()->unitID(),
Dominik Arominski's avatar
Dominik Arominski committed
654
                       "Wavelength")
655
656
657
658
659
660
      TS_ASSERT_DELTA(workspaceEntry->getAxis(1)->getValue(0), 12.66, 0.01)
      TS_ASSERT_DELTA(workspaceEntry->getAxis(1)->getValue(1), 13.45, 0.01)
      TS_ASSERT_DELTA(workspaceEntry->getAxis(1)->getValue(2), 14.66, 0.01)
      TS_ASSERT_DELTA(workspaceEntry->getAxis(1)->getValue(3), 15.45, 0.01)
      TS_ASSERT_DELTA(workspaceEntry->getAxis(1)->getValue(132), 0.00, 0.01)
      TS_ASSERT_DELTA(workspaceEntry->getAxis(1)->getValue(133), 0.00, 0.01)
661
    }
662
663
  }

664
665
666
667
668
  void test_D7_sign_TwoTheta() {
    // Tests pixel position alignment coming from the YIG calibration IPF file
    LoadILLPolarizedDiffraction alg;
    alg.setChild(true);
    alg.initialize();
669
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filename", "394458"))
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
    TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_outWS"))
    TS_ASSERT_THROWS_NOTHING(
        alg.setPropertyValue("PositionCalibration", "None"))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("ConvertToScatteringAngle", true))
    TS_ASSERT_THROWS_NOTHING(alg.setProperty("TransposeMonochromatic", false))
    TS_ASSERT_THROWS_NOTHING(alg.execute())
    TS_ASSERT(alg.isExecuted())

    WorkspaceGroup_sptr outputWS = alg.getProperty("OutputWorkspace");
    TS_ASSERT(outputWS)
    TS_ASSERT(outputWS->isGroup())
    TS_ASSERT_EQUALS(outputWS->getNumberOfEntries(), 1)
    do_test_general_features(outputWS, "monochromatic");

    for (auto entry_no = 0; entry_no < outputWS->getNumberOfEntries();
         ++entry_no) {
      MatrixWorkspace_sptr workspaceEntry =
          std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
              outputWS->getItem(entry_no));
      TS_ASSERT(workspaceEntry)
690
691
692
693
694
695
696
697
      auto axis = workspaceEntry->getAxis(1);
      TS_ASSERT(!axis->isSpectra())
      TS_ASSERT_DELTA(axis->getValue(0), -88.87, 0.01)
      TS_ASSERT_DELTA(axis->getValue(43), -46.08, 0.01)
      TS_ASSERT_DELTA(axis->getValue(44), -42.65, 0.01)
      TS_ASSERT_DELTA(axis->getValue(87), 0.13, 0.01)
      TS_ASSERT_DELTA(axis->getValue(88), -0.80, 0.01)
      TS_ASSERT_DELTA(axis->getValue(131), 41.99, 0.01)
698
699
700
    }
  }

Dominik Arominski's avatar
Dominik Arominski committed
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
  void do_test_general_features(WorkspaceGroup_sptr outputWS,
                                std::string measurementMode) {
    for (auto entry_no = 0; entry_no < outputWS->getNumberOfEntries();
         entry_no++) {
      MatrixWorkspace_sptr workspaceEntry =
          std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
              outputWS->getItem(entry_no));
      TS_ASSERT(workspaceEntry)
      TS_ASSERT_EQUALS(workspaceEntry->getNumberHistograms(), 134)
      TS_ASSERT(workspaceEntry->detectorInfo().isMonitor(132))
      TS_ASSERT(workspaceEntry->detectorInfo().isMonitor(133))
      TS_ASSERT(workspaceEntry->isHistogramData())
      TS_ASSERT(!workspaceEntry->isDistribution())
      TS_ASSERT_EQUALS(workspaceEntry->YUnitLabel(), "Counts")
      if (measurementMode == "monochromatic") {
        TS_ASSERT_EQUALS(workspaceEntry->blocksize(), 1)
717
        TS_ASSERT_EQUALS(workspaceEntry->getAxis(0)->unit()->unitID(),
Dominik Arominski's avatar
Dominik Arominski committed
718
719
                         "Wavelength")
      } else if (measurementMode == "TOF") {
720
        { TS_ASSERT_EQUALS(workspaceEntry->blocksize(), 512) }
721
      }
Dominik Arominski's avatar
Dominik Arominski committed
722
    }
723
  }
Dominik Arominski's avatar
Dominik Arominski committed
724

725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
private:
  const double RAD_2_DEG = 180.0 / M_PI;
  std::string m_oldFacility;
  std::string m_oldInstrument;
};

class LoadILLPolarizedDiffractionTestPerformance : public CxxTest::TestSuite {
public:
  static LoadILLPolarizedDiffractionTestPerformance *createSuite() {
    return new LoadILLPolarizedDiffractionTestPerformance();
  }
  static void destroySuite(LoadILLPolarizedDiffractionTestPerformance *suite) {
    delete suite;
  }

  LoadILLPolarizedDiffractionTestPerformance() {}

  void setUp() override {
743
744
    std::tie(m_oldFacility, m_oldInstrument) = commonSetUp();

745
746
    m_alg.initialize();
    m_alg.setChild(true);
747
    m_alg.setPropertyValue("Filename", "395850");
748
    m_alg.setPropertyValue("OutputWorkspace", "_outWS");
749
    m_alg.setPropertyValue("PositionCalibration", "Nexus");
750
751
  }

752
753
  void tearDown() override { commonTearDown(m_oldFacility, m_oldInstrument); }

754
  void test_performance() {
755
    for (int i = 0; i < 50; ++i) {
756
757
758
759
760
761
      TS_ASSERT_THROWS_NOTHING(m_alg.execute());
    }
  }

private:
  LoadILLPolarizedDiffraction m_alg;
762
763
  std::string m_oldFacility;
  std::string m_oldInstrument;
764
};