20#include <boost/algorithm/string.hpp>
21#include <boost/math/special_functions/round.hpp>
44 declareParameter(
"DeltaX", 0.0,
"relative shift along X in meter");
45 declareParameter(
"DeltaY", 0.0,
"relative shift along Y in meter");
46 declareParameter(
"DeltaZ", 0.0,
"relative shift along Z in meter");
48 declareParameter(
"RotX", 0.0,
"relative rotation around X in degree");
49 declareParameter(
"RotY", 0.0,
"relative rotation around Y in degree");
50 declareParameter(
"RotZ", 0.0,
"relative rotation around Z in degree");
53 declareParameter(
"DeltaT0", 0.1,
"delta of TOF");
55 declareParameter(
"DeltaSampleX", 0.0,
"relative shift of sample position along X.");
56 declareParameter(
"DeltaSampleY", 0.0,
"relative shift of sample position along Y.");
57 declareParameter(
"DeltaSampleZ", 0.0,
"relative shift of sample position along Z.");
59 declareParameter(
"ScaleX", 1.0,
"Scale of detector along X-direction (i.e., width).");
60 declareParameter(
"ScaleY", 1.0,
"Scale of detector along Y-direction (i.e., height).");
64 const std::vector<double> &tofs) {
70 if (inst->getName().compare(
"CORELLI") == 0 &&
m_cmpt !=
"moderator")
73 if (!boost::algorithm::ends_with(
m_cmpt,
"/sixteenpack"))
74 m_cmpt.append(
"/sixteenpack");
124 bool calibrateT0 = (
m_cmpt ==
"none/sixteenpack") || (
m_cmpt ==
"none");
141 for (
int i = 0; i < pws->getNumberPeaks(); ++i) {
143 const double tof =
m_tofs[i];
155 {{UnitParams::l2, pk.getL2()},
156 {UnitParams::twoTheta, pk.getScattering()},
157 {UnitParams::efixed, pk.getInitialEnergy()}});
158 pk.setWavelength(wl.singleFromTOF(tof + dT0));
160 V3D qv = pk.getQSampleFrame();
161 for (
int j = 0; j < 3; ++j)
162 out[i * 3 + j] = qv[j];
199IPeaksWorkspace_sptr SCDCalibratePanels2ObjFunc::moveInstruentComponentBy(
double deltaX,
double deltaY,
double deltaZ,
200 const std::string &componentName,
206 mv_alg->initialize();
207 mv_alg->setChild(
true);
208 mv_alg->setLogging(LOGCHILDALG);
209 mv_alg->setProperty(
"Workspace", pws);
210 mv_alg->setProperty(
"ComponentName", componentName);
211 mv_alg->setProperty(
"X", deltaX);
212 mv_alg->setProperty(
"Y", deltaY);
213 mv_alg->setProperty(
"Z", deltaZ);
214 mv_alg->setProperty(
"RelativePosition",
true);
215 mv_alg->executeAsChildAlg();
230IPeaksWorkspace_sptr SCDCalibratePanels2ObjFunc::rotateInstrumentComponentBy(
double rotX,
double rotY,
double rotZ,
231 const std::string &componentName,
236 rot_alg->initialize();
237 rot_alg->setChild(
true);
238 rot_alg->setLogging(LOGCHILDALG);
239 rot_alg->setProperty(
"Workspace", pws);
240 rot_alg->setProperty(
"ComponentName", componentName);
241 rot_alg->setProperty(
"X", 1.0);
242 rot_alg->setProperty(
"Y", 0.0);
243 rot_alg->setProperty(
"Z", 0.0);
244 rot_alg->setProperty(
"Angle", rotX);
245 rot_alg->setProperty(
"RelativeRotation",
true);
246 rot_alg->executeAsChildAlg();
248 rot_alg->initialize();
249 rot_alg->setChild(
true);
250 rot_alg->setLogging(LOGCHILDALG);
251 rot_alg->setProperty(
"Workspace", pws);
252 rot_alg->setProperty(
"ComponentName", componentName);
253 rot_alg->setProperty(
"X", 0.0);
254 rot_alg->setProperty(
"Y", 1.0);
255 rot_alg->setProperty(
"Z", 0.0);
256 rot_alg->setProperty(
"Angle", rotY);
257 rot_alg->setProperty(
"RelativeRotation",
true);
258 rot_alg->executeAsChildAlg();
260 rot_alg->initialize();
261 rot_alg->setChild(
true);
262 rot_alg->setLogging(LOGCHILDALG);
263 rot_alg->setProperty(
"Workspace", pws);
264 rot_alg->setProperty(
"ComponentName", componentName);
265 rot_alg->setProperty(
"X", 0.0);
266 rot_alg->setProperty(
"Y", 0.0);
267 rot_alg->setProperty(
"Z", 1.0);
268 rot_alg->setProperty(
"Angle", rotZ);
269 rot_alg->setProperty(
"RelativeRotation",
true);
270 rot_alg->executeAsChildAlg();
276SCDCalibratePanels2ObjFunc::scaleRectagularDetectorSize(
const double &
scalex,
const double &
scaley,
277 const std::string &componentName,
282 std::shared_ptr<const Geometry::RectangularDetector> rectDet =
283 std::dynamic_pointer_cast<const Geometry::RectangularDetector>(comp);
287 auto oldscalex =
pmap.getDouble(rectDet->getName(),
"scalex");
288 auto oldscaley =
pmap.getDouble(rectDet->getName(),
"scaley");
290 if (!oldscalex.empty())
291 relscalex /= oldscalex[0];
292 if (!oldscaley.empty())
293 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
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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
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