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"
29
30#include <cstdarg>
31
32using namespace Mantid::API;
33using namespace Mantid::DataObjects;
34using namespace Mantid::Kernel;
37using namespace Mantid::Geometry;
38
39namespace Mantid::Crystal {
40
41DECLARE_ALGORITHM(SetCrystalLocation)
42
43void SetCrystalLocation::init() {
44 declareProperty(std::make_unique<WorkspaceProperty<EventWorkspace>>("InputWorkspace", "", Direction::Input),
45 "Original event workspace");
46 declareProperty(std::make_unique<WorkspaceProperty<EventWorkspace>>("OutputWorkspace", "", Direction::Output),
47 "Output event workspace with a modified sample position");
48 declareProperty("NewX", 0.0, "New Absolute X position of crystal.");
49 declareProperty("NewY", 0.0, "New Absolute Y position of crystal.");
50 declareProperty("NewZ", 0.0, "New Absolute Z position of crystal.");
51}
52
53// simple algorithm that changes the sample position of the input
54// event workspace.
56 EventWorkspace_sptr events = getProperty("InputWorkspace");
57 EventWorkspace_sptr outEvents = getProperty("OutputWorkspace");
58 const double newX = getProperty("NewX");
59 const double newY = getProperty("NewY");
60 const double newZ = getProperty("NewZ");
61 V3D newSamplePos = V3D(newX, newY, newZ);
62 if (events != outEvents) {
63 outEvents = events->clone();
64 }
65
66 auto &componentInfo = outEvents->mutableComponentInfo();
67 CalibrationHelpers::adjustUpSampleAndSourcePositions(componentInfo.l1(), newSamplePos, componentInfo);
68
69 setProperty("OutputWorkspace", outEvents);
70} // exec
71
72} // namespace Mantid::Crystal
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:547
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
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.
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:35
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:54
@ Output
An output workspace.
Definition Property.h:55