Mantid
Loading...
Searching...
No Matches
SetCrystalLocation.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7/*
8 *
9 * SetCrystalLocation.cpp
10 *
11 * Created on: Dec 12, 2018
12 * Author: Brendan Sullivan
13 */
15
17#include "MantidAPI/Run.h"
18#include "MantidAPI/Sample.h"
30
31#include <cstdarg>
32
33using namespace Mantid::API;
34using namespace Mantid::DataObjects;
35using namespace Mantid::Kernel;
38using namespace Mantid::Geometry;
39
40namespace Mantid::Crystal {
41
42DECLARE_ALGORITHM(SetCrystalLocation)
43
44void SetCrystalLocation::init() {
45 declareProperty(std::make_unique<WorkspaceProperty<EventWorkspace>>("InputWorkspace", "", Direction::Input),
46 "Original event workspace");
47 declareProperty(std::make_unique<WorkspaceProperty<EventWorkspace>>("OutputWorkspace", "", Direction::Output),
48 "Output event workspace with a modified sample position");
49 declareProperty("NewX", 0.0, "New Absolute X position of crystal.");
50 declareProperty("NewY", 0.0, "New Absolute Y position of crystal.");
51 declareProperty("NewZ", 0.0, "New Absolute Z position of crystal.");
52}
53
54// simple algorithm that changes the sample position of the input
55// event workspace.
57 EventWorkspace_sptr events = getProperty("InputWorkspace");
58 EventWorkspace_sptr outEvents = getProperty("OutputWorkspace");
59 const double newX = getProperty("NewX");
60 const double newY = getProperty("NewY");
61 const double newZ = getProperty("NewZ");
62 V3D newSamplePos = V3D(newX, newY, newZ);
63 if (events != outEvents) {
64 outEvents = events->clone();
65 }
66
67 auto &componentInfo = outEvents->mutableComponentInfo();
68 CalibrationHelpers::adjustUpSampleAndSourcePositions(componentInfo.l1(), newSamplePos, componentInfo);
69
70 setProperty("OutputWorkspace", outEvents);
71} // exec
72
73} // namespace Mantid::Crystal
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
A property class for workspaces.
void exec() override
Virtual method - must be overridden by concrete algorithm.
This class contains static utility methods for indexing peaks and finding the UB matrix.
Definition: IndexingUtils.h:32
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
Class for 3D vectors.
Definition: V3D.h:34
MANTID_CRYSTAL_DLL void adjustUpSampleAndSourcePositions(double const L0, const Kernel::V3D &newSampPos, Geometry::ComponentInfo &componentInfo)
Updates the ComponentInfo for the workspace containing newInstrument to reflect the position of the s...
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
@ Input
An input workspace.
Definition: Property.h:53
@ Output
An output workspace.
Definition: Property.h:54