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

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

multiple changes to improve the functionality of VCALC

more values are reported, and the IQ plot now accounts for a beam stop shadowing the low q region. Qmin and qmax values are reported for each panel. the beam intensity value is more realistic, with correct SSD values.

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