source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf @ 1133

Last change on this file since 1133 was 1133, checked in by srkline, 4 years ago

many changes to the VCALC procedures to add in the hard/soft shadowing to the calculation, visualization of the shadowed regions, and the actual q-values. Added a separate panel to view the shadowed regions.

simpe fix to the real time routine to allow easy updating of both the raw 2D data and 1-D average

update to the USANS package to handle the new NICE generated data where the data is collected in terms of q-values rather than angle. On startup asks user which style of data they have. Sets a preference that can be un-checked if you have old-style ICP data. (there is nothing in the data file that I can key on).

File size: 51.8 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3//
4//
5// mockup of the panel for VCALC
6//
7// -- all is housed in the folder:
8//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC
9//
10// -- Put all of the constants to define the instrument plus all of the VCALC stuff
11//
12// anticipating that at the same level as VCALC will be all of the reduction folders
13// in a similar way as for SANS reduction
14//
15//
16
17
18Proc VCALC_Panel()
19        DoWindow/F VCALC
20        if(V_flag==0)
21       
22                //initialize space = folders, parameters, instrument constants, etc.
23                VC_Initialize_Space()
24               
25                //open the panel
26                DrawVCALC_Panel()
27
28                // check for a mask, if not present, generate a default mask (this will be updated later)
29                if(!Exists("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_FT:data"))
30                        V_GenerateDefaultMask()
31                endif
32               
33                // two graphs with the ray-tracing side/top views
34                SetupSideView()
35                SetupTopView()
36               
37                // a front view of the panels
38                FrontView_1x()
39               
40                // pop one of the presets to get everything to update
41                VC_Preset_WhiteBeam()
42               
43                // update the views
44                VC_UpdateViews()
45               
46                // a recalculation is needed after the change
47                // this re-bins the I(q) data too
48                Recalculate_AllDetectors()
49               
50        endif
51End
52
53Function FakeFrontMiddleSDDClick()
54       
55        STRUCT WMSetVariableAction sva
56        sva.eventCode = 3
57//      sva.dval = 0.3
58
59        VC_BDet_SDD_SetVarProc(sva)             
60        VC_MDet_SDD_SetVarProc(sva)
61        VC_FDet_SDD_SetVarProc(sva)
62
63        return(0)
64end
65
66
67Proc DrawVCALC_Panel()
68        PauseUpdate; Silent 1           // building window...
69        NewPanel /W=(34,44,1274,699)/N=VCALC/K=1
70        ModifyPanel cbRGB=(49151,60031,65535)
71//      ShowTools/A
72        SetDrawLayer UserBack
73       
74// always visible stuff, not on any tab
75       
76        GroupBox group0,pos={10,10},size={440,125},title="Setup"
77        TabControl Vtab,labelBack=(45000,61000,58000),pos={14,150},size={430,200},tabLabel(0)="Collim"
78        TabControl Vtab,tabLabel(1)="Sample",tabLabel(2)="Front Det",tabLabel(3)="Mid Det"
79        TabControl Vtab,tabLabel(4)="Back Det",tabLabel(5)="Simul",value= 0,proc=VCALCTabProc
80        GroupBox group1,pos={460,10},size={762,635},title="Detector Panel Positions + Data"
81        Button button_a,pos={250,70},size={100,20},title="Show Mask",proc=V_VCALCShowMaskButtonProc
82        Button button_b,pos={250,100},size={100,20},title="Recalculate",proc=V_VCALCRecalcButtonProc
83
84
85        PopupMenu popup_a,pos={50,40},size={142,20},title="Presets"
86        PopupMenu popup_a,mode=1,popvalue="White Beam",value= root:Packages:NIST:VSANS:VCALC:gPresetPopStr
87        PopupMenu popup_a,proc=VC_PresetConfigPopup
88
89        PopupMenu popup_b,pos={670,311},size={142,20},title="Binning type",proc=VC_RebinIQ_PopProc
90        PopupMenu popup_b,mode=1,value= root:Packages:NIST:VSANS:VCALC:gBinTypeStr
91        SetVariable setVar_b,pos={476,313},size={120,15},title="axis Q",proc=Front2DQ_Range_SetVarProc
92        SetVariable setVar_b,limits={0.02,1,0.02},value=_NUM:0.52
93        CheckBox check_0a title="Log?",size={60,20},pos={619,313},proc=Front2DQ_Log_CheckProc
94               
95        SetVariable setVar_a,pos={476,26},size={120,15},title="axis degrees",proc=FrontView_Range_SetVarProc
96        SetVariable setVar_a,limits={0.3,30,0.2},value=_NUM:28
97
98        ValDisplay valDisp_a,pos={30,380},size={150,15},fstyle=1,title="Beam Intensity",value=root:Packages:NIST:VSANS:VCALC:gBeamIntensity
99
100        SetDrawEnv fstyle= 1
101        DrawText 30,420,"Back"
102        DrawText 80,420,"Q min"
103        DrawText 150,420,"Q max"
104        ValDisplay valDisp_b,pos={30,420},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_B
105        ValDisplay valDisp_c,pos={130,420},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_B
106
107        SetDrawEnv fstyle= 1
108        DrawText 130,460,"Middle"
109        DrawText 180,460,"Q min"
110        DrawText 250,460,"Q max"       
111        ValDisplay valDisp_d,pos={130,460},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_M
112        ValDisplay valDisp_e,pos={230,460},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_M
113
114        SetDrawEnv fstyle= 1
115        DrawText 230,500,"Front"       
116        DrawText 280,500,"Q min"
117        DrawText 350,500,"Q max"       
118        ValDisplay valDisp_f,pos={230,500},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_F
119        ValDisplay valDisp_g,pos={330,500},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_F
120
121
122        ValDisplay valDisp_h,pos={50,530},size={200,15},title="Beam Diam (middle) (cm)",value=root:Packages:NIST:VSANS:VCALC:gBeamDiam
123        ValDisplay valDisp_i,pos={50,560},size={200,15},title="Beam Stop Diam (middle) (in)",value=root:Packages:NIST:VSANS:VCALC:gBeamStopDiam
124        ValDisplay valDisp_j,pos={50,590},size={200,15},title="Beam Stop Q min (1/A)",value=root:Packages:NIST:VSANS:VCALC:gRealQMin
125
126
127
128        // for panels (in degrees)     
129        Display/W=(476,45,757,303)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
130        RenameWindow #,FrontView
131        ModifyGraph mode=2              // mode = 2 = dots
132        ModifyGraph marker=19
133        ModifyGraph rgb=(0,0,0)
134        ModifyGraph tick=2,mirror=1
135        Label left "degrees"
136        Label bottom "degrees" 
137        SetActiveSubwindow ##
138
139
140        // for side view
141        Display/W=(842,25,1200,170)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
142        RenameWindow #,SideView
143        ModifyGraph mode=2              // mode = 2 = dots
144        ModifyGraph marker=19
145        ModifyGraph rgb=(0,0,0)
146        ModifyGraph tick=2,mirror=1
147        Label left "Vertical position (cm)"
148        Label bottom "SDD (cm)"
149        SetAxis/A/R left       
150        SetActiveSubwindow ##   
151       
152        // for top view
153        Display/W=(842,180,1200,325)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
154        RenameWindow #,TopView
155        ModifyGraph mode=2              // mode = 2 = dots
156        ModifyGraph marker=19
157        ModifyGraph rgb=(0,0,0)
158        ModifyGraph tick=2,mirror=1
159        Label left "Horizontal position (cm)"
160        Label bottom "SDD (cm)"
161        SetActiveSubwindow ##   
162
163        // for panels (as 2D Q)
164        Display/W=(475,332,814,631)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
165        RenameWindow #,Panels_Q
166        ModifyGraph mode=2              // mode = 2 = dots
167        ModifyGraph tick=2,mirror=1,grid=2,standoff=0
168        ModifyGraph width={Aspect,1},height={Aspect,1},gbRGB=(56797,56797,56797)
169        SetAxis left -0.2,0.2
170        SetAxis bottom -0.2,0.2
171        Label left "Qy"
172        Label bottom "Qx"       
173        SetActiveSubwindow ##
174
175
176
177        // for averaged I(Q)
178        Display/W=(842,334,1204,629)/HOST=# //root:Packages:NIST:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
179        RenameWindow #,Panels_IQ
180//      ModifyGraph mode=2              // mode = 2 = dots
181        ModifyGraph tick=2,mirror=1,grid=2
182//      Label left "Intensity"
183//      Label bottom "Q"       
184        SetActiveSubwindow ##
185
186
187       
188// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter indexing items on tab
189
190       
191// tab(0), collimation - initially visible
192        Slider VCALCCtrl_0a,pos={223,324-50},size={200,45},limits={0,9,1},value= 1,vert= 0,proc=V_GuideSliderProc
193        SetVariable VCALCCtrl_0b,pos={25,294-50},size={120,15},title="wavelength"
194        SetVariable VCALCCtrl_0b,limits={4,20,1},value=_NUM:8,proc=VC_Lambda_SetVarProc
195        PopupMenu VCALCCtrl_0c,pos={26,257-50},size={150,20},title="monochromator"
196        PopupMenu VCALCCtrl_0c,mode=1,popvalue="Velocity Selector",value= root:Packages:NIST:VSANS:VCALC:gMonochromatorType
197        PopupMenu VCALCCtrl_0c,proc=VC_MonochromSelectPopup
198        PopupMenu VCALCCtrl_0d,pos={26,321-50},size={115,20},title="delta lambda"
199        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
200        PopupMenu VCALCCtrl_0d,proc=VC_DeltaLamSelectPopup
201        PopupMenu VCALCCtrl_0e,pos={291,262-50},size={132,20},title="source shape"
202        PopupMenu VCALCCtrl_0e,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSourceShape
203        PopupMenu VCALCCtrl_0e,proc=VC_SourceApShapeSelectPopup
204        PopupMenu VCALCCtrl_0f,pos={283,293-50},size={141,20},title="source aperture"
205        PopupMenu VCALCCtrl_0f,mode=1,popvalue="6.0 cm",value= root:Packages:NIST:VSANS:VCALC:gSourceDiam
206        PopupMenu VCALCCtrl_0f,proc=VC_SourceAperDiamSelectPopup
207
208
209// tab(1) - Sample conditions, initially not visible
210        PopupMenu VCALCCtrl_1a,pos={38,250-50},size={142,20},title="table location",disable=1
211        PopupMenu VCALCCtrl_1a,mode=1,popvalue="Changer",value= root:Packages:NIST:VSANS:VCALC:gTableLocation
212        PopupMenu VCALCCtrl_1b,pos={270,250-50},size={115,20},title="Aperture Shape",disable=1
213        PopupMenu VCALCCtrl_1b,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureShape
214        PopupMenu VCALCCtrl_1c,pos={270,310-50},size={132,20},title="Aperture Diam (cm)",disable=1
215        PopupMenu VCALCCtrl_1c,mode=1,popvalue="1.27",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureDiam
216        SetVariable VCALCCtrl_1d,pos={25,280-50},size={200,15},title="Sample Aperture to Gate Valve (cm)"
217        SetVariable VCALCCtrl_1d,limits={4,40,0.1},value=_NUM:22,proc=VC_A2_to_GV_SetVarProc,disable=1
218        SetVariable VCALCCtrl_1e,pos={25,310-50},size={200,15},title="Sample Pos to Gate Valve (cm)"
219        SetVariable VCALCCtrl_1e,limits={4,40,0.1},value=_NUM:11,proc=VC_Sam_to_GV_SetVarProc,disable=1
220
221// tab(2) - Front detector panels, initially not visible
222        SetVariable VCALCCtrl_2a,pos={30,260-50},size={150,15},title="LEFT Offset (cm)",proc=VC_FDet_LR_SetVarProc
223        SetVariable VCALCCtrl_2a,limits={-20,19,0.1},disable=1,value=_NUM:-10
224        SetVariable VCALCCtrl_2aa,pos={30,290-50},size={150,15},title="RIGHT Offset (cm)",proc=VC_FDet_LR_SetVarProc
225        SetVariable VCALCCtrl_2aa,limits={-19,20,0.1},disable=1,value=_NUM:10
226       
227        SetVariable VCALCCtrl_2b,pos={30,330-50},size={150,15},title="TOP Offset (cm)",proc=VC_FDet_LR_SetVarProc
228        SetVariable VCALCCtrl_2b,limits={0,18,0.1},disable=1,value=_NUM:10
229        SetVariable VCALCCtrl_2bb,pos={30,360-50},size={150,15},title="BOTTOM Offset (cm)",proc=VC_FDet_LR_SetVarProc
230        SetVariable VCALCCtrl_2bb,limits={-18,0,0.1},disable=1,value=_NUM:-10
231       
232        SetVariable VCALCCtrl_2d,pos={205,260-50},size={230,15},title="Gate Valve to Detector Distance (cm)",proc=VC_FDet_SDD_SetVarProc
233        SetVariable VCALCCtrl_2d,limits={70,800,1},disable=1    ,value=_NUM:150
234       
235
236// tab(3) - Middle detector panels, initially not visible
237        SetVariable VCALCCtrl_3a,pos={30,260-50},size={150,15},title="LEFT Offset (cm)",proc=VC_MDet_LR_SetVarProc
238        SetVariable VCALCCtrl_3a,limits={-20,19,0.1},disable=1,value=_NUM:-7
239        SetVariable VCALCCtrl_3aa,pos={30,290-50},size={150,15},title="RIGHT Offset (cm)",proc=VC_MDet_LR_SetVarProc
240        SetVariable VCALCCtrl_3aa,limits={-19,20,0.1},disable=1,value=_NUM:7
241               
242        SetVariable VCALCCtrl_3b,pos={30,330-50},size={150,15},title="TOP Offset (cm)",proc=VC_MDet_LR_SetVarProc
243        SetVariable VCALCCtrl_3b,limits={0,18,0.1},disable=1,value=_NUM:14
244        SetVariable VCALCCtrl_3bb,pos={30,360-50},size={150,15},title="BOTTOM Offset (cm)",proc=VC_MDet_LR_SetVarProc
245        SetVariable VCALCCtrl_3bb,limits={-18,0,0.1},disable=1,value=_NUM:-14
246
247        SetVariable VCALCCtrl_3d,pos={205,260-50},size={230,15},title="Gate Valve to Detector Distance (cm)",proc=VC_MDet_SDD_SetVarProc
248        SetVariable VCALCCtrl_3d,limits={250,2000,1},disable=1,value=_NUM:1000
249
250       
251// tab(4) - Back detector panel
252        SetVariable VCALCCtrl_4a,pos={188,290-50},size={150,15},title="Lateral Offset (cm)"
253        SetVariable VCALCCtrl_4a,limits={0,20,0.1},disable=1,value=_NUM:0
254        SetVariable VCALCCtrl_4b,pos={188,260-50},size={230,15},title="Gate Valve to Detector Distance (cm)",proc=VC_BDet_SDD_SetVarProc
255        SetVariable VCALCCtrl_4b,limits={2000,2500,1},disable=1,value=_NUM:2200
256//      PopupMenu VCALCCtrl_4c,pos={40,260},size={180,20},title="Detector type",disable=1
257//      PopupMenu VCALCCtrl_4c,mode=1,popvalue="2D",value= root:Packages:NIST:VSANS:VCALC:gBackDetType
258
259// tab(5) - Simulation setup
260        SetVariable VCALCCtrl_5a,pos={40,290-50},size={200,15},title="Neutrons on Sample (imon)"
261        SetVariable VCALCCtrl_5a,limits={1e7,1e15,1e7},disable=1,value=_NUM:1e11,proc=VC_SimImon_SetVarProc
262        PopupMenu VCALCCtrl_5b,pos={40,260-50},size={180,20},title="Model Function",disable=1
263        PopupMenu VCALCCtrl_5b,mode=1,popvalue="Debye",value= root:Packages:NIST:VSANS:VCALC:gModelFunctionType,proc=VC_SimModelFunc_PopProc
264       
265End
266
267Function V_VCALCShowMaskButtonProc(ba) : ButtonControl
268        STRUCT WMButtonAction &ba
269
270        switch( ba.eventCode )
271                case 2: // mouse up
272                        // click code here
273                       
274                        V_SetupPanelDisplay()
275                       
276                        PopupMenu popup1 win=VSANS_Det_Panels,mode=14,popvalue="VCALC"
277                        PopupMenu popup0 win=VSANS_Det_Panels,popvalue="F"
278                        ControlUpdate/A/W=VSANS_Det_Panels
279
280                //pop the carriage menu to refresh the VCALC data
281                        STRUCT WMPopupAction pa
282                        pa.eventCode = 2                //fake click
283                        V_PickCarriagePopMenuProc(pa)
284                       
285// risky, but I can pass the button "click" to the next button to toggle the mask "On"                 
286                        V_ToggleFourMaskButtonProc(ba)
287                       
288                        break
289                case -1: // control being killed
290                        break
291        endswitch
292
293        return 0
294End
295
296
297
298Function V_VCALCRecalcButtonProc(ba) : ButtonControl
299        STRUCT WMButtonAction &ba
300
301        switch( ba.eventCode )
302                case 2: // mouse up
303                        // click code here
304                       
305                        Recalculate_AllDetectors()
306                               
307                        break
308                case -1: // control being killed
309                        break
310        endswitch
311
312        return 0
313End
314
315//
316//  recalculates the detector panels, doesn't adjust the views
317//
318Function Recalculate_AllDetectors()
319
320// calculates Q for each panel
321// and fills 2D panels with model data
322// then plots the 2D panel
323        fPlotBackPanels()
324        fPlotMiddlePanels()
325        fPlotFrontPanels()
326
327// generate a proper mask based on hard+soft shadowing
328        VC_ResetVCALCMask()
329        VC_DrawVCALCMask()
330
331
332// generate the 1D I(q)
333        String popStr
334        String collimationStr = "pinhole"
335        ControlInfo/W=VCALC popup_b
336        popStr = S_Value                //
337        V_QBinAllPanels_Circular("VCALC",V_BinTypeStr2Num(popStr),collimationStr)
338
339        // plot the results (1D)
340        String type = "VCALC"
341        String str,winStr="VCALC#Panels_IQ",workTypeStr
342        workTypeStr = "root:Packages:NIST:VSANS:"+type
343       
344        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr
345        Execute ("V_Back_IQ_Graph"+str)
346               
347        Execute ("V_Middle_IQ_Graph"+str)
348       
349        Execute ("V_Front_IQ_Graph"+str)
350
351
352// update values on the panel
353        V_beamIntensity()
354       
355//      Print "Beam diam (middle) = ",VC_beamDiameter("horizontal",2)           //middle carriage
356       
357        // fill in the Qmin and Qmax values, based on Q_Tot for the 2D panels (not including mask)
358        V_QMinMax_Back()
359        V_QMinMax_Middle()
360        V_QMinMax_Front()
361       
362        //calculate beam diameter and beamstop size
363        V_BeamDiamDisplay("maximum", "MR")      //TODO -- hard-wired here for the Middle carriage (and in the SetVar label)
364        V_BeamStopDiamDisplay("MR")
365       
366        //calculate the "real" QMin with the beamstop
367        V_QMin_withBeamStop("MR")               //TODO -- hard-wired here as the middle carriage and MR panel
368       
369        // multiply the averaged data by the shadow factor to simulate a beamstop
370        V_IQ_BeamstopShadow()
371       
372        return(0)
373End
374
375
376
377// function to control the drawing of controls in the TabControl on the main panel
378// Naming scheme for the controls MUST be strictly adhered to... else controls will
379// appear in odd places...
380// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter denoting
381// the controls position on that particular tab.
382// in this way, they will always be drawn correctly..
383//
384//
385// -- this will need to be modified to allow for the graph to be drawn of the detector bank positions
386//     if that is individual to each tab - or if it's  always visible - that's still to be decided.
387//
388//
389Function VCALCTabProc(name,tab)
390        String name
391        Variable tab
392       
393//      Print "name,number",name,tab
394        String ctrlList = ControlNameList("",";"),item="",nameStr=""
395        Variable num = ItemsinList(ctrlList,";"),ii,onTab
396        for(ii=0;ii<num;ii+=1)
397                //items all start w/"VCALCCtrl_", 10 characters
398                item=StringFromList(ii, ctrlList ,";")
399                nameStr=item[0,9]
400                if(cmpstr(nameStr,"VCALCCtrl_")==0)
401                        onTab = str2num(item[10])                       //[10] is a number
402                        ControlInfo $item
403                        switch(abs(V_flag))     
404                                case 1:
405                                        Button $item,disable=(tab!=onTab)
406                                        break
407                                case 2:
408                                        CheckBox $item,disable=(tab!=onTab)
409                                        break
410                                case 3:
411                                        PopupMenu $item,disable=(tab!=onTab)
412                                        break
413                                case 4:
414                                        ValDisplay $item,disable=(tab!=onTab)
415                                        break
416                                case 5:
417                                        SetVariable $item,disable=(tab!=onTab)
418                                        break
419                                case 7:
420                                        Slider $item,disable=(tab!=onTab)
421                                        break
422                                case 9:
423                                        GroupBox $item,disable=(tab!=onTab)
424                                        break
425                                case 10:       
426                                        TitleBox $item,disable=(tab!=onTab)
427                                        break
428                                // add more items to the switch if different control types are used
429                        endswitch
430                endif
431        endfor
432       
433        return(0)
434End
435
436
437
438// TODO
439//changing the number of guides changes the SSD
440// the source aperture popup may need to be updated
441//
442Function V_GuideSliderProc(ctrlName,sliderValue,event)
443        String ctrlName
444        Variable sliderValue
445        Variable event  // bit field: bit 0: value set, 1: mouse down, 2: mouse up, 3: mouse moved
446       
447        Variable recalc=0
448        SVAR apStr = root:Packages:NIST:VSANS:VCALC:gSourceDiam
449       
450        if(event %& 0x1)        // bit 0, value set
451                if(cmpstr(ctrlName,"") != 0)            //here by direct action, so do LensCheck and recalculate
452//                      recalc=1
453//                      LensCheckProc("",2)             //make sure lenses are deselected
454                endif
455//              sourceToSampleDist()            //updates the SSD global and wave
456                //change the sourceAp popup, SDD range, etc
457                switch(sliderValue)
458                        case 0:
459//                              ControlInfo/W=SASCALC popup0
460//                              mode=V_value
461                                apStr = "0.75 cm;1.5 cm;3.0 cm;"
462                                break
463                        default:
464                                apStr = "6 cm;"
465                endswitch
466                ControlUpdate/W=VCALC VCALCCtrl_0f
467//              UpdateControls()                                // the Ng global is actually set inside this function
468                Recalculate_AllDetectors()
469        endif
470        return 0
471End
472
473
474
475
476
477Function Front2DQ_Log_CheckProc(cba) : CheckBoxControl
478        STRUCT WMCheckboxAction &cba
479
480        switch( cba.eventCode )
481                case 2: // mouse up
482                        Variable checked = cba.checked
483                       
484                        Execute "FrontPanels_AsQ()"
485                        Execute "MiddlePanels_AsQ()"
486                        Execute "BackPanels_AsQ()"
487                       
488                        break
489                case -1: // control being killed
490                        break
491        endswitch
492
493        return 0
494End
495
496
497
498Function VC_SourceAperDiamSelectPopup(pa) : PopupMenuControl
499        STRUCT WMPopupAction &pa
500
501        switch( pa.eventCode )
502                case 2: // mouse up
503                        Variable popNum = pa.popNum
504                        String popStr = pa.popStr
505                       
506                        Print "Not filled in yet"
507                       
508                        // a recalculation is needed after the change
509                        //Recalculate_AllDetectors()
510                                       
511                        break
512                case -1: // control being killed
513                        break
514        endswitch
515
516        return 0
517End
518
519Function VC_SourceApShapeSelectPopup(pa) : PopupMenuControl
520        STRUCT WMPopupAction &pa
521
522        switch( pa.eventCode )
523                case 2: // mouse up
524                        Variable popNum = pa.popNum
525                        String popStr = pa.popStr
526                       
527                        Print "Not filled in yet"
528
529                        // a recalculation is needed after the change
530                        //Recalculate_AllDetectors()
531                                                                       
532                        break
533                case -1: // control being killed
534                        break
535        endswitch
536
537        return 0
538End
539
540Function VC_DeltaLamSelectPopup(pa) : PopupMenuControl
541        STRUCT WMPopupAction &pa
542
543        switch( pa.eventCode )
544                case 2: // mouse up
545                        Variable popNum = pa.popNum
546                        String popStr = pa.popStr
547                       
548                        // a recalculation is needed after the change
549                        Recalculate_AllDetectors()
550                                                                       
551                        break
552                case -1: // control being killed
553                        break
554        endswitch
555
556        return 0
557End
558
559// change the choices for deltaLam based on the
560// type of monochromator selected
561//
562// some cases force a change of the wavelength
563//
564// then recalculate
565Function VC_MonochromSelectPopup(pa) : PopupMenuControl
566        STRUCT WMPopupAction &pa
567
568        switch( pa.eventCode )
569                case 2: // mouse up
570                        Variable popNum = pa.popNum
571                        String popStr = pa.popStr
572                       
573                        SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda
574                       
575                        strswitch(popStr)
576                                case "Velocity Selector":
577                                        DLStr = "0.12;"
578//                                      PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
579                                        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12"
580                                       
581                                        SetVariable VCALCCtrl_0b,disable=0,noedit=0             // allow user editing again
582
583                                        break
584                                case "Graphite":
585                                        DLStr = "0.01;"
586//                                      PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
587                                        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01"
588                                       
589                                        SetVariable VCALCCtrl_0b,value=_NUM:4.75,disable=2              // wavelength
590                                        break
591                                case "White Beam":
592                                        DLStr = "0.40;"
593//                                      PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
594                                        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40"
595
596                                        SetVariable VCALCCtrl_0b,value=_NUM:5.3,disable=2               //wavelength
597                                        break           
598                                default:
599                                        Print "Error--No match in VC_MonochromSelectPopup"
600                                        return(0)
601                        endswitch
602                       
603
604                        // a recalculation is needed after the change
605                        Recalculate_AllDetectors()
606                                                               
607                        break
608                case -1: // control being killed
609                        break
610        endswitch
611
612        return 0
613End
614
615//
616//
617// "F+M Ng0 Low Q;F+M Ng2 Mid Q;F+M Ng7 Mid Q;F+M Ng9 High Q;Converging Pinholes;Narrow Slit;White Beam;Graphite;Polarizer;"
618//
619Function VC_PresetConfigPopup(pa) : PopupMenuControl
620        STRUCT WMPopupAction &pa
621
622        switch( pa.eventCode )
623                case 2: // mouse up
624                        Variable popNum = pa.popNum
625                        String popStr = pa.popStr
626                       
627                        String BinStr = "F2-M2xTB-B"
628               
629                        strswitch(popStr)
630                                case "F+M Ng0 Low Q":
631                                        VC_Preset_FrontMiddle_Ng0()
632                                        break
633                                case "F+M Ng2 Mid Q":
634                                        VC_Preset_FrontMiddle_Ng2()
635                                        break
636                                case "F+M Ng7 Mid Q":
637                                        VC_Preset_FrontMiddle_Ng7()
638                                        break
639                                case "F+M Ng9 High Q":
640                                        VC_Preset_FrontMiddle_Ng9()
641                                        break
642                                       
643                                case "White Beam":
644                                        VC_Preset_WhiteBeam()
645                                        break   
646                                case "Graphite":
647                                        VC_Preset_GraphiteMono()
648                                        break
649                                case "Narrow Slit":
650                                       
651                                        break
652                                case "Converging Pinholes":
653                                       
654                                        break
655                                case "Polarizer":
656                                       
657                                        break
658                                       
659                                default:
660                                        Print "Error--No match in VC_PresetConfigPopup"
661                                        return(0)
662                        endswitch
663                       
664                        // update the views
665                        VC_UpdateViews()
666                       
667                        // a recalculation is needed after the change
668                        // this re-bins the data too
669                        Recalculate_AllDetectors()
670                       
671                        // re-bin the data?
672//                      VC_RebinIQ_PopProc("",0,binStr)
673                                       
674                        break
675                case -1: // control being killed
676                        break
677        endswitch
678
679        return 0
680End
681
682
683
684
685
686//
687// recalculate the detectors with a preset model function
688//
689Function VC_SimModelFunc_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
690        String ctrlName
691        Variable popNum // which item is currently selected (1-based)
692        String popStr           // contents of current popup item as string
693
694        Recalculate_AllDetectors()
695       
696        return(0)       
697End
698
699
700//
701// recalculate the I(q) binning. no need to adjust model function or views
702// just rebin
703//
704// this is for the VCALC 1-D plot subwindow only. so it is set up to
705// operate on that window - but uses the same binning and plotting routines
706// as the regualr VSANS data display
707//
708Function VC_RebinIQ_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
709        String ctrlName
710        Variable popNum // which item is currently selected (1-based)
711        String popStr           // contents of current popup item as string
712
713
714        String type = "VCALC"
715        String str,winStr="VCALC#Panels_IQ",workTypeStr
716        workTypeStr = "root:Packages:NIST:VSANS:"+type
717       
718        String collimationStr = "pinhole"               //TODO: fill this in from the VCALC panel
719       
720// dispatch based on the string, not on the number of selection in the pop string
721        V_QBinAllPanels_Circular(type,V_BinTypeStr2Num(popStr),collimationStr)
722       
723        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr
724
725        Execute ("V_Back_IQ_Graph"+str)
726        Execute ("V_Middle_IQ_Graph"+str)
727        Execute ("V_Front_IQ_Graph"+str)
728
729// OLD - do not use
730//      // do the q-binning for front panels to get I(Q)
731//      Execute "BinAllFrontPanels()"
732//      Execute "Front_IQ_Graph()"
733//
734//      // do the q-binning for middle panels to get I(Q)
735//      Execute "BinAllMiddlePanels()"
736//      Execute "Middle_IQ_Graph()"
737//     
738//      // do the q-binning for the back panel to get I(Q)
739//      Execute "BinAllBackPanels()"
740//      Execute "Back_IQ_Graph()"
741//     
742        return(0)       
743End
744
745
746//
747// setVar for the distance from Sample Position to Gave Valve
748//
749Function VC_Sam_to_GV_SetVarProc(sva) : SetVariableControl
750        STRUCT WMSetVariableAction &sva
751
752        switch( sva.eventCode )
753                case 1: // mouse up
754                case 2: // Enter key
755                case 3: // Live update
756                        Variable dval = sva.dval
757                        String sval = sva.sval
758                       
759//                      // don't need to recalculate the views, but need to recalculate the detectors
760
761//                      Recalculate_AllDetectors()             
762                               
763                        break
764                case -1: // control being killed
765                        break
766        endswitch
767
768        return 0
769End
770       
771
772//
773// setVar for the distance from Sample Aperture to Gave Valve
774//
775Function VC_A2_to_GV_SetVarProc(sva) : SetVariableControl
776        STRUCT WMSetVariableAction &sva
777
778        switch( sva.eventCode )
779                case 1: // mouse up
780                case 2: // Enter key
781                case 3: // Live update
782                        Variable dval = sva.dval
783                        String sval = sva.sval
784                       
785//                      // don't need to recalculate the views, but need to recalculate the detectors
786
787//                      Recalculate_AllDetectors()             
788                               
789                        break
790                case -1: // control being killed
791                        break
792        endswitch
793
794        return 0
795End
796       
797//
798// setVar for the wavelength
799//
800Function VC_Lambda_SetVarProc(sva) : SetVariableControl
801        STRUCT WMSetVariableAction &sva
802
803        switch( sva.eventCode )
804                case 1: // mouse up
805                case 2: // Enter key
806                case 3: // Live update
807                        Variable dval = sva.dval
808                        String sval = sva.sval
809                       
810//                      // don't need to recalculate the views, but need to recalculate the detectors
811
812                        Recalculate_AllDetectors()             
813                               
814                        break
815                case -1: // control being killed
816                        break
817        endswitch
818
819        return 0
820End
821
822//
823// setVar for the simulation monitor count
824//
825Function VC_SimImon_SetVarProc(sva) : SetVariableControl
826        STRUCT WMSetVariableAction &sva
827
828        switch( sva.eventCode )
829                case 1: // mouse up
830                case 2: // Enter key
831                case 3: // Live update
832                        Variable dval = sva.dval
833                        String sval = sva.sval
834
835                        Recalculate_AllDetectors()             
836                               
837                        break
838                case -1: // control being killed
839                        break
840        endswitch
841
842        return 0
843End
844
845
846// setVar for the range (in degrees) for the FrontView plot of the detectors
847//
848Function FrontView_Range_SetVarProc(sva) : SetVariableControl
849        STRUCT WMSetVariableAction &sva
850
851        switch( sva.eventCode )
852                case 1: // mouse up
853                case 2: // Enter key
854                case 3: // Live update
855                        Variable dval = sva.dval
856                        String sval = sva.sval
857                       
858                        FrontView_1x()
859                       
860                        break
861                case -1: // control being killed
862                        break
863        endswitch
864
865        return 0
866End
867
868// setVar for the range (in Q) for the FrontView plot of the detectors
869//
870// TODO: this assumes that everything (the data) is already updated - this only updates the plot range
871Function Front2DQ_Range_SetVarProc(sva) : SetVariableControl
872        STRUCT WMSetVariableAction &sva
873
874        switch( sva.eventCode )
875                case 1: // mouse up
876                case 2: // Enter key
877                case 3: // Live update
878                        Variable dval = sva.dval
879                        String sval = sva.sval
880                       
881                        SetAxis/W=VCALC#Panels_Q left -dval,dval
882                        SetAxis/W=VCALC#Panels_Q bottom -dval,dval
883                       
884//                      FrontPanels_AsQ()
885                       
886                        break
887                case -1: // control being killed
888                        break
889        endswitch
890
891        return 0
892End
893
894// SDD for the Front detector. triggers a recalculation
895// of the intensity and a redraw of the banks
896//
897Function VC_FDet_SDD_SetVarProc(sva) : SetVariableControl
898        STRUCT WMSetVariableAction &sva
899
900        switch( sva.eventCode )
901                case 1: // mouse up
902                case 2: // Enter key
903                case 3: // Live update
904                        Variable dval = sva.dval
905                        String sval = sva.sval
906                       
907//                      Variable LR_sep,TB_sep
908//                      // don't know if LR or TB called, so get the explicit values
909//                      //
910//                      ControlInfo VCALCCtrl_2a
911//                      LR_sep = V_Value
912//                      ControlInfo VCALCCtrl_2b
913//                      TB_sep = V_Value
914//                     
915//                      UpdateFrontDetector(LR_sep,TB_sep)
916                       
917                        UpdateSideView()
918                        UpdateTopView()
919                        FrontView_1x()
920                       
921                        fPlotFrontPanels()
922                       
923                        break
924                case -1: // control being killed
925                        break
926        endswitch
927
928        return 0
929End
930
931// SDD for the Middle detector. triggers a recalculation
932// of the intensity and a redraw of the banks
933//
934Function VC_MDet_SDD_SetVarProc(sva) : SetVariableControl
935        STRUCT WMSetVariableAction &sva
936
937        switch( sva.eventCode )
938                case 1: // mouse up
939                case 2: // Enter key
940                case 3: // Live update
941                        Variable dval = sva.dval
942                        String sval = sva.sval
943                       
944//                      Variable LR_sep,TB_sep
945//                      // don't know if LR or TB called, so get the explicit values
946//                      //
947//                      ControlInfo VCALCCtrl_2a
948//                      LR_sep = V_Value
949//                      ControlInfo VCALCCtrl_2b
950//                      TB_sep = V_Value
951//                     
952//                      UpdateFrontDetector(LR_sep,TB_sep)
953                       
954                        UpdateSideView()
955                        UpdateTopView()
956                        FrontView_1x()
957                       
958                        fPlotMiddlePanels()
959                       
960                        break
961                case -1: // control being killed
962                        break
963        endswitch
964
965        return 0
966End
967
968// SDD for the Back detector. triggers a recalculation
969// of the intensity and a redraw of the banks
970//
971Function VC_BDet_SDD_SetVarProc(sva) : SetVariableControl
972        STRUCT WMSetVariableAction &sva
973
974        switch( sva.eventCode )
975                case 1: // mouse up
976                case 2: // Enter key
977                case 3: // Live update
978                        Variable dval = sva.dval
979                        String sval = sva.sval
980                       
981//                      Variable LR_sep,TB_sep
982//                      // don't know if LR or TB called, so get the explicit values
983//                      //
984//                      ControlInfo VCALCCtrl_2a
985//                      LR_sep = V_Value
986//                      ControlInfo VCALCCtrl_2b
987//                      TB_sep = V_Value
988//                     
989//                      UpdateFrontDetector(LR_sep,TB_sep)
990                       
991                        UpdateSideView()
992                        UpdateTopView()
993                        FrontView_1x()
994                       
995                        fPlotBackPanels()
996                       
997                        break
998                case -1: // control being killed
999                        break
1000        endswitch
1001
1002        return 0
1003End
1004
1005// separation, either LR or TB of the front detector. triggers a recalculation
1006// of the intensity and a redraw of the banks
1007//
1008Function VC_FDet_LR_SetVarProc(sva) : SetVariableControl
1009        STRUCT WMSetVariableAction &sva
1010
1011        switch( sva.eventCode )
1012                case 1: // mouse up
1013                case 2: // Enter key
1014                case 3: // Live update
1015                        Variable dval = sva.dval
1016                        String sval = sva.sval
1017                       
1018//                      Variable LR_sep,TB_sep
1019//                      // don't know if LR or TB called, so get the explicit values
1020//                      //
1021//                      ControlInfo VCALCCtrl_2a
1022//                      LR_sep = V_Value
1023//                      ControlInfo VCALCCtrl_2b
1024//                      TB_sep = V_Value
1025//                     
1026//                      UpdateFrontDetector(LR_sep,TB_sep)
1027                       
1028                        UpdateSideView()
1029                        UpdateTopView()
1030                        FrontView_1x()
1031                       
1032                        fPlotFrontPanels()
1033                       
1034                        break
1035                case -1: // control being killed
1036                        break
1037        endswitch
1038
1039        return 0
1040End
1041
1042
1043// separation, either LR or TB of the middle detector. triggers a recalculation
1044// of the intensity and a redraw of the banks
1045//
1046Function VC_MDet_LR_SetVarProc(sva) : SetVariableControl
1047        STRUCT WMSetVariableAction &sva
1048
1049        switch( sva.eventCode )
1050                case 1: // mouse up
1051                case 2: // Enter key
1052                case 3: // Live update
1053                        Variable dval = sva.dval
1054                        String sval = sva.sval
1055                       
1056//                      Variable LR_sep,TB_sep
1057//                      // don't know if LR or TB called, so get the explicit values
1058//                      //
1059//                      ControlInfo VCALCCtrl_3a
1060//                      LR_sep = V_Value
1061//                      ControlInfo VCALCCtrl_3b
1062//                      TB_sep = V_Value
1063                       
1064//                      UpdateMiddleDetector(LR_sep,TB_sep)
1065                       
1066                        UpdateSideView()
1067                        UpdateTopView()
1068                        FrontView_1x()
1069                       
1070                        fPlotMiddlePanels()
1071                       
1072                        break
1073                case -1: // control being killed
1074                        break
1075        endswitch
1076
1077        return 0
1078End
1079
1080// call to update the views (not the q-calculation, that is a separate call)
1081Function VC_UpdateViews()
1082
1083        UpdateSideView()
1084        UpdateTopView()
1085        FrontView_1x()
1086       
1087        return(0)
1088End
1089
1090// this all needs to be fixed and updated - not yet specific to VSANS
1091//
1092// -- all of the simulation stuff will need to be re-thought
1093// -- all of the integersRead, data, etc. will need to be re-thought...
1094// -- but the space needs to be allocated.
1095// -- parameters and constants need to be defined in their own space
1096//
1097// FEB 2016 -- changed the data folder space to mimic the HDF folder structure
1098// so that the averaging routines could be re-used (along with everything else)
1099// -- painful, but better in the long run
1100//
1101// -- I have not re-named the detector arrays to all be "data" since that is very difficult to
1102//   deal with on images. Added a global "gVCALC_Active" as a crude workaround as needed. Turn it
1103//   on when needed and then immediately off
1104//
1105Proc VC_Initialize_Space()
1106//
1107        NewDataFolder/O root:Packages
1108        NewDataFolder/O root:Packages:NIST
1109        NewDataFolder/O root:Packages:NIST:VSANS
1110        NewDataFolder/O root:Packages:NIST:VSANS:VCALC
1111        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry
1112        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument
1113        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
1114        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
1115        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
1116        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
1117        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
1118        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
1119        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
1120        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
1121        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
1122
1123//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front
1124//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Middle
1125//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Back
1126
1127        NewDataFolder/O root:Packages:NIST:VSANS:RawVSANS
1128       
1129        Variable/G root:Packages:NIST:VSANS:VCALC:gVCALC_Active = 1
1130        Variable/G root:Packages:NIST:VSANS:VCALC:gUseNonLinearDet = 0          //if == 1, use RAW non-linear corrections
1131       
1132        SetDataFolder root:Packages:NIST:VSANS:VCALC
1133       
1134
1135///// FRONT DETECTOR BANKS
1136// dimensions for the detector banks (then get them in the drawing functions)
1137// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
1138// so keep them as variables
1139        Variable/G gFront_LR_w = 40.3           //front bank, nominal LR panel width [cm]  0.84cm/tube*48 = 40.3 cm
1140        Variable/G gFront_LR_h = 100.0
1141        Variable/G gFront_TB_w = 50.0
1142        Variable/G gFront_TB_h = 40.3
1143
1144// SDD setback of T/B (decide on units??)
1145// for the Nexus file, the detector distance should already be corrected for the "setback"
1146// of the T/B panels. keep as VCALC variable
1147        Variable/G gFront_SDDsetback = 41.0                     // [cm]
1148       
1149       
1150// detector resolution (xy for each bank!)
1151        Make/O/D/N=1 :entry:instrument:detector_FL:x_pixel_size = 0.84          // (cm)         these tubes are vertical 8.4 mm x-spacing (JGB 2/2106)
1152        Make/O/D/N=1 :entry:instrument:detector_FL:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
1153        Make/O/D/N=1 :entry:instrument:detector_FR:x_pixel_size = 0.84
1154        Make/O/D/N=1 :entry:instrument:detector_FR:y_pixel_size = 0.8
1155        //T/B
1156        Make/O/D/N=1 :entry:instrument:detector_FT:x_pixel_size = 0.4           //these tubes are horizontal
1157        Make/O/D/N=1 :entry:instrument:detector_FT:y_pixel_size = 0.84
1158        Make/O/D/N=1 :entry:instrument:detector_FB:x_pixel_size = 0.4
1159        Make/O/D/N=1 :entry:instrument:detector_FB:y_pixel_size = 0.84
1160       
1161
1162// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
1163        Make/O/D/N=1 :entry:instrument:detector_FL:pixel_num_x = 48     // == number of tubes
1164        Make/O/D/N=1 :entry:instrument:detector_FL:pixel_num_y = 128    // == pixels in vertical direction (was 256, John says likely will run @ 128 9/2015)
1165        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_x = 48     // == number of tubes
1166        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_y = 128    // == pixels in vertical direction
1167        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_x = 128    // == pixels in horizontal direction
1168        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_y = 48     // == number of tubes
1169        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_x = 128    // == pixels in horizontal direction
1170        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_y = 48     // == number of tubes
1171
1172
1173
1174// pixel beam center - HDF style
1175        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_x = 55           // == x beam center, in pixels
1176        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_y = 64           // == y beam center, in pixels
1177        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_x = -8   
1178        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_y = 64   
1179        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_x = 64   
1180        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_y = -8   
1181        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_x = 64   
1182        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_y = 55   
1183
1184
1185
1186///// MIDDLE DETECTOR BANKS
1187// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
1188// so keep them as variables
1189        Variable/G gMiddle_LR_w = 40.3                  //middle bank, nominal LR panel width (cm) 0.84cm/tube*48 = 40.3 cm
1190        Variable/G gMiddle_LR_h = 100.0
1191        Variable/G gMiddle_TB_w = 50.0
1192        Variable/G gMiddle_TB_h = 40.3
1193// SDD offset of T/B (decide on units??)
1194// for the Nexus file, the detector distance should already be corrected for the "setback"
1195// of the T/B panels. keep as VCALC variable
1196        Variable/G gMiddle_SDDsetback = 41.0                    // [cm]
1197       
1198// detector resolution (xy for each bank!)
1199        Make/O/D/N=1 :entry:instrument:detector_ML:x_pixel_size = 0.84          // (cm)         these tubes are vertical 8.4 mm x-spacing (JGB 2/2106)
1200        Make/O/D/N=1 :entry:instrument:detector_ML:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
1201        Make/O/D/N=1 :entry:instrument:detector_MR:x_pixel_size = 0.84
1202        Make/O/D/N=1 :entry:instrument:detector_MR:y_pixel_size = 0.8
1203        //T/B
1204        Make/O/D/N=1 :entry:instrument:detector_MT:x_pixel_size = 0.4           //these tubes are horizontal
1205        Make/O/D/N=1 :entry:instrument:detector_MT:y_pixel_size = 0.84
1206        Make/O/D/N=1 :entry:instrument:detector_MB:x_pixel_size = 0.4
1207        Make/O/D/N=1 :entry:instrument:detector_MB:y_pixel_size = 0.84
1208
1209
1210
1211// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
1212        Make/O/D/N=1 :entry:instrument:detector_ML:pixel_num_x = 48     // == number of tubes
1213        Make/O/D/N=1 :entry:instrument:detector_ML:pixel_num_y = 128    // == pixels in vertical direction (was 256, John says likely will run @ 128 9/2015)
1214        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_x = 48     // == number of tubes
1215        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_y = 128    // == pixels in vertical direction
1216        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_x = 128    // == pixels in horizontal direction
1217        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_y = 48     // == number of tubes
1218        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_x = 128    // == pixels in horizontal direction
1219        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_y = 48     // == number of tubes
1220       
1221
1222
1223// pixel beam center - HDF style
1224        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_x = 55           // == x beam center, in pixels
1225        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_y = 64           // == y beam center, in pixels
1226        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_x = -8   
1227        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_y = 64   
1228        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_x = 64   
1229        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_y = -8   
1230        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_x = 64   
1231        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_y = 55   
1232
1233
1234
1235
1236//// BACK DETECTOR
1237        Variable/G gBack_w = 22.2                               //w and h for the back detector [cm]
1238        Variable/G gBack_h = 50.4
1239       
1240       
1241        // TODOHIRES -- be sure that all of this is correct, since it is hard-wired values
1242        // -- can't use a switch so I'm using an if(), where the default is 4x4 binning
1243        if(root:Packages:NIST:VSANS:Globals:gHighResBinning == 1)
1244                Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.00845                // 340 micron resolution (units of [cm] here)
1245                Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.00845               
1246       
1247                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_x = 2720            // detector pixels in x-direction
1248                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_y = 6624
1249               
1250        // pixel beam center - HDF style
1251                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 1360.1        // == x beam center, in pixels +0.1 so I know it's from here
1252                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 3312.1                // == y beam center, in pixels
1253        else
1254                Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.034          // 340 micron resolution (units of [cm] here)
1255                Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.034         
1256       
1257                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_x = 680             // detector pixels in x-direction
1258                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_y = 1656
1259               
1260        // pixel beam center - HDF style
1261                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 340.1 // == x beam center, in pixels +0.1 so I know it's from here
1262                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 828.1         // == y beam center, in pixels
1263        endif
1264
1265
1266// Generate all of the waves used for the detector and the q values
1267//
1268// TODO: the detector dimensions need to be properly defined here...
1269// FRONT
1270//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
1271
1272        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
1273        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FL
1274        Duplicate/O det_FL qTot_FL,qx_FL,qy_FL,qz_FL
1275
1276        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
1277        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FR
1278        Duplicate/O det_FR qTot_FR,qx_FR,qy_FR,qz_FR
1279
1280        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
1281        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FT
1282        Duplicate/O det_FT qTot_FT,qx_FT,qy_FT,qz_FT
1283       
1284        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
1285        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FB
1286        Duplicate/O det_FB qTot_FB,qx_FB,qy_FB,qz_FB
1287
1288
1289//MIDDLE
1290// TODO: the detector dimensions need to be properly defined here...
1291//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
1292
1293        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
1294        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_ML
1295        Duplicate/O det_ML qTot_ML,qx_ML,qy_ML,qz_ML
1296       
1297        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
1298        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MR
1299        Duplicate/O det_MR qTot_MR,qx_MR,qy_MR,qz_MR
1300
1301        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
1302        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MT
1303        Duplicate/O det_MT qTot_MT,qx_MT,qy_MT,qz_MT
1304       
1305        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
1306        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MB
1307        Duplicate/O det_MB qTot_MB,qx_MB,qy_MB,qz_MB
1308
1309// BACK
1310// TODO: the detector dimensions need to be properly defined here...
1311//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Back
1312
1313        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
1314        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_B
1315        Duplicate/O det_B qTot_B,qx_B,qy_B,qz_B
1316
1317
1318////////////    FOR THE PANEL
1319
1320        SetDataFolder root:Packages:NIST:VSANS:VCALC
1321
1322        Make/O/D/N=2 fpx1,fpy1,mpx1,mpy1                // for display of the detector panels
1323        Make/O/D/N=2 fv_degX,fv_degY
1324
1325
1326// to fill in:
1327// values for always-visible items
1328        String/G gPresetPopStr = "F+M Ng0 Low Q;F+M Ng2 Mid Q;F+M Ng7 Mid Q;F+M Ng9 High Q;Converging Pinholes;Narrow Slit;White Beam;Graphite;Polarizer;"
1329        String/G gBinTypeStr = ksBinTypeStr
1330        Variable/G gBeamIntensity= 0
1331
1332        Variable/G gQmin_F,gQmax_F,gQmin_M,gQmax_M,gQmin_B,gQmax_B
1333        Variable/G gBeamDiam,gBeamStopDiam
1334        Variable/G gRealQMin
1335
1336// popup strings for each tab (then use the string in the panel)
1337// tab 0 - collimation
1338        String/G gMonochromatorType = "Velocity Selector;Graphite;White Beam;"
1339        String/G gSourceShape = "circular;rectangular;converging pinholes;"
1340        String/G gSourceDiam = "6.0 cm;"
1341        String/G gSourceDiam_0g = "0.75 cm;1.5 cm;3.0 cm;"              // values from John Mar 2018
1342        String/G gDeltaLambda = "0.12;"
1343       
1344// tab 1 - sample conditions
1345        String/G gTableLocation = "Changer;Stage;"
1346        String/G gSampleApertureShape = "circular;rectangular;converging pinholes;"
1347        String/G gSampleApertureDiam = "1.27;1.59;1.0;2.0;"
1348       
1349// tab 2
1350
1351// tab 3
1352
1353// tab 4 - back detector
1354        String/G gBackDetType = "1D;2D;"
1355
1356// tab 5
1357        String/G gModelFunctionType = "Debye;Sphere;Big Debye;Big Sphere;AgBeh;Vycor;Empty Cell;Blocked Beam;"
1358        gModelFunctionType += "Debye +;AgBeh +;Empty Cell +;"
1359
1360////////////////////
1361
1362
1363
1364// limits for detector travel? or are these limits part of the panel, hard-wired there
1365
1366
1367//      // for the panel
1368
1369//      Variable/G gNg=0
1370//      Variable/G gOffset=0
1371//      Variable/G gSamAp=1.27          //samAp diameter in cm
1372//      String/G gSourceApString = "1.43 cm;2.54 cm;3.81 cm;"
1373//      String/G gApPopStr = "1/16\";1/8\";3/16\";1/4\";5/16\";3/8\";7/16\";1/2\";9/16\";5/8\";11/16\";3/4\";other;"
1374//      Variable/G gSamApOther = 10             //non-standard aperture diameter, in mm
1375//      Variable/G gUsingLenses = 0             //0=no lenses, 1=lenses(or prisms)
1376//      Variable/G gModelOffsetFactor = 1
1377//     
1378//      // for the MC simulation
1379//      Variable/G doSimulation =0              // == 1 if 1D simulated data, 0 if other from the checkbox
1380//      Variable/G gRanDateTime=datetime
1381//      Variable/G gImon = 10000
1382//      Variable/G gThick = 0.1
1383//      Variable/G gSig_incoh = 0.1
1384//      String/G gFuncStr = ""
1385//      Variable/G gR2 = 2.54/2
1386//      Variable/G gSamTrans=0.8                        //for 1D, default value
1387//      Variable/G gCntTime = 300
1388//      Variable/G gDoMonteCarlo = 0
1389//      Variable/G gUse_MC_XOP = 1                              //set to zero to use Igor code
1390//      Variable/G gBeamStopIn = 1                      //set to zero for beamstop out (transmission)
1391//      Variable/G gRawCounts = 0
1392//      Variable/G gSaveIndex = 100
1393//      String/G gSavePrefix = "SIMUL"
1394//      Variable/G gAutoSaveIndex = 100                 //a way to set the index for automated saves
1395//      String/G gAutoSaveLabel = ""                            //a way to set the "sample" label for automated saves
1396//      Make/O/D/N=10 results = 0
1397//      Make/O/T/N=10 results_desc = {"total X-section (1/cm)","SAS X-section (1/cm)","number that scatter","number that reach detector","avg # times scattered","fraction single coherent","fraction multiple coherent","fraction multiple scattered","fraction transmitted","detector counts w/beamstop"}
1398//
1399//      Variable/G g_1DTotCts = 0                       //summed counts (simulated)
1400//      Variable/G g_1DEstDetCR = 0             // estimated detector count rate
1401//      Variable/G g_1DFracScatt = 0            // fraction of beam captured on detector
1402//      Variable/G g_1DEstTrans = 0             // estimated transmission of sample
1403//      Variable/G g_1D_DoABS = 1
1404//      Variable/G g_1D_AddNoise = 1
1405//      Variable/G g_MultScattFraction=0
1406//      Variable/G g_detectorEff=0.75                   //average value for most wavelengths
1407//      Variable/G g_actSimTime = 0                             //for the save
1408//      Variable/G g_SimTimeWarn = 10                   //manually set to a very large value for scripted operation
1409//     
1410
1411//     
1412//      //for the fake dependency
1413//      Variable/G gTouched=0
1414//      Variable/G gCalculate=0
1415//      //for plotting
1416//      Variable/G gFreezeCount=1               //start the count at 1 to keep Jeff happy
1417//      Variable/G gDoTraceOffset=0             // (1==Yes, offset 2^n), 0==turn off the offset
1418
1419//
1420// instrument - specific dimensions
1421//
1422
1423//     
1424//      Variable/G gInstrument = 6              // files (may) be tagged SA6 as the 6th SANS instrument
1425//      Variable/G gS12 = 54.8
1426//      Variable/G d_det = 0.5
1427//      Variable/G a_pixel = 0.5
1428//      Variable/G del_r = 0.5
1429//      Variable/G det_width = 64.0
1430//      Variable/G gLambda_t = 5.50
1431//      Variable/G gL2r_lower = 132.3
1432//      Variable/G gL2r_upper =  1317
1433//      Variable/G gLambda_lower = 2.5
1434//      Variable/G gLambda_upper = 20.0
1435//      Variable/G gD_upper = 25.0
1436//      Variable/G gBs_factor = 1.05
1437//      Variable/G gT1 = 0.63
1438//      Variable/G gT2 = 1.0
1439//      Variable/G gT3 = 0.75
1440//      Variable/G gL_gap = 100.0
1441//      Variable/G gGuide_width = 6.0
1442//      Variable/G gIdmax = 100.0
1443
1444//
1445//      //new values, from 11/2009 --- BeamFluxReport_2009.ifn
1446//      Variable/G gPhi_0 = 2.42e13
1447//      Variable/G gB = 0.0
1448//      Variable/G gC = -0.0243
1449//      Variable/G gGuide_loss = 0.924
1450//     
1451//      //fwhm values (new variables) (+3, 0, -3, calibrated 2009)
1452//      Variable/G gFwhm_narrow = 0.109
1453//      Variable/G gFwhm_mid = 0.125
1454//      Variable/G gFwhm_wide = 0.236
1455//     
1456//      //source apertures (cm)
1457//      Variable/G gA1_0_0 = 1.43
1458//      Variable/G gA1_0_1 = 2.54
1459//      Variable/G gA1_0_2 = 3.81
1460//      Variable/G gA1_7_0 = 2.5                        // after the polarizer         
1461//      Variable/G gA1_7_1 = 5.0
1462//      Variable/G gA1_7_1 = 0.95               //
1463//      Variable/G gA1_def = 5.00
1464//     
1465        SetDataFolder root:
1466end
1467
1468// set the global values for display
1469Function V_QMinMax_Back()
1470
1471        NVAR min_b = root:Packages:NIST:VSANS:VCALC:gQmin_B
1472        NVAR max_b = root:Packages:NIST:VSANS:VCALC:gQmax_B
1473
1474        String folderStr = "VCALC"
1475        String detStr = ""
1476
1477        String folderPath = "root:Packages:NIST:VSANS:"+folderStr
1478        String instPath = ":entry:instrument:detector_"
1479
1480        detStr = "B"
1481        WAVE qTot_B = $(folderPath+instPath+detStr+":qTot_"+detStr)
1482        WAVE mask_B = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1483
1484        Duplicate/O qTot_B tmp_B
1485        // for the minimum
1486        tmp_B = (mask_B == 0) ? qTot_B : 1e6
1487        min_b = WaveMin(tmp_B)
1488
1489        // for the maximum
1490        tmp_B = (mask_B == 0) ? qTot_B : -1e6
1491        max_b = WaveMax(tmp_B)
1492
1493        KillWaves/Z tmp_B
1494
1495        return(0)
1496end
1497
1498// set the global values for display
1499Function V_QMinMax_Middle()
1500
1501        NVAR min_m = root:Packages:NIST:VSANS:VCALC:gQmin_M
1502        NVAR max_m = root:Packages:NIST:VSANS:VCALC:gQmax_M
1503
1504        String folderStr = "VCALC"
1505        String detStr = ""
1506
1507        String folderPath = "root:Packages:NIST:VSANS:"+folderStr
1508        String instPath = ":entry:instrument:detector_"
1509
1510        detStr = "ML"
1511        WAVE qTot_ML = $(folderPath+instPath+detStr+":qTot_"+detStr)
1512        WAVE mask_ML = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1513
1514        detStr = "MR"
1515        WAVE qTot_MR = $(folderPath+instPath+detStr+":qTot_"+detStr)
1516        WAVE mask_MR = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1517
1518        detStr = "MT"
1519        WAVE qTot_MT = $(folderPath+instPath+detStr+":qTot_"+detStr)
1520        WAVE mask_MT = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1521
1522        detStr = "MB"
1523        WAVE qTot_MB = $(folderPath+instPath+detStr+":qTot_"+detStr)
1524        WAVE mask_MB = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1525
1526        Variable min1,min2,min3,min4
1527        Variable max1,max2,max3,max4
1528        // WaveMin(), WaveMax() will report NaN or inf
1529        // so for the min, set masked values to 1e6
1530        Duplicate/O qTot_ML tmp_ML
1531        tmp_ML = (mask_ML == 0) ? qTot_ML : 1e6
1532
1533        Duplicate/O qTot_MR tmp_MR
1534        tmp_MR = (mask_MR == 0) ? qTot_MR : 1e6
1535       
1536        Duplicate/O qTot_MT tmp_MT
1537        tmp_MT = (mask_MT == 0) ? qTot_MT : 1e6
1538       
1539        Duplicate/O qTot_MB tmp_MB
1540        tmp_MB = (mask_MB == 0) ? qTot_MB : 1e6
1541       
1542        min1 = WaveMin(tmp_ML)
1543        min2 = WaveMin(tmp_MR)
1544        min3 = WaveMin(tmp_MT)
1545        min4 = WaveMin(tmp_MB)
1546
1547        // so for the max, set masked values to -1e6
1548        tmp_ML = (mask_ML == 0) ? qTot_ML : -1e6
1549        tmp_MR = (mask_MR == 0) ? qTot_MR : -1e6
1550        tmp_MT = (mask_MT == 0) ? qTot_MT : -1e6
1551        tmp_MB = (mask_MB == 0) ? qTot_MB : -1e6
1552       
1553        max1 = WaveMax(tmp_ML)
1554        max2 = WaveMax(tmp_MR)
1555        max3 = WaveMax(tmp_MT)
1556        max4 = WaveMax(tmp_MB)
1557
1558//      print min1,min2,min3,min4
1559//      print max1,max2,max3,max4
1560               
1561        min_m = min(min1,min2,min3,min4)
1562        max_m = max(max1,max2,max3,max4)
1563
1564//      min_m = min(WaveMin(tmp_ML),WaveMin(tmp_MT),WaveMin(tmp_MR),WaveMin(tmp_MB))
1565//      max_m = max(WaveMax(tmp_ML),WaveMax(tmp_MT),WaveMax(tmp_MR),WaveMax(tmp_MB))
1566       
1567        KillWaves/Z tmp_ML,tmp_MR,tmp_MT,tmp_MB
1568
1569        return(0)
1570end
1571
1572// set the global values for display
1573Function V_QMinMax_Front()
1574
1575        NVAR min_f = root:Packages:NIST:VSANS:VCALC:gQmin_F
1576        NVAR max_f = root:Packages:NIST:VSANS:VCALC:gQmax_F
1577
1578        String folderStr = "VCALC"
1579        String detStr = ""
1580       
1581        String folderPath = "root:Packages:NIST:VSANS:"+folderStr
1582        String instPath = ":entry:instrument:detector_"
1583
1584        detStr = "FL"
1585        WAVE qTot_FL = $(folderPath+instPath+detStr+":qTot_"+detStr)
1586        WAVE mask_FL = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1587       
1588        detStr = "FR"
1589        WAVE qTot_FR = $(folderPath+instPath+detStr+":qTot_"+detStr)
1590        WAVE mask_FR = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1591
1592        detStr = "FT"
1593        WAVE qTot_FT = $(folderPath+instPath+detStr+":qTot_"+detStr)
1594        WAVE mask_FT = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1595
1596        detStr = "FB"
1597        WAVE qTot_FB = $(folderPath+instPath+detStr+":qTot_"+detStr)
1598        WAVE mask_FB = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1599
1600        Variable min1,min2,min3,min4
1601        Variable max1,max2,max3,max4
1602        // WaveMin(), WaveMax() will report NaN or inf
1603        // so for the min, set masked values to 1e6
1604        Duplicate/O qTot_FL tmp_FL
1605        tmp_FL = (mask_FL == 0) ? qTot_FL : 1e6
1606
1607        Duplicate/O qTot_FR tmp_FR
1608        tmp_FR = (mask_FR == 0) ? qTot_FR : 1e6
1609       
1610        Duplicate/O qTot_FT tmp_FT
1611        tmp_FT = (mask_FT == 0) ? qTot_FT : 1e6
1612       
1613        Duplicate/O qTot_FB tmp_FB
1614        tmp_FB = (mask_FB == 0) ? qTot_FB : 1e6
1615
1616        min1 = WaveMin(tmp_FL)
1617        min2 = WaveMin(tmp_FR)
1618        min3 = WaveMin(tmp_FT)
1619        min4 = WaveMin(tmp_FB)
1620       
1621        // so for the max, set masked values to -1e6
1622        tmp_FL = (mask_FL == 0) ? qTot_FL : -1e6
1623        tmp_FR = (mask_FR == 0) ? qTot_FR : -1e6
1624        tmp_FT = (mask_FT == 0) ? qTot_FT : -1e6
1625        tmp_FB = (mask_FB == 0) ? qTot_FB : -1e6
1626
1627
1628        max1 = WaveMax(tmp_FL)
1629        max2 = WaveMax(tmp_FR)
1630        max3 = WaveMax(tmp_FT)
1631        max4 = WaveMax(tmp_FB)
1632
1633//      print min1,min2,min3,min4
1634//      print max1,max2,max3,max4
1635               
1636        min_f = min(min1,min2,min3,min4)
1637        max_f = max(max1,max2,max3,max4)
1638       
1639//      min_f = min(WaveMin(tmp_FL),WaveMin(tmp_FT),WaveMin(tmp_FR),WaveMin(tmp_FB))
1640//      max_f = max(WaveMax(tmp_FL),WaveMax(tmp_FT),WaveMax(tmp_FR),WaveMax(tmp_FB))
1641
1642        KillWaves/Z tmp_FL,tmp_FR,tmp_FT,tmp_FB
1643        return(0)
1644end
1645
1646Function V_QMin_withBeamStop(detStr)
1647        String detStr
1648       
1649        NVAR val = root:Packages:NIST:VSANS:VCALC:gRealQMin
1650
1651        Variable BSDiam,SDD,two_theta,lambda,qMin
1652
1653        BSDiam = VC_beamstopDiam(detStr)
1654        SDD = VC_getSDD(detStr)
1655        lambda = VCALC_getWavelength()
1656       
1657        two_theta = atan(BSDiam/2/SDD)
1658        qMin = 4*pi/lambda*sin(two_theta/2)
1659               
1660        val = qMin
1661       
1662        return(0)
1663End
1664
1665
1666Function V_BeamDiamDisplay(direction, detStr)
1667        String direction
1668        String detStr
1669       
1670        NVAR val = root:Packages:NIST:VSANS:VCALC:gBeamDiam
1671
1672        val = VC_beamDiameter(direction, detStr)                //middle carriage, maximum extent, includes gravity
1673
1674        return(0)
1675End
1676
1677
1678// carrNum 1=front, 2=middle, 3=back
1679Function V_BeamStopDiamDisplay(detStr)
1680        String detStr
1681
1682        NVAR val = root:Packages:NIST:VSANS:VCALC:gBeamStopDiam
1683
1684        val = VC_beamstopDiam(detStr)/2.54              //return the value in inches
1685
1686        return(0)
1687End
1688       
1689               
1690       
Note: See TracBrowser for help on using the repository browser.