 Timestamp:
 Apr 9, 2010 1:46:29 PM (13 years ago)
 Location:
 sans/XOP_Dev/MonteCarlo
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

sans/XOP_Dev/MonteCarlo/MonteCarlo.c
r623 r673 13 13 #include "DebyeSpheres.h" 14 14 15 static int gCallSpinProcess = 1; // Set to 1 to all user abort (cmd dot) and background processing.15 //static int gCallSpinProcess = 1; // Set to 1 to all user abort (cmd dot) and background processing. 16 16 17 17 ////////// … … 60 60 long n1,n2,n3; 61 61 double dth,zz,xx,yy,phi; 62 double theta,ran,ll,rr ,ttot;62 double theta,ran,ll,rr; 63 63 long done,find_theta,err; //used as logicals 64 64 long xPixel,yPixel; … … 73 73 // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 74 74 waveHndl wavH; 75 int waveType,hState;75 // int waveType,hState; 76 76 long numDimensions; 77 77 long dimensionSizes[MAX_DIMENSIONS+1]; 78 char* dataStartPtr; 79 long dataOffset; 80 long numRows, numColumns,numRows_ran_dev; 81 double *dp0, *dp, value[2]; // Pointers used for double data. 78 // char* dataStartPtr; 79 // long dataOffset; 80 // long numRows, numColumns; 81 long numRows_ran_dev; 82 // double *dp0, *dp; 83 double value[2]; // Pointers used for double data. 82 84 long seed; 83 85 long indices[MAX_DIMENSIONS]; 84 86 85 char buf[256];87 // char buf[256]; 86 88 87 89 /* check that wave handles are all valid */ … … 154 156 sig_incoh = inputWave[9]; 155 157 sig_sas = inputWave[10]; 156 xCtr_long = round(xCtr);157 yCtr_long = round(yCtr);158 xCtr_long = (long)(xCtr+0.5); 159 yCtr_long = (long)(yCtr+0.5); 158 160 159 161 dummy = MDGetWaveScaling(p>ran_devH, 0, &delta, &left); //0 is the rows … … 368 370 //Choose index for scattering angle array. 369 371 //IND = NINT(THETA_z/DTH + 0.4999999) 370 ind = round(theta_z/dth + 0.4999999); //round is eqivalent to nint()372 ind = (long)(theta_z/dth + 0.4999999); //round is eqivalent to nint() 371 373 nt[ind] += 1; //Increment bin for angle. 372 374 //Increment angle array for single scattering events. … … 408 410 //indices[0] = xCtr_long; //don't put everything in one pixel 409 411 //indices[1] = yCtr_long; 410 indices[0] = (long) round(xCtr+xx/pixSize);411 indices[1] = (long) round(yCtr+yy/pixSize);412 indices[0] = (long)(xCtr+xx/pixSize+0.5); 413 indices[1] = (long)(yCtr+yy/pixSize+0.5); 412 414 // check for valid indices  got an XOP error, probably from here 413 415 if(indices[0] > 127) indices[0] = 127; … … 483 485 theta = 2.0*asin(qy*lam/4.0/pi); 484 486 dy = sdd*tan(theta); 485 *yPixel = round(yCtr + dy/pixSize);487 *yPixel = (long)(yCtr + dy/pixSize+0.5); 486 488 487 489 theta = 2.0*asin(qx*lam/4.0/pi); 488 490 dx = sdd*tan(theta); 489 *xPixel = round(xCtr + dx/pixSize);491 *xPixel = (long)(xCtr + dx/pixSize+0.5); 490 492 491 493 //if on detector, return xPix and yPix values, otherwise 1 
sans/XOP_Dev/MonteCarlo/MonteCarlo.r
r623 r673 16 16 { 17 17 /* [1] */ 18 " WaveAccess requires Igor Pro 5.0or later.",18 "SANSMonteCarlo requires Igor Pro 6.1 or later.", 19 19 /* [2] */ 20 20 "Wave does not exist.", 
sans/XOP_Dev/MonteCarlo/MonteCarlo2.c
r623 r673 12 12 #include "MonteCarlo.h" 13 13 14 static int gCallSpinProcess = 1; // Set to 1 to all user abort (cmd dot) and background processing.14 //static int gCallSpinProcess = 1; // Set to 1 to all user abort (cmd dot) and background processing. 15 15 16 16 // these versions are DIRECT COPIES of the main version in MonteCarlo.c … … 41 41 long n1,n2,n3; 42 42 double dth,zz,xx,yy,phi; 43 double theta,ran,ll,rr ,ttot;43 double theta,ran,ll,rr; 44 44 long done,find_theta,err; //used as logicals 45 45 long xPixel,yPixel; … … 55 55 // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 56 56 waveHndl wavH; 57 int waveType,hState;57 // int waveType,hState; 58 58 long numDimensions; 59 59 long dimensionSizes[MAX_DIMENSIONS+1]; 60 char* dataStartPtr; 61 long dataOffset; 62 long numRows, numColumns,numRows_ran_dev; 63 double *dp0, *dp, value[2]; // Pointers used for double data. 60 // char* dataStartPtr; 61 // long dataOffset; 62 // long numRows, numColumns; 63 long numRows_ran_dev; 64 // double *dp0, *dp; 65 double value[2]; // Pointers used for double data. 64 66 long seed; 65 67 long indices[MAX_DIMENSIONS]; 66 68 67 char buf[256];69 // char buf[256]; 68 70 69 71 /* check that wave handles are all valid */ … … 136 138 sig_incoh = inputWave[9]; 137 139 sig_sas = inputWave[10]; 138 xCtr_long = round(xCtr);139 yCtr_long = round(yCtr);140 xCtr_long = (long)(xCtr+0.5); 141 yCtr_long = (long)(yCtr+0.5); 140 142 141 143 dummy = MDGetWaveScaling(p>ran_devH, 0, &delta, &left); //0 is the rows … … 350 352 //Choose index for scattering angle array. 351 353 //IND = NINT(THETA_z/DTH + 0.4999999) 352 ind = round(theta_z/dth + 0.4999999); //round is eqivalent to nint()354 ind = (long)(theta_z/dth + 0.4999999); //round is eqivalent to nint() 353 355 nt[ind] += 1; //Increment bin for angle. 354 356 //Increment angle array for single scattering events. … … 390 392 //indices[0] = xCtr_long; //don't put everything in one pixel 391 393 //indices[1] = yCtr_long; 392 indices[0] = (long) round(xCtr+xx/pixSize);393 indices[1] = (long) round(yCtr+yy/pixSize);394 indices[0] = (long)(xCtr+xx/pixSize+0.5); 395 indices[1] = (long)(yCtr+yy/pixSize+0.5); 394 396 // check for valid indices  got an XOP error, probably from here 395 397 if(indices[0] > 127) indices[0] = 127; … … 472 474 long n1,n2,n3; 473 475 double dth,zz,xx,yy,phi; 474 double theta,ran,ll,rr ,ttot;476 double theta,ran,ll,rr; 475 477 long done,find_theta,err; //used as logicals 476 478 long xPixel,yPixel; … … 486 488 // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 487 489 waveHndl wavH; 488 int waveType,hState;490 // int waveType,hState; 489 491 long numDimensions; 490 492 long dimensionSizes[MAX_DIMENSIONS+1]; 491 char* dataStartPtr; 492 long dataOffset; 493 long numRows, numColumns,numRows_ran_dev; 494 double *dp0, *dp, value[2]; // Pointers used for double data. 493 // char* dataStartPtr; 494 // long dataOffset; 495 // long numRows, numColumns; 496 long numRows_ran_dev; 497 // double *dp0, *dp; 498 double value[2]; // Pointers used for double data. 495 499 long seed; 496 500 long indices[MAX_DIMENSIONS]; 497 501 498 char buf[256];502 // char buf[256]; 499 503 500 504 /* check that wave handles are all valid */ … … 567 571 sig_incoh = inputWave[9]; 568 572 sig_sas = inputWave[10]; 569 xCtr_long = round(xCtr);570 yCtr_long = round(yCtr);573 xCtr_long = (long)(xCtr+0.5); 574 yCtr_long = (long)(yCtr+0.5); 571 575 572 576 dummy = MDGetWaveScaling(p>ran_devH, 0, &delta, &left); //0 is the rows … … 781 785 //Choose index for scattering angle array. 782 786 //IND = NINT(THETA_z/DTH + 0.4999999) 783 ind = round(theta_z/dth + 0.4999999); //round is eqivalent to nint()787 ind = (long)(theta_z/dth + 0.4999999); //round is eqivalent to nint() 784 788 nt[ind] += 1; //Increment bin for angle. 785 789 //Increment angle array for single scattering events. … … 821 825 //indices[0] = xCtr_long; //don't put everything in one pixel 822 826 //indices[1] = yCtr_long; 823 indices[0] = (long) round(xCtr+xx/pixSize);824 indices[1] = (long) round(yCtr+yy/pixSize);827 indices[0] = (long)(xCtr+xx/pixSize+0.5); 828 indices[1] = (long)(yCtr+yy/pixSize+0.5); 825 829 // check for valid indices  got an XOP error, probably from here 826 830 if(indices[0] > 127) indices[0] = 127; … … 902 906 long n1,n2,n3; 903 907 double dth,zz,xx,yy,phi; 904 double theta,ran,ll,rr ,ttot;908 double theta,ran,ll,rr; 905 909 long done,find_theta,err; //used as logicals 906 910 long xPixel,yPixel; … … 916 920 // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 917 921 waveHndl wavH; 918 int waveType,hState;922 // int waveType,hState; 919 923 long numDimensions; 920 924 long dimensionSizes[MAX_DIMENSIONS+1]; 921 char* dataStartPtr; 922 long dataOffset; 923 long numRows, numColumns,numRows_ran_dev; 924 double *dp0, *dp, value[2]; // Pointers used for double data. 925 // char* dataStartPtr; 926 // long dataOffset; 927 // long numRows, numColumns; 928 long numRows_ran_dev; 929 // double *dp0, *dp; 930 double value[2]; // Pointers used for double data. 925 931 long seed; 926 932 long indices[MAX_DIMENSIONS]; 927 933 928 char buf[256];934 // char buf[256]; 929 935 930 936 /* check that wave handles are all valid */ … … 997 1003 sig_incoh = inputWave[9]; 998 1004 sig_sas = inputWave[10]; 999 xCtr_long = round(xCtr);1000 yCtr_long = round(yCtr);1005 xCtr_long = (long)(xCtr+0.5); 1006 yCtr_long = (long)(yCtr+0.5); 1001 1007 1002 1008 dummy = MDGetWaveScaling(p>ran_devH, 0, &delta, &left); //0 is the rows … … 1211 1217 //Choose index for scattering angle array. 1212 1218 //IND = NINT(THETA_z/DTH + 0.4999999) 1213 ind = round(theta_z/dth + 0.4999999); //round is eqivalent to nint()1219 ind = (long)(theta_z/dth + 0.4999999); //round is eqivalent to nint() 1214 1220 nt[ind] += 1; //Increment bin for angle. 1215 1221 //Increment angle array for single scattering events. … … 1251 1257 //indices[0] = xCtr_long; //don't put everything in one pixel 1252 1258 //indices[1] = yCtr_long; 1253 indices[0] = (long) round(xCtr+xx/pixSize);1254 indices[1] = (long) round(yCtr+yy/pixSize);1259 indices[0] = (long)(xCtr+xx/pixSize+0.5); 1260 indices[1] = (long)(yCtr+yy/pixSize+0.5); 1255 1261 // check for valid indices  got an XOP error, probably from here 1256 1262 if(indices[0] > 127) indices[0] = 127;
Note: See TracChangeset
for help on using the changeset viewer.