source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf @ 975

Last change on this file since 975 was 975, checked in by srkline, 7 years ago

adding more functions for VSANS infrastructure

File size: 2.2 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4// functions to apply corrections to the detector panels
5
6// may be relocated in the future
7
8
9
10
11//
12// detector dead time
13//
14// input is the data array (N tubes x M pixels)
15// input of N x 1 array of dead time values
16//
17// output is the corrected counts in data, overwriting the input data
18//
19// Note that the equation in Roe (eqn 2.15, p. 63) looks different, but it is really the
20// same old equation, just written in a more complex form.
21//
22// TODO
23// -- verify the direction of the tubes and indexing
24// x- decide on the appropriate functional form for the tubes
25// x- need count time as input
26// -- be sure I'm working in the right data folder
27// -- clean up when done
28// -- calculate + return the error contribution?
29//
30Function DeadTimeCorrectionTubes(dataW,dtW,orientation,ctTime)
31        Wave dataW,dtW
32        String orientation
33        Variable ctTime
34       
35        // do I count on the orientation as an input, or do I just figure it out on my own?
36       
37        // sum the counts in each tube and divide by time for total cr per tube
38        Variable npt
39       
40        if(cmpstr(orientation,"vertical")==0)
41                //      this is data dimensioned as (Ntubes,Npix)
42               
43                MatrixOp/O sumTubes = sumRows(dataW)            // n x 1 result
44                sumTubes /= ctTime              //now count rate per tube
45               
46                dataW[][] = dataW[p][q]/(1-sumTubes[p][0]*dtW[p])               //correct the data
47
48        elseif(cmpstr(orientation,"horizontal")==0)
49        //      this is data (horizontal) dimensioned as (Npix,Ntubes)
50
51                MatrixOp/O sumTubes = sumCols(dataW)            // 1 x m result
52                sumTubes /= ctTime
53               
54                dataW[][] = dataW[p][q]/(1-sumTubes[0][q]*dtW[q])
55       
56        else           
57                DoAlert 0,"Orientation not correctly passed in DeadTimeCorrectionTubes(). No correction done."
58        endif
59       
60        return(0)
61end
62
63
64
65/////
66//
67//
68// non-linear corrections to the tube pixels
69// - returns the distance in mm (although this may change)
70//
71//
72// c0,c1,c2,pix
73// c0-c2 are the fit coefficients
74// pix is the test pixel
75//
76// returns the distance in mm (relative to ctr pixel)
77// ctr is the center pixel, as defined when fitting to quadratic was done
78//
79Function V_TubePixel_to_mm(c0,c1,c2,pix)
80        Variable c0,c1,c2,pix
81       
82        Variable dist
83        dist = c0 + c1*pix + c2*pix*pix
84       
85        return(dist)
86End
87
88////
Note: See TracBrowser for help on using the repository browser.