source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_SideView.ipf @ 1093

Last change on this file since 1093 was 1093, checked in by srkline, 5 years ago

New dimensions added for the back detector. many functions neede to be updated to accomodate these changes. Beam center is handled in the same way (in cm, not pixels) as other panels even though this panel is like the 2D detectors on SANS.

Still missing is the real values for caibration, pixel size, dead time, etc. that are yet to be measured.

File size: 11.9 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3
4
5
6/////////////
7// different views of the detector positions - based on John's drawings and the geometry
8//
9//
10// These are the side and top views with the "rays" traced out to show
11// where the detector views overlap
12//
13// TODO:
14// -x  make sure that all of the values are from global constants, not hard-wired values
15//
16//
17//
18
19
20// generate the waves needed for drawing the views
21// draw a blank graph
22Function SetupSideView()
23
24        SetDataFolder root:Packages:NIST:VSANS:VCALC
25
26        Make/O/D/N=2 FT_profileX,FT_profileY,FB_profileX,FB_profileY
27        Make/O/D/N=2 MT_profileX,MT_profileY,MB_profileX,MB_profileY
28       
29        Make/O/D/N=4 FT_rayX,FT_rayY,FB_rayX,FB_rayY
30        Make/O/D/N=4 MT_rayX,MT_rayY,MB_rayX,MB_rayY
31
32        Make/O/D/N=2 B_S_profileX,B_S_profileY
33        Make/O/D/N=4 B_S_rayX,B_S_rayY
34       
35        DoWindow SideView
36        if(V_Flag==0)
37                Execute "SideView()"
38        endif
39       
40//      UpdateSideView()  // don't bother running this here - the Execute is a separate command and is out of sync.
41       
42        SetDataFolder root:
43        return(0)
44End
45
46// TODO:
47// -x account for the 41cm SDD setback for the T/B detectors. These are only seen in the side view.
48//
49Function UpdateSideView()
50
51        SetDataFolder root:Packages:NIST:VSANS:VCALC
52       
53// wave declarations
54        Wave FT_profileX,FT_profileY,FB_profileX,FB_profileY
55        Wave MT_profileX,MT_profileY,MB_profileX,MB_profileY
56       
57        Wave FT_rayX,FT_rayY,FB_rayX,FB_rayY
58        Wave MT_rayX,MT_rayY,MB_rayX,MB_rayY
59
60        Wave B_S_profileX,B_S_profileY
61        Wave B_S_rayX,B_S_rayY
62
63// Dimensions of detectors
64        NVAR F_LR_w = gFront_LR_w
65        NVAR F_LR_h = gFront_LR_h
66        NVAR F_TB_w = gFront_TB_w
67        NVAR F_TB_h = gFront_TB_h
68       
69        NVAR M_LR_w = gMiddle_LR_w
70        NVAR M_LR_h = gMiddle_LR_h
71        NVAR M_TB_w = gMiddle_TB_w
72        NVAR M_TB_h = gMiddle_TB_h
73
74        NVAR B_h = gBack_h
75        NVAR B_w = gBack_w
76
77
78// get the values from the panel
79        Variable F_LR_sep,F_T_sep, F_B_sep ,F_SDD
80        Variable M_LR_sep,M_T_sep, M_B_sep, M_SDD
81        Variable B_SDD, B_offset
82
83        NVAR TB_SDD_setback = gFront_SDDsetback         //in [cm]  distance T/B are behind L/R - not to be confused with lateral offset
84       
85        //front
86// separations are [cm] translation from zero (center) position
87        ControlInfo VCALCCtrl_2b
88        F_T_sep = V_Value
89        ControlInfo VCALCCtrl_2bb
90        F_B_sep = V_Value
91        ControlInfo VCALCCtrl_2d
92        F_SDD = V_Value
93                               
94        //middle
95//      ControlInfo VCALCCtrl_3a
96//      M_LR_sep = V_Value
97        ControlInfo VCALCCtrl_3b
98        M_T_sep = V_Value
99        ControlInfo VCALCCtrl_3bb
100        M_B_sep = V_Value
101        ControlInfo VCALCCtrl_3d
102        M_SDD = V_Value
103       
104        //back                 
105        ControlInfo VCALCCtrl_4a
106        B_offset = V_Value     
107        ControlInfo VCALCCtrl_4b
108        B_SDD = V_Value         
109
110//      Print "Front ", F_LR_sep,F_TB_sep, F_SDD, F_offset
111//      Print "Middle ",  M_LR_sep,M_TB_sep, M_SDD, M_offset
112//      Print "Back ",  B_SDD, B_offset                 
113                       
114
115// FRONT
116        FT_profileX = (F_SDD+TB_SDD_setback)            //SDD in [cm], set back from L/R        ---- convert to meters for the plot?
117        FB_profileX = FT_profileX
118       
119        FT_profileY[0] = F_T_sep                // edge closest to zero position [cm]
120        FT_profileY[1] = FT_profileY[0] + F_TB_h        // add in height of T/B panel in cm
121       
122        FB_profileY[0] = F_B_sep
123        FB_profileY[1] = F_B_sep - F_TB_h                       // height of B panel, negative Y
124
125        //angles (not calculating anything, just connect the dots)
126        FT_rayX[0] = 0
127        FT_rayX[1] = F_SDD+TB_SDD_setback
128        FT_rayX[2] = F_SDD+TB_SDD_setback
129        FT_rayX[3] = 0
130       
131        FT_rayY[0] = 0
132        FT_rayy[1] = FT_profileY[0]
133        FT_rayY[2] = FT_profileY[1]
134        FT_rayY[3] = 0
135       
136       
137        FB_rayX[0] = 0
138        FB_rayX[1] = F_SDD+TB_SDD_setback
139        FB_rayX[2] = F_SDD+TB_SDD_setback
140        FB_rayX[3] = 0
141       
142        FB_rayY[0] = 0
143        FB_rayy[1] = FB_profileY[0]
144        FB_rayY[2] = FB_profileY[1]
145        FB_rayY[3] = 0 
146
147
148// MIDDLE       
149        MT_profileX = M_SDD+TB_SDD_setback              //SDD in [cm]
150        MB_profileX = MT_profileX
151       
152        MT_profileY[0] = M_T_sep                // separation in cm
153        MT_profileY[1] = MT_profileY[0] + M_TB_h        // add in height of T/B panel in cm
154
155        MB_profileY[0] = M_B_sep
156        MB_profileY[1] = M_B_sep - M_TB_h                       // height of B panel, negative Y       
157
158        //angles (not calculating anything, just connect the dots)
159        MT_rayX[0] = 0
160        MT_rayX[1] = M_SDD+TB_SDD_setback
161        MT_rayX[2] = M_SDD+TB_SDD_setback
162        MT_rayX[3] = 0
163       
164        MT_rayY[0] = 0
165        MT_rayy[1] = MT_profileY[0]
166        MT_rayY[2] = MT_profileY[1]
167        MT_rayY[3] = 0
168       
169       
170        MB_rayX[0] = 0
171        MB_rayX[1] = M_SDD+TB_SDD_setback
172        MB_rayX[2] = M_SDD+TB_SDD_setback
173        MB_rayX[3] = 0
174       
175        MB_rayY[0] = 0
176        MB_rayy[1] = MB_profileY[0]
177        MB_rayY[2] = MB_profileY[1]
178        MB_rayY[3] = 0 
179
180// BACK
181        B_S_profileX = B_SDD            //SDDb in [cm]
182       
183        B_S_profileY[0] = B_h/2         // half-height
184        B_S_profileY[1] = -B_h/2                // half-height
185
186        B_S_rayX[0] = 0
187        B_S_rayX[1] = B_SDD
188        B_S_rayX[2] = B_SDD
189        B_S_rayX[3] = 0
190       
191        B_S_rayY[0] = 0
192        B_S_rayy[1] = B_S_profileY[0]
193        B_S_rayY[2] = B_S_profileY[1]
194        B_S_rayY[3] = 0
195       
196        SetDataFolder root:
197       
198        Execute "SideView()"
199       
200        return(0)
201       
202End
203
204
205Window SideView() : Graph
206
207        PauseUpdate; Silent 1           // building window...
208        String fldrSav0= GetDataFolder(1)
209        SetDataFolder root:Packages:NIST:VSANS:VCALC
210       
211        CheckDisplayed/W=VCALC#SideView FB_rayY
212        if(V_flag == 0)
213//              Display /W=(41,720,592,1119) FB_rayY vs FB_rayX as "SideView"
214                AppendToGraph/W=VCALC#SideView FB_rayY vs FB_rayX
215                AppendToGraph/W=VCALC#SideView FT_rayY vs FT_rayX
216                AppendToGraph/W=VCALC#SideView MB_rayY vs MB_rayX
217                AppendToGraph/W=VCALC#SideView MT_rayY vs MT_rayX
218                AppendToGraph/W=VCALC#SideView B_S_rayY vs B_S_rayX
219                AppendToGraph/W=VCALC#SideView B_S_profileY vs B_S_profileX
220                AppendToGraph/W=VCALC#SideView FB_profileY vs FB_profileX
221                AppendToGraph/W=VCALC#SideView FT_profileY vs FT_profileX
222                AppendToGraph/W=VCALC#SideView MB_profileY vs MB_profileX
223                AppendToGraph/W=VCALC#SideView MT_profileY vs MT_profileX
224       
225                ModifyGraph/W=VCALC#SideView lSize(B_S_profileY)=5,lSize(FB_profileY)=5,lSize(FT_profileY)=5,lSize(MB_profileY)=5
226                ModifyGraph/W=VCALC#SideView lSize(MT_profileY)=5
227                ModifyGraph/W=VCALC#SideView rgb(FB_rayY)=(0,0,0),rgb(FT_rayY)=(0,0,0),rgb(MB_rayY)=(0,0,0),rgb(MT_rayY)=(0,0,0)
228                ModifyGraph/W=VCALC#SideView rgb(B_S_rayY)=(0,0,0),rgb(B_S_profileY)=(1,52428,52428),rgb(FB_profileY)=(3,52428,1)
229                ModifyGraph/W=VCALC#SideView rgb(FT_profileY)=(3,52428,1),rgb(MB_profileY)=(1,12815,52428),rgb(MT_profileY)=(1,12815,52428)
230                ModifyGraph/W=VCALC#SideView grid=1
231                ModifyGraph/W=VCALC#SideView mirror=2
232                ModifyGraph/W=VCALC#SideView nticks(left)=8
233                Label/W=VCALC#SideView left "\\Z10Vertical position (cm)"
234                Label/W=VCALC#SideView bottom "\\Z10SDD (cm)"
235                SetAxis/W=VCALC#SideView left -80.0,80.0
236                SetAxis/W=VCALC#SideView bottom 0,2500
237//              TextBox/W=VCALC#SideView/C/N=text0/A=MC/X=22.54/Y=42.04 "\\JCSIDE VIEW\rOnly the Top/Bottom panels are shown"
238                TextBox/W=VCALC#SideView/C/N=text0/A=MC/X=40.15/Y=43.62 "\\JCSIDE VIEW\r= Top/Bottom panels"
239        endif
240        SetDataFolder fldrSav0
241       
242EndMacro
243
244
245
246//////////////////
247// generate the waves needed for drawing the views
248// draw a blank graph
249//
250// TOP VIEW uses the L and R banks
251//
252Function SetupTopView()
253
254        SetDataFolder root:Packages:NIST:VSANS:VCALC
255
256        Make/O/D/N=2 FL_profileX,FL_profileY,FR_profileX,FR_profileY
257        Make/O/D/N=2 ML_profileX,ML_profileY,MR_profileX,MR_profileY
258       
259        Make/O/D/N=4 FL_rayX,FL_rayY,FR_rayX,FR_rayY
260        Make/O/D/N=4 ML_rayX,ML_rayY,MR_rayX,MR_rayY
261
262        Make/O/D/N=2 B_T_profileX,B_T_profileY
263        Make/O/D/N=4 B_T_rayX,B_T_rayY
264
265        DoWindow TopView
266        if(V_Flag==0)
267                Execute "TopView()"
268        endif
269       
270       
271        SetDataFolder root:
272        return(0)
273End
274
275Function UpdateTopView()
276
277        SetDataFolder root:Packages:NIST:VSANS:VCALC
278       
279// wave declarations
280        Wave FL_profileX,FL_profileY,FR_profileX,FR_profileY
281        Wave ML_profileX,ML_profileY,MR_profileX,MR_profileY
282       
283        Wave FL_rayX,FL_rayY,FR_rayX,FR_rayY
284        Wave ML_rayX,ML_rayY,MR_rayX,MR_rayY
285
286        Wave B_T_profileX,B_T_profileY
287        Wave B_T_rayX,B_T_rayY
288
289// Dimensions of detectors
290        NVAR F_LR_w = gFront_LR_w
291        NVAR F_LR_h = gFront_LR_h
292        NVAR F_TB_w = gFront_TB_w
293        NVAR F_TB_h = gFront_TB_h
294       
295        NVAR M_LR_w = gMiddle_LR_w
296        NVAR M_LR_h = gMiddle_LR_h
297        NVAR M_TB_w = gMiddle_TB_w
298        NVAR M_TB_h = gMiddle_TB_h
299
300        NVAR B_h = gBack_h
301        NVAR B_w = gBack_w
302
303
304// get the values from the panel
305        Variable F_L_sep,F_R_sep, F_TB_sep, F_SDD
306        Variable M_L_sep,M_R_sep, M_TB_sep, M_SDD
307        Variable B_SDD, B_offset
308        //front
309        ControlInfo VCALCCtrl_2a
310        F_L_sep = V_Value
311        ControlInfo VCALCCtrl_2aa
312        F_R_sep = V_Value
313        ControlInfo VCALCCtrl_2d
314        F_SDD = V_Value
315                               
316        //middle
317        ControlInfo VCALCCtrl_3a
318        M_L_sep = V_Value
319        ControlInfo VCALCCtrl_3aa
320        M_R_sep = V_Value
321        ControlInfo VCALCCtrl_3d
322        M_SDD = V_Value
323       
324        //back                 
325        ControlInfo VCALCCtrl_4a
326        B_offset = V_Value     
327        ControlInfo VCALCCtrl_4b
328        B_SDD = V_Value         
329
330//      Print "Front ", F_LR_sep,F_TB_sep, F_SDD, F_offset
331//      Print "Middle ",  M_LR_sep,M_TB_sep, M_SDD, M_offset
332//      Print "Back ",  B_SDD, B_offset                 
333                       
334
335// FRONT
336        FL_profileX = F_SDD             //SDD in [cm]
337        FR_profileX = FL_profileX
338       
339        FL_profileY[0] = F_L_sep                // translation from zero in cm
340        FL_profileY[1] = F_L_sep - F_LR_w               // subtract width of L/R panel in cm
341       
342        FR_profileY[0] = F_R_sep                // translation from zero in cm
343        FR_profileY[1] = F_R_sep + F_LR_w               // add width of L/R panel in cm
344
345        //angles (not calculating anything, just connect the dots)
346        FL_rayX[0] = 0
347        FL_rayX[1] = F_SDD
348        FL_rayX[2] = F_SDD
349        FL_rayX[3] = 0
350       
351        FL_rayY[0] = 0
352        FL_rayy[1] = FL_profileY[0]
353        FL_rayY[2] = FL_profileY[1]
354        FL_rayY[3] = 0
355       
356       
357        FR_rayX[0] = 0
358        FR_rayX[1] = F_SDD
359        FR_rayX[2] = F_SDD
360        FR_rayX[3] = 0
361       
362        FR_rayY[0] = 0
363        FR_rayy[1] = FR_profileY[0]
364        FR_rayY[2] = FR_profileY[1]
365        FR_rayY[3] = 0 
366
367
368// MIDDLE       
369        ML_profileX = M_SDD             //SDD in [cm]
370        MR_profileX = ML_profileX
371       
372        ML_profileY[0] = M_L_sep                // translation in cm
373        ML_profileY[1] = M_L_sep - M_LR_w               // subtract width of L/R panel in cm
374       
375        MR_profileY[0] = M_R_sep                // translation in cm
376        MR_profileY[1] = M_R_sep + M_LR_w               // add width of L/R panel in cm
377
378        //angles (not calculating anything, just connect the dots)
379        ML_rayX[0] = 0
380        ML_rayX[1] = M_SDD
381        ML_rayX[2] = M_SDD
382        ML_rayX[3] = 0
383       
384        ML_rayY[0] = 0
385        ML_rayy[1] = ML_profileY[0]
386        ML_rayY[2] = ML_profileY[1]
387        ML_rayY[3] = 0
388       
389       
390        MR_rayX[0] = 0
391        MR_rayX[1] = M_SDD
392        MR_rayX[2] = M_SDD
393        MR_rayX[3] = 0
394       
395        MR_rayY[0] = 0
396        MR_rayy[1] = MR_profileY[0]
397        MR_rayY[2] = MR_profileY[1]
398        MR_rayY[3] = 0 
399
400// BACK
401        B_T_profileX = B_SDD            //SDDb in [cm]
402       
403        B_T_profileY[0] = B_w/2         // from the top, see the width
404        B_T_profileY[1] = -B_w/2                // half-width
405
406        B_T_rayX[0] = 0
407        B_T_rayX[1] = B_SDD
408        B_T_rayX[2] = B_SDD
409        B_T_rayX[3] = 0
410       
411        B_T_rayY[0] = 0
412        B_T_rayY[1] = B_T_profileY[0]
413        B_T_rayY[2] = B_T_profileY[1]
414        B_T_rayY[3] = 0
415       
416        SetDataFolder root:
417       
418        Execute "TopView()"
419       
420        return(0)
421       
422End
423
424
425Window TopView() : Graph
426        PauseUpdate; Silent 1           // building window...
427        String fldrSav0= GetDataFolder(1)
428        SetDataFolder root:Packages:NIST:VSANS:VCALC
429       
430        CheckDisplayed/W=VCALC#TopView FR_rayY
431        if(V_flag == 0)
432               
433//              Display /W=(594,721,1144,1119) FR_rayY vs FR_rayX as "TopView"
434                AppendToGraph/W=VCALC#TopView FR_rayY vs FR_rayX
435                AppendToGraph/W=VCALC#TopView FL_rayY vs FL_rayX
436                AppendToGraph/W=VCALC#TopView MR_rayY vs MR_rayX
437                AppendToGraph/W=VCALC#TopView ML_rayY vs ML_rayX
438                AppendToGraph/W=VCALC#TopView B_T_rayY vs B_T_rayX
439                AppendToGraph/W=VCALC#TopView B_T_profileY vs B_T_profileX
440                AppendToGraph/W=VCALC#TopView FR_profileY vs FR_profileX
441                AppendToGraph/W=VCALC#TopView FL_profileY vs FL_profileX
442                AppendToGraph/W=VCALC#TopView MR_profileY vs MR_profileX
443                AppendToGraph/W=VCALC#TopView ML_profileY vs ML_profileX
444       
445                ModifyGraph/W=VCALC#TopView lSize(B_T_profileY)=5,lSize(FR_profileY)=5,lSize(FL_profileY)=5,lSize(MR_profileY)=5
446                ModifyGraph/W=VCALC#TopView lSize(ML_profileY)=5
447                ModifyGraph/W=VCALC#TopView rgb(FR_rayY)=(0,0,0),rgb(FL_rayY)=(0,0,0),rgb(MR_rayY)=(0,0,0),rgb(ML_rayY)=(0,0,0)
448                ModifyGraph/W=VCALC#TopView rgb(B_T_rayY)=(0,0,0),rgb(B_T_profileY)=(1,52428,52428),rgb(FR_profileY)=(39321,26208,1)
449                ModifyGraph/W=VCALC#TopView rgb(FL_profileY)=(39321,26208,1)
450                ModifyGraph/W=VCALC#TopView grid=1
451                ModifyGraph/W=VCALC#TopView mirror=2
452                ModifyGraph/W=VCALC#TopView nticks(left)=8
453                Label/W=VCALC#TopView left "\\Z10Horizontal position (cm)"
454                Label/W=VCALC#TopView bottom "\\Z10SDD (cm)"
455                SetAxis/W=VCALC#TopView left -80.0,80.0
456                SetAxis/W=VCALC#TopView bottom 0,2500
457                TextBox/W=VCALC#TopView/C/N=text0/A=MC/X=41.61/Y=43.62 "\\JCTOP VIEW\r= Left/Right panels"
458        endif
459        SetDataFolder fldrSav0
460
461EndMacro
462
463
464
Note: See TracBrowser for help on using the repository browser.