/** * Calculate the twoTheta angle from the detector and sample locations. * @return: twoTheta */ double SpecularReflectionAlgorithm::calculateTwoTheta() const { MatrixWorkspace_sptr inWS = this->getProperty("InputWorkspace"); const std::string analysisMode = this->getProperty("AnalysisMode"); Instrument_const_sptr instrument = inWS->getInstrument(); IComponent_const_sptr detector = this->getDetectorComponent(inWS, analysisMode == pointDetectorAnalysis); IComponent_const_sptr sample = this->getSurfaceSampleComponent(instrument); const V3D detSample = detector->getPos() - sample->getPos(); boost::shared_ptr<const ReferenceFrame> refFrame = instrument->getReferenceFrame(); const double upoffset = refFrame->vecPointingUp().scalar_prod(detSample); const double beamoffset = refFrame->vecPointingAlongBeam().scalar_prod(detSample); const double twoTheta = std::atan2(upoffset, beamoffset) * 180 / M_PI; return twoTheta; }