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

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

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

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