#pragma rtGlobals=1 // Use modern global access method. #pragma IgorVersion=6.1 // there are utlity functions here (commented out) for plotting the 2D resolution function // at any point on the detector // I can only calculate (nord) points in an AAO fashion, so threading the function calculation // doesn't help. Even if I can rewrite this to calculate nord*nord AAO, that will typically be 10*10=100 // and that is not enough points to thread with any benefit // but the calculation of each q value is independent, so I can split the total number of q-values between processors // // -- but I must be careful to pass this a function that is not already threaded! // --- BUT - I can't pass either a function reference, OR a structure to a thread! // ---- So sadly, each 2D resolution calculation must be threaded by hand. // // See the Sphere_2D function for an example of how to thread the smearing // // // SRK May 2010 // // NOTE: there is a definition of FindTheta = -1* FindPhi() that is a duplicate of what is in RawWindowHook.ipf // and should eventually be in a common location for analysis and reduction packages // //// this is the completely generic 2D smearing, not threaded, but takes FUNCREF and STRUCT parameters // // uses resolution ellipse defined perpendicular "Y" and parallel "X", // rotating the ellipse into its proper orientaiton based on qx,qy // // 5 gauss points is not enough - it gives artifacts as a function of phi // 10 gauss points is minimally sufficient // 20 gauss points are needed if lots of oscillations (just like in 1D) // even more may be necessary for highly peaked functions // // Function Smear_2DModel_PP(fcn,s,nord) FUNCREF SANS_2D_ModelAAO_proto fcn Struct ResSmear_2D_AAOStruct &s Variable nord String weightStr,zStr Variable ii,jj,kk,num Variable qx,qy,qz,qval,fs Variable qy_pt,qx_pt,res_x,res_y,answer,sumIn,sumOut Variable a,b,c,normFactor,phi,theta,maxSig,numStdDev=3 switch(nord) case 5: weightStr="gauss5wt" zStr="gauss5z" if (WaveExists($weightStr) == 0) Make/O/D/N=(nord) $weightStr,$zStr Make5GaussPoints($weightStr,$zStr) endif break case 10: weightStr="gauss10wt" zStr="gauss10z" if (WaveExists($weightStr) == 0) Make/O/D/N=(nord) $weightStr,$zStr Make10GaussPoints($weightStr,$zStr) endif break case 20: weightStr="gauss20wt" zStr="gauss20z" if (WaveExists($weightStr) == 0) Make/O/D/N=(nord) $weightStr,$zStr Make20GaussPoints($weightStr,$zStr) endif break default: Abort "Smear_2DModel_PP called with invalid nord value" endswitch Wave/Z wt = $weightStr Wave/Z xi = $zStr /// keep these waves local // Make/O/D/N=1 yPtW Make/O/D/N=(nord) fcnRet,xptW,res_tot,yptW // now just loop over the points as specified num=numpnts(s.xw[0]) answer=0 Variable spl,spp,apl,app,bpl,bpp,phi_pt,qpl_pt Variable qperp_pt,phi_prime,q_prime Variable t1=StopMSTimer(-2) //loop over q-values for(ii=0;ii