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

Last change on this file since 1245 was 1245, checked in by srkline, 2 years ago

another test commit after re-setup on the laptop

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