-
Notifications
You must be signed in to change notification settings - Fork 122
/
SetCrystalLocation.cpp
80 lines (68 loc) · 2.73 KB
/
SetCrystalLocation.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
// 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 +
/*
*
* SetCrystalLocation.cpp
*
* Created on: Dec 12, 2018
* Author: Brendan Sullivan
*/
#include "MantidCrystal/SetCrystalLocation.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/Sample.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidCrystal/CalibrationHelpers.h"
#include "MantidCrystal/PeakHKLErrors.h"
#include "MantidCrystal/SCDCalibratePanels.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidGeometry/Crystal/IPeak.h"
#include "MantidGeometry/Crystal/IndexingUtils.h"
#include "MantidGeometry/Instrument/ComponentInfo.h"
#include "MantidGeometry/Instrument/Goniometer.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/EnabledWhenProperty.h"
#include <cstdarg>
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Kernel;
using Mantid::Geometry::IndexingUtils;
using Mantid::Geometry::Instrument_const_sptr;
using namespace Mantid::Geometry;
namespace Mantid {
namespace Crystal {
DECLARE_ALGORITHM(SetCrystalLocation)
void SetCrystalLocation::init() {
declareProperty(std::make_unique<WorkspaceProperty<EventWorkspace>>(
"InputWorkspace", "", Direction::Input),
"Original event workspace");
declareProperty(std::make_unique<WorkspaceProperty<EventWorkspace>>(
"OutputWorkspace", "", Direction::Output),
"Output event workspace with a modified sample position");
declareProperty("NewX", 0.0, "New Absolute X position of crystal.");
declareProperty("NewY", 0.0, "New Absolute Y position of crystal.");
declareProperty("NewZ", 0.0, "New Absolute Z position of crystal.");
}
// simple algorithm that changes the sample position of the input
// event workspace.
void SetCrystalLocation::exec() {
EventWorkspace_sptr events = getProperty("InputWorkspace");
EventWorkspace_sptr outEvents = getProperty("OutputWorkspace");
const double newX = getProperty("NewX");
const double newY = getProperty("NewY");
const double newZ = getProperty("NewZ");
V3D newSamplePos = V3D(newX, newY, newZ);
if (events != outEvents) {
outEvents = events->clone();
}
auto &componentInfo = outEvents->mutableComponentInfo();
CalibrationHelpers::adjustUpSampleAndSourcePositions(
componentInfo.l1(), newSamplePos, componentInfo);
setProperty("OutputWorkspace", outEvents);
} // exec
} // namespace Crystal
} // namespace Mantid