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

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

cosmetic changes to VCALC

changed the patch routine for guides to accept "CONV_BEAMS", etc. to properly fill in the collimation to be recognized for resolution calculations.

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