Ejemplo n.º 1
0
void SINQTranspose3D::doTRICS(IMDHistoWorkspace_sptr inWS)
{
	double *inVal, *inErr, *outVal, *outErr;
	size_t idxIn, idxOut;
	unsigned int xdim, ydim, zdim;

	boost::shared_ptr<const IMDDimension> x,y,z;
	x = inWS->getXDimension();
	y = inWS->getYDimension();
	z = inWS->getZDimension();

	std::vector<IMDDimension_sptr> dimensions;
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(x));
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(z));
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(y));

    MDHistoWorkspace_sptr outWS (new MDHistoWorkspace(dimensions));
    outWS->setTo(.0,.0,.0);

    inVal = inWS->getSignalArray();
    inErr = inWS->getErrorSquaredArray();
    outVal = outWS->getSignalArray();
    outErr = outWS->getErrorSquaredArray();
    xdim = static_cast<unsigned int>(x->getNBins());
    ydim = static_cast<unsigned int>(y->getNBins());
    zdim = static_cast<unsigned int>(z->getNBins());
    for(unsigned int xx = 0; xx < xdim; xx++){
    	for(unsigned int yy= 0; yy < ydim; yy++){
    		for(unsigned int zz = 0; zz <  zdim; zz++){
    			idxIn = ydim*zdim*xx + zdim*yy + zz; // this works for TRICS
    			idxOut = outWS->getLinearIndex(xx,zz,yy);
    			outVal[idxOut] = inVal[idxIn];
    			outErr[idxOut] = inErr[idxIn];
    		}
    	}
    }
    copyMetaData(inWS, outWS);

    // assign the workspace
	setProperty("OutputWorkspace",outWS);

}
Ejemplo n.º 2
0
void SINQTranspose3D::doAMOR(IMDHistoWorkspace_sptr inWS)
{
	double val, *inVal;
	unsigned int xdim, ydim, zdim, idx;

	boost::shared_ptr<const IMDDimension> x,y,z;
	x = inWS->getXDimension();
	y = inWS->getYDimension();
	z = inWS->getZDimension();

	std::vector<IMDDimension_sptr> dimensions;
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(y));
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(x));
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(z));

    MDHistoWorkspace_sptr outWS (new MDHistoWorkspace(dimensions));
    outWS->setTo(.0,.0,.0);

    xdim = static_cast<unsigned int>(x->getNBins());
    ydim = static_cast<unsigned int>(y->getNBins());
    zdim = static_cast<unsigned int>(z->getNBins());
    inVal = inWS->getSignalArray();
    for(unsigned int xx = 0; xx < xdim; xx++){
    	for(unsigned int yy = 0; yy < ydim; yy++){
    		for(unsigned zz = 0; zz < zdim; zz++){
    			//idx = ydim*zdim*xx + zdim*yy + zz;
    			idx = ydim*zdim*xx + zdim*yy + zz;
    			val = inVal[idx];
    			outWS->setSignalAt(outWS->getLinearIndex(yy,xx,zz),val);
    			outWS->setErrorSquaredAt(outWS->getLinearIndex(yy,xx,zz),val);
    		}
    	}
    }

    copyMetaData(inWS, outWS);

    // assign the workspace
	setProperty("OutputWorkspace",outWS);

}