20#include <boost/math/special_functions/round.hpp>
43 declareParameter(
"DeltaX", 0.0,
"relative shift along X in meter");
44 declareParameter(
"DeltaY", 0.0,
"relative shift along Y in meter");
45 declareParameter(
"DeltaZ", 0.0,
"relative shift along Z in meter");
47 declareParameter(
"RotX", 0.0,
"relative rotation around X in degree");
48 declareParameter(
"RotY", 0.0,
"relative rotation around Y in degree");
49 declareParameter(
"RotZ", 0.0,
"relative rotation around Z in degree");
52 declareParameter(
"DeltaT0", 0.1,
"delta of TOF");
54 declareParameter(
"DeltaSampleX", 0.0,
"relative shift of sample position along X.");
55 declareParameter(
"DeltaSampleY", 0.0,
"relative shift of sample position along Y.");
56 declareParameter(
"DeltaSampleZ", 0.0,
"relative shift of sample position along Z.");
58 declareParameter(
"ScaleX", 1.0,
"Scale of detector along X-direction (i.e., width).");
59 declareParameter(
"ScaleY", 1.0,
"Scale of detector along Y-direction (i.e., height).");
63 const std::vector<double> &tofs) {
69 if (inst->getName().compare(
"CORELLI") == 0 &&
m_cmpt !=
"moderator")
72 if (!
m_cmpt.ends_with(
"/sixteenpack"))
73 m_cmpt.append(
"/sixteenpack");
123 bool calibrateT0 = (
m_cmpt ==
"none/sixteenpack") || (
m_cmpt ==
"none");
140 for (
int i = 0; i < pws->getNumberPeaks(); ++i) {
142 const double tof =
m_tofs[i];
154 {{UnitParams::l2, pk.getL2()},
155 {UnitParams::twoTheta, pk.getScattering()},
156 {UnitParams::efixed, pk.getInitialEnergy()}});
157 pk.setWavelength(wl.singleFromTOF(tof + dT0));
159 V3D qv = pk.getQSampleFrame();
160 for (
int j = 0; j < 3; ++j)
161 out[i * 3 + j] = qv[j];
198IPeaksWorkspace_sptr SCDCalibratePanels2ObjFunc::moveInstruentComponentBy(
double deltaX,
double deltaY,
double deltaZ,
199 const std::string &componentName,
204 auto mv_alg = Mantid::API::AlgorithmFactory::Instance().create(
"MoveInstrumentComponent", -1);
205 mv_alg->initialize();
206 mv_alg->setChild(
true);
207 mv_alg->setLogging(LOGCHILDALG);
208 mv_alg->setProperty(
"Workspace", pws);
209 mv_alg->setProperty(
"ComponentName", componentName);
210 mv_alg->setProperty(
"X", deltaX);
211 mv_alg->setProperty(
"Y", deltaY);
212 mv_alg->setProperty(
"Z", deltaZ);
213 mv_alg->setProperty(
"RelativePosition",
true);
214 mv_alg->executeAsChildAlg();
229IPeaksWorkspace_sptr SCDCalibratePanels2ObjFunc::rotateInstrumentComponentBy(
double rotX,
double rotY,
double rotZ,
230 const std::string &componentName,
233 auto rot_alg = Mantid::API::AlgorithmFactory::Instance().create(
"RotateInstrumentComponent", -1);
235 rot_alg->initialize();
236 rot_alg->setChild(
true);
237 rot_alg->setLogging(LOGCHILDALG);
238 rot_alg->setProperty(
"Workspace", pws);
239 rot_alg->setProperty(
"ComponentName", componentName);
240 rot_alg->setProperty(
"X", 1.0);
241 rot_alg->setProperty(
"Y", 0.0);
242 rot_alg->setProperty(
"Z", 0.0);
243 rot_alg->setProperty(
"Angle", rotX);
244 rot_alg->setProperty(
"RelativeRotation",
true);
245 rot_alg->executeAsChildAlg();
247 rot_alg->initialize();
248 rot_alg->setChild(
true);
249 rot_alg->setLogging(LOGCHILDALG);
250 rot_alg->setProperty(
"Workspace", pws);
251 rot_alg->setProperty(
"ComponentName", componentName);
252 rot_alg->setProperty(
"X", 0.0);
253 rot_alg->setProperty(
"Y", 1.0);
254 rot_alg->setProperty(
"Z", 0.0);
255 rot_alg->setProperty(
"Angle", rotY);
256 rot_alg->setProperty(
"RelativeRotation",
true);
257 rot_alg->executeAsChildAlg();
259 rot_alg->initialize();
260 rot_alg->setChild(
true);
261 rot_alg->setLogging(LOGCHILDALG);
262 rot_alg->setProperty(
"Workspace", pws);
263 rot_alg->setProperty(
"ComponentName", componentName);
264 rot_alg->setProperty(
"X", 0.0);
265 rot_alg->setProperty(
"Y", 0.0);
266 rot_alg->setProperty(
"Z", 1.0);
267 rot_alg->setProperty(
"Angle", rotZ);
268 rot_alg->setProperty(
"RelativeRotation",
true);
269 rot_alg->executeAsChildAlg();
275SCDCalibratePanels2ObjFunc::scaleRectagularDetectorSize(
const double &
scalex,
const double &
scaley,
276 const std::string &componentName,
281 std::shared_ptr<const Geometry::RectangularDetector> rectDet =
282 std::dynamic_pointer_cast<const Geometry::RectangularDetector>(comp);
286 auto oldscalex =
pmap.getDouble(rectDet->getName(),
"scalex");
287 auto oldscaley =
pmap.getDouble(rectDet->getName(),
"scaley");
289 if (!oldscalex.empty())
290 relscalex /= oldscalex[0];
291 if (!oldscaley.empty())
292 relscaley /= oldscaley[0];
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
double getParameter(size_t i) const override
Get i-th parameter.
SCDCalibratePanels2ObjFunc : TODO: DESCRIPTION.
Mantid::API::IPeaksWorkspace_sptr m_pws
Mantid::API::IPeaksWorkspace_sptr rotateInstrumentComponentBy(double rotX, double rotY, double rotZ, const std::string &componentName, Mantid::API::IPeaksWorkspace_sptr &pws) const
Rotate the instrument by angle axis.
std::vector< double > m_tofs
void setPeakWorkspace(Mantid::API::IPeaksWorkspace_sptr &pws, const std::string &componentName, const std::vector< double > &tofs)
Mantid::API::IPeaksWorkspace_sptr scaleRectagularDetectorSize(const double &scalex, const double &scaley, const std::string &componentName, Mantid::API::IPeaksWorkspace_sptr &pws) const
std::string m_cmpt
temp workspace holder
void function1D(double *out, const double *xValues, const size_t order) const override
base objective function
Mantid::API::IPeaksWorkspace_sptr moveInstruentComponentBy(double deltaX, double deltaY, double deltaZ, const std::string &componentName, Mantid::API::IPeaksWorkspace_sptr &pws) const
helper functions
Structure describing a single-crystal peak.
double getL1() const override
Return the L1 flight path length (source to sample), in meters.
void setDetectorID(int id)
Set the detector ID of the pixel at the centre of the peak and look up and cache values related to it...
int getDetectorID() const override
Get the ID of the detector at the center of the peak
void setInstrument(const Geometry::Instrument_const_sptr &inst)
Set the instrument (and save the source/sample pos).
The Logger class is in charge of the publishing messages from the framework through various channels.
void initialize(const double &_l1, const int &_emode, const UnitParametersMap ¶ms)
Initialize the unit to perform conversion using singleToTof() and singleFromTof()
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
Kernel::Logger g_log("ExperimentInfo")
static logger object
MANTID_API_DLL void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, Geometry::IComponent *componentId, const double scaleX, const double scaleY)
Helpers for resizing RectangularDetectors.
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
Generate a tableworkspace to store the calibration results.
adjust instrument component position and orientation
: detector size scale at y-direction