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

Last change on this file was 1242, checked in by srkline, 3 years ago

updating the IgorVersion? pragma to v7.0 for all files to be consistent.

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