29 throw std::runtime_error(
"L0 is negative, must be positive.");
32 const double oldL1 = componentInfo.
l1();
35 if (samplePos != newSampPos) {
39 double scalee = L0 / oldL1;
40 V3D newSourcePos = newSampPos - oldSourceToSampleDir * scalee;
64 const V3D &pos,
const Quat &rot,
const double detWScale,
const double detHtScale,
68 for (
const auto &bankName : bankNames) {
70 std::shared_ptr<const Geometry::RectangularDetector> bank =
71 std::dynamic_pointer_cast<const RectangularDetector>(bank1);
73 Quat relRot = bank->getRelativeRot();
75 Quat newRot = parentRot * rot * relRot;
77 const auto bankComponentIndex = componentInfo.
indexOf(bank->getComponentID());
78 componentInfo.
setRotation(bankComponentIndex, newRot);
81 bank->getParent()->getRotation().rotate(rotatedPos);
83 componentInfo.
setPosition(bankComponentIndex, rotatedPos + bank->getPos());
85 std::vector<double> oldScalex =
pmap->getDouble(bank->getName(), std::string(
"scalex"));
86 std::vector<double> oldScaley =
pmap->getDouble(bank->getName(), std::string(
"scaley"));
89 if (!oldScalex.empty())
90 scalex = oldScalex[0] * detWScale;
94 if (!oldScaley.empty())
95 scaley = oldScaley[0] * detHtScale;
99 pmap->addDouble(bank.get(), std::string(
"scalex"),
scalex);
100 pmap->addDouble(bank.get(), std::string(
"scaley"),
scaley);
102 if (detWScale != 1.0 || detHtScale != 1.0)
std::shared_ptr< const IComponent > getComponentByName(const std::string &cname, int nlevels=0) const override
Returns a pointer to the first component of assembly encountered with the given name.
ComponentInfo : Provides a component centric view on to the instrument.
void setRotation(size_t componentIndex, const Kernel::Quat &newRotation)
size_t indexOf(Geometry::IComponent *id) const
Kernel::V3D sourcePosition() const
void setPosition(size_t componentIndex, const Kernel::V3D &newPosition)
Kernel::V3D samplePosition() const
std::shared_ptr< ParameterMap > getParameterMap() const
Pointer to the NOT const ParameterMap holding the parameters of the modified instrument components.
std::vector< double > getRotation(bool check_normalisation=false, bool throw_on_errors=false) const
returns the rotation matrix defined by this quaternion as an 9-point
MANTID_API_DLL void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, Geometry::IComponent *componentId, const double scaleX, const double scaleY)
Helpers for resizing RectangularDetectors.
CalibrationHelpers : This contains helper methods to move source, sample and detector positions/rotat...
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...
MANTID_CRYSTAL_DLL void adjustBankPositionsAndSizes(const std::vector< std::string > &bankNames, const Geometry::Instrument &newInstrument, const Kernel::V3D &pos, const Kernel::Quat &rot, const double detWScale, const double detHtScale, Geometry::ComponentInfo &componentInfo)
Updates ComponentInfo for newInstrument to reflect the changes in the associated panel information.
Generate a tableworkspace to store the calibration results.
adjust instrument component position and orientation
: detector size scale at y-direction