void Box::create(Vector3 origin, float length, float depth, float width) { this->center = origin; this->sizeX = length; this->sizeY = depth; this->sizeZ = width; Vector3 V0(origin.x()-(length/2), origin.y()-(depth/2), origin.z()-(width/2)); Vector3 V1(origin.x()+(length/2), origin.y()-(depth/2), origin.z()-(width/2)); Vector3 V2(origin.x()+(length/2), origin.y()+(depth/2), origin.z()-(width/2)); Vector3 V3(origin.x()-(length/2), origin.y()+(depth/2), origin.z()-(width/2)); Vector3 V4(origin.x()-(length/2), origin.y()-(depth/2), origin.z()+(width/2)); Vector3 V5(origin.x()+(length/2), origin.y()-(depth/2), origin.z()+(width/2)); Vector3 V6(origin.x()+(length/2), origin.y()+(depth/2), origin.z()+(width/2)); Vector3 V7(origin.x()-(length/2), origin.y()+(depth/2), origin.z()+(width/2)); vector<Quadrilateral> Q; Q.push_back(Quadrilateral(V0,V1,V5,V4)); Q.push_back(Quadrilateral(V2,V3,V7,V6)); Q.push_back(Quadrilateral(V0,V4,V7,V3)); Q.push_back(Quadrilateral(V5,V1,V2,V6)); Q.push_back(Quadrilateral(V1,V0,V3,V2)); Q.push_back(Quadrilateral(V4,V5,V6,V7)); setFaces(Q); calculateMinMax(); }
/** * Execute the algorithm. */ void SofQW3::exec() { MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace"); // Do the full check for common binning if( !WorkspaceHelpers::commonBoundaries(inputWS) ) { throw std::invalid_argument("The input workspace must have common binning across all spectra"); } RebinnedOutput_sptr outputWS = this->setUpOutputWorkspace(inputWS, getProperty("QAxisBinning"), m_Qout); g_log.debug() << "Workspace type: " << outputWS->id() << std::endl; setProperty("OutputWorkspace", outputWS); const size_t nEnergyBins = inputWS->blocksize(); const size_t nHistos = inputWS->getNumberHistograms(); // Progress reports & cancellation const size_t nreports(nHistos * nEnergyBins); m_progress = boost::shared_ptr<API::Progress>(new API::Progress(this, 0.0, 1.0, nreports)); // Compute input caches this->initCachedValues(inputWS); std::vector<double> par = inputWS->getInstrument()->getNumberParameter("detector-neighbour-offset"); if (par.empty()) { // Index theta cache this->initThetaCache(inputWS); } else { g_log.debug() << "Offset: " << par[0] << std::endl; this->m_detNeighbourOffset = static_cast<int>(par[0]); this->getValuesAndWidths(inputWS); } const MantidVec & X = inputWS->readX(0); PARALLEL_FOR2(inputWS, outputWS) for (int64_t i = 0; i < static_cast<int64_t>(nHistos); ++i) // signed for openmp { PARALLEL_START_INTERUPT_REGION DetConstPtr detector = inputWS->getDetector(i); if (detector->isMasked() || detector->isMonitor()) { continue; } double theta = this->m_theta[i]; double phi = 0.0; double thetaWidth = 0.0; double phiWidth = 0.0; // Non-PSD mode if (par.empty()) { thetaWidth = this->m_thetaWidth; } // PSD mode else { phi = this->m_phi[i]; thetaWidth = this->m_thetaWidths[i]; phiWidth = this->m_phiWidths[i]; } double thetaHalfWidth = 0.5 * thetaWidth; double phiHalfWidth = 0.5 * phiWidth; const double thetaLower = theta - thetaHalfWidth; const double thetaUpper = theta + thetaHalfWidth; const double phiLower = phi - phiHalfWidth; const double phiUpper = phi + phiHalfWidth; const double efixed = this->getEFixed(detector); for(size_t j = 0; j < nEnergyBins; ++j) { m_progress->report("Computing polygon intersections"); // For each input polygon test where it intersects with // the output grid and assign the appropriate weights of Y/E const double dE_j = X[j]; const double dE_jp1 = X[j+1]; const V2D ll(dE_j, this->calculateQ(efixed, dE_j, thetaLower, phiLower)); const V2D lr(dE_jp1, this->calculateQ(efixed, dE_jp1, thetaLower, phiLower)); const V2D ur(dE_jp1, this->calculateQ(efixed, dE_jp1, thetaUpper, phiUpper)); const V2D ul(dE_j, this->calculateQ(efixed, dE_j, thetaUpper, phiUpper)); Quadrilateral inputQ = Quadrilateral(ll, lr, ur, ul); this->rebinToFractionalOutput(inputQ, inputWS, i, j, outputWS, m_Qout); } PARALLEL_END_INTERUPT_REGION } PARALLEL_CHECK_INTERUPT_REGION outputWS->finalize(); this->normaliseOutput(outputWS, inputWS); }