/** This software was developed by the University of Tennessee as part of the Distributed Data Analysis of Neutron Scattering Experiments (DANSE) project funded by the US National Science Foundation. If you use DANSE applications to do scientific research that leads to publication, we ask that you acknowledge the use of the software with the following sentence: "This work benefited from DANSE software developed under NSF award DMR-0520547." copyright 2009, University of Tennessee */ #include "smearer.hh" #include #include using namespace std; /** * Constructor for BaseSmearer * * @param qmin: minimum Q value * @param qmax: maximum Q value * @param nbins: number of Q bins */ BaseSmearer :: BaseSmearer(double qmin, double qmax, int nbins) { // Number of bins this->nbins = nbins; this->qmin = qmin; this->qmax = qmax; // Flag to keep track of whether we have a smearing matrix or // whether we need to compute one has_matrix = false; }; /** * Constructor for SlitSmearer * * @param width: slit width in Q units * @param height: slit height in Q units * @param qmin: minimum Q value * @param qmax: maximum Q value * @param nbins: number of Q bins */ SlitSmearer :: SlitSmearer(double width, double height, double qmin, double qmax, int nbins) : BaseSmearer(qmin, qmax, nbins){ this->height = height; this->width = width; }; /** * Constructor for SlitSmearer * * @param width: array slit widths for each Q point, in Q units * @param qmin: minimum Q value * @param qmax: maximum Q value * @param nbins: number of Q bins */ QSmearer :: QSmearer(double* width, double qmin, double qmax, int nbins) : BaseSmearer(qmin, qmax, nbins){ this->width = width; }; /** * Compute the slit smearing matrix */ void SlitSmearer :: compute_matrix(){ weights = new vector(nbins*nbins,0); // Loop over all q-values for(int i=0; i0 ? npts : 1; int npts_w = width>0 ? npts : 1; // If both height and width are great than zero, // modify the number of points in each direction so // that the total number of points is still what // the user would expect (downgrade resolution) if(npts_h>1 && npts_w>1){ npts_h = (int)ceil(sqrt((double)npts)); npts_w = npts_h; } double shift_h, shift_w; for(int k=0; k(nbins*nbins,0); // Loop over all q-values double step = (qmax-qmin)/((double)nbins-1.0); for(int i=0; i0.0) ? sum/counts : 0; } }