Changeset 490 for sans/Dev/trunk/NCNR_User_Procedures/Reduction
 Timestamp:
 Apr 14, 2009 3:31:17 PM (14 years ago)
 Location:
 sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf
r475 r490 426 426 // so get it from the wave scaling instead 427 427 Q0 =left + binarysearchinterp(ran_dev,abs(enoise(1)))*delta 428 theta = Q0/2/Pi*wavelength //SAS approximation 428 theta = Q0/2/Pi*wavelength //SAS approximation. 1% error at theta=30 deg (theta/2=15deg) 429 429 430 430 //Print "q0, theta = ",q0,theta … … 520 520 // then it must be a transmitted neutron 521 521 // don't need to calculate, just increment the proper counters 522 MC_linear_data[xCtr][yCtr] += 1 522 523 MC_linear_data[xCtr+xx/pixsize][yCtr+yy/pixsize] += 1 523 524 isOn += 1 524 525 nt[0] += 1 … … 922 923 CheckBox check0,pos={216,180},size={68,14},title="Raw counts",variable = root:Packages:NIST:SAS:gRawCounts 923 924 CheckBox check0_1,pos={216,199},size={60,14},title="Yes Offset",variable= root:Packages:NIST:SAS:gDoTraceOffset 925 CheckBox check0_2,pos={216,199+19},size={60,14},title="Beam Stop in",variable= root:Packages:NIST:SAS:gBeamStopIn 926 CheckBox check0_3,pos={216,199+2*19},size={60,14},title="use XOP",variable= root:Packages:NIST:SAS:gUse_MC_XOP 924 927 925 928 String fldrSav0= GetDataFolder(1) … … 1064 1067 End 1065 1068 1066 1069 // calculates the fraction of the scattering that reaches the detector, given the random deviate function 1070 // and qmin and qmax 1071 // 1072 // 1073 // still some question of the corners and number of pixels per qbin 1074 Function FractionReachingDetector(ran_dev,Qmin,Qmax) 1075 wave ran_dev 1076 Variable Qmin,Qmax 1077 1078 Variable r1,r2,frac 1079 r1=x2pnt(ran_dev,Qmin) 1080 r2=x2pnt(ran_dev,Qmax) 1081 1082 // no normalization needed  the full qrange is defined as [0,1] 1083 frac = ran_dev[r2]  ran_dev[r1] 1084 1085 return frac 1086 End 1067 1087 1068 1088 
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf
r472 r490 117 117 Variable/G root:Packages:NIST:SAS:gCntTime = 1 118 118 Variable/G root:Packages:NIST:SAS:gDoMonteCarlo = 0 119 Variable/G root:Packages:NIST:SAS:gUse_MC_XOP = 1 //set to zero to use Igor code 120 Variable/G root:Packages:NIST:SAS:gBeamStopIn = 1 //set to zero for beamstop out (transmission) 119 121 Variable/G root:Packages:NIST:SAS:gRawCounts = 0 120 122 Variable/G root:Packages:NIST:SAS:gSaveIndex = 100 … … 927 929 t0 = stopMStimer(2) 928 930 inputWave[0] = 1000 929 // Monte_SANS_Threaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 930 Monte_SANS_NotThreaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 931 NVAR useXOP = root:Packages:NIST:SAS:gUse_MC_XOP //if zero, will use nonthreaded Igor code 932 933 if(useXOP) 934 //use a single thread, otherwise time is dominated by overhead 935 Monte_SANS_NotThreaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 936 else 937 Monte_SANS(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 938 endif 939 931 940 t0 = (stopMSTimer(2)  t0)*1e6 932 941 t0 *= imon/1000/ThreadProcessorCount //projected time, in seconds (using threads for the calculation) … … 949 958 t0 = stopMStimer(2) 950 959 951 Monte_SANS_Threaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 952 // Monte_SANS_NotThreaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 953 960 if(useXOP) 961 Monte_SANS_Threaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 962 else 963 Monte_SANS_NotThreaded(inputWave,ran_dev,nt,j1,j2,nn,linear_data,results) 964 endif 965 954 966 t0 = (stopMSTimer(2)  t0)*1e6 955 967 Printf "MC sim time = %g seconds\r",t0 … … 960 972 endif 961 973 962 Print "counts on detector = ",sum(linear_data,inf,inf)963 964 linear_data[xCtr][yCtr] = 0 //snip out the transmitted spike974 Print "counts on detector, including transmitted = ",sum(linear_data,inf,inf) 975 976 // linear_data[xCtr][yCtr] = 0 //snip out the transmitted spike 965 977 // Print "counts on detector not transmitted = ",sum(linear_data,inf,inf) 966 978 967 979 // or simulate a beamstop 980 NVAR MC_BS_in = root:Packages:NIST:SAS:gBeamStopIn //if zero, beam stop is "out", as in a transmission measurement 981 968 982 Variable rad=beamstopDiam()/2 //beamstop radius in cm 969 rad /= 0.5 //convert cm to pixels 970 rad += 0. // (no  it cuts off the low Q artificially) add an extra pixel to each side to account for edge 971 Duplicate/O linear_data,root:Packages:NIST:SAS:tmp_mask 972 WAVE tmp_mask = root:Packages:NIST:SAS:tmp_mask 973 tmp_mask = (sqrt((pxCtr)^2+(qyCtr)^2) < rad) ? 0 : 1 //behind beamstop = 0, away = 1 974 975 linear_data *= tmp_mask 983 if(MC_BS_in) 984 rad /= 0.5 //convert cm to pixels 985 rad += 0. // (no  it cuts off the low Q artificially) add an extra pixel to each side to account for edge 986 Duplicate/O linear_data,root:Packages:NIST:SAS:tmp_mask//,root:Packages:NIST:SAS:MC_linear_data 987 WAVE tmp_mask = root:Packages:NIST:SAS:tmp_mask 988 tmp_mask = (sqrt((pxCtr)^2+(qyCtr)^2) < rad) ? 0 : 1 //behind beamstop = 0, away = 1 989 990 linear_data *= tmp_mask 991 endif 992 976 993 results[9] = sum(linear_data,inf,inf) 977 994 // Print "counts on detector not behind beamstop = ",results[9]
Note: See TracChangeset
for help on using the changeset viewer.