Ignore:
Timestamp:
Sep 10, 2009 3:53:23 PM (14 years ago)
Author:
srkline
Message:

Correct reporting of results wave accounting for multiple coherent scattering
(2nd version with different ran - otherwise identical to MonteCarlo?.c)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/XOP_Dev/MonteCarlo/MonteCarlo2.c

    r458 r553  
    7070        long NSingleIncoherent,NSingleCoherent,NScatterEvents,incoherentEvent,coherentEvent; 
    7171        long NDoubleCoherent,NMultipleScatter,isOn,xCtr_long,yCtr_long; 
     72        long NMultipleCoherent,NCoherentEvents; 
     73 
    7274 
    7375        // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 
     
    219221        NMultipleScatter = 0; 
    220222        NScatterEvents = 0; 
     223        NMultipleCoherent = 0; 
     224        NCoherentEvents = 0; 
     225         
    221226        isOn = 0; 
    222227         
     
    283288                                        //sprintf(buf,"neutron scatters coherently\r"); 
    284289                                        //XOPNotice(buf); 
    285                                         coherentEvent = 1; 
     290                                        coherentEvent += 1; 
    286291                                        find_theta = 0;                 //false 
    287292                                        do { 
     
    307312                                        //sprintf(buf,"neutron scatters incoherent\r"); 
    308313                                        //XOPNotice(buf); 
    309                                         incoherentEvent = 1; 
     314                                        incoherentEvent += 1; 
    310315                                  // phi and theta are random over the entire sphere of scattering 
    311316                                        // !can't just choose random theta and phi, won't be random over sphere solid angle 
     
    392397                                                NMultipleScatter += 1; 
    393398                                        } 
     399                                        if(coherentEvent >= 1 && incoherentEvent == 0) { 
     400                                                NCoherentEvents += 1; 
     401                                        } 
     402                                        if(coherentEvent > 1 && incoherentEvent == 0) { 
     403                                                NMultipleCoherent += 1; 
     404                                        } 
     405 
    394406                                } else {        // index was zero, neutron must be transmitted, so just increment the proper counters and data 
    395407                                                isOn += 1; 
    396408                                                nt[0] += 1; 
    397409                                                MemClear(indices, sizeof(indices)); // Must be 0 for unused dimensions. 
    398                                                 indices[0] = xCtr_long; 
    399                                                 indices[1] = yCtr_long; 
     410                                                //indices[0] = xCtr_long;               //don't put everything in one pixel 
     411                                                //indices[1] = yCtr_long; 
     412                                                indices[0] = (long)round(xCtr+xx/pixSize); 
     413                                                indices[1] = (long)round(yCtr+yy/pixSize); 
     414                                                // check for valid indices - got an XOP error, probably from here 
     415                                                if(indices[0] > 127) indices[0] = 127; 
     416                                                if(indices[0] < 0) indices[0] = 0; 
     417                                                if(indices[1] > 127) indices[1] = 127; 
     418                                                if(indices[1] < 0) indices[1] = 0; 
     419                                                 
    400420                                                if (result = MDGetNumericWavePointValue(wavH, indices, value)) 
    401421                                                        return result; 
     
    431451        if (result = MDSetNumericWavePointValue(p->resultsH, indices, value)) 
    432452                return result; 
    433         value[0] = (double)NDoubleCoherent; 
     453        value[0] = (double)NMultipleCoherent; 
    434454        indices[0] = 5; 
    435455        if (result = MDSetNumericWavePointValue(p->resultsH, indices, value)) 
     
    439459        if (result = MDSetNumericWavePointValue(p->resultsH, indices, value)) 
    440460                return result;   
    441  
     461        value[0] = (double)NCoherentEvents; 
     462        indices[0] = 7; 
     463        if (result = MDSetNumericWavePointValue(p->resultsH, indices, value)) 
     464                return result; 
    442465 
    443466//      HSetState((Handle)wavH, hState);                //release the handle of the 2D data wave 
Note: See TracChangeset for help on using the changeset viewer.