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

Last change on this file since 1092 was 1092, checked in by srkline, 5 years ago

added a few corrections to the reduction:

Added sample apertures to the patch panel so that they can be corrected

A flag is now written to the data files if the "flip" has been done, and it will refuse to flip again. This flag can be reset if something goes wrong.

Multiple reduce now allows run numbers to be entered as is for SANS,

Filtering of files for the protocol panel should be better behaved now.

File size: 33.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                // 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={444,180},title="Setup"
66        TabControl Vtab,labelBack=(45000,61000,58000),pos={14,215},size={430,426},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
74        PopupMenu popup_b,pos={690,310},size={142,20},title="Binning type",proc=VC_RebinIQ_PopProc
75        PopupMenu popup_b,mode=1,value= root:Packages:NIST:VSANS:VCALC:gBinTypeStr
76       
77        SetVariable setVar_a,pos={476,26},size={120,15},title="axis degrees",proc=FrontView_Range_SetVarProc
78        SetVariable setVar_a,limits={0.3,30,0.2},value=_NUM:20
79
80        // for panels (in degrees)     
81        Display/W=(476,45,757,303)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
82        RenameWindow #,FrontView
83        ModifyGraph mode=2              // mode = 2 = dots
84        ModifyGraph marker=19
85        ModifyGraph rgb=(0,0,0)
86        ModifyGraph tick=2,mirror=1
87        Label left "degrees"
88        Label bottom "degrees" 
89        SetActiveSubwindow ##
90
91
92        // for side view
93        Display/W=(842,25,1200,170)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
94        RenameWindow #,SideView
95        ModifyGraph mode=2              // mode = 2 = dots
96        ModifyGraph marker=19
97        ModifyGraph rgb=(0,0,0)
98        ModifyGraph tick=2,mirror=1
99        Label left "Vertical position (mm)"
100        Label bottom "SDD (m)" 
101        SetActiveSubwindow ##   
102       
103        // for top view
104        Display/W=(842,180,1200,325)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
105        RenameWindow #,TopView
106        ModifyGraph mode=2              // mode = 2 = dots
107        ModifyGraph marker=19
108        ModifyGraph rgb=(0,0,0)
109        ModifyGraph tick=2,mirror=1
110        Label left "Horizontal position (mm)"
111        Label bottom "SDD (m)" 
112        SetActiveSubwindow ##   
113
114        // for panels (as 2D Q)
115        Display/W=(475,332,814,631)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
116        RenameWindow #,Panels_Q
117        ModifyGraph mode=2              // mode = 2 = dots
118        ModifyGraph tick=2,mirror=1,grid=2,standoff=0
119        ModifyGraph width={Aspect,1},height={Aspect,1},gbRGB=(56797,56797,56797)
120        SetAxis left -0.2,0.2
121        SetAxis bottom -0.2,0.2
122        Label left "Qy"
123        Label bottom "Qx"       
124        SetActiveSubwindow ##
125
126        SetVariable setVar_b,pos={476,314},size={120,15},title="axis Q",proc=Front2DQ_Range_SetVarProc
127        SetVariable setVar_b,limits={0.02,1,0.02},value=_NUM:0.3
128        CheckBox check_0a title="Log?",size={60,20},pos={619,313},proc=Front2DQ_Log_CheckProc
129
130        // for averaged I(Q)
131        Display/W=(842,334,1204,629)/HOST=# //root:Packages:NIST:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
132        RenameWindow #,Panels_IQ
133//      ModifyGraph mode=2              // mode = 2 = dots
134        ModifyGraph tick=2,mirror=1,grid=2
135//      Label left "Intensity"
136//      Label bottom "Q"       
137        SetActiveSubwindow ##
138
139
140       
141// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter indexing items on tab
142
143       
144// tab(0), collimation - initially visible
145        Slider VCALCCtrl_0a,pos={223,324},size={200,45},limits={0,10,1},value= 1,vert= 0
146        SetVariable VCALCCtrl_0b,pos={25,294},size={120,15},title="wavelength"
147        SetVariable VCALCCtrl_0b,limits={4,20,1},value=_NUM:8,proc=VC_Lambda_SetVarProc
148        PopupMenu VCALCCtrl_0c,pos={26,257},size={150,20},title="monochromator"
149        PopupMenu VCALCCtrl_0c,mode=1,popvalue="Velocity Selector",value= root:Packages:NIST:VSANS:VCALC:gMonochromatorType
150        PopupMenu VCALCCtrl_0d,pos={26,321},size={115,20},title="delta lambda"
151        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.10",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
152        PopupMenu VCALCCtrl_0e,pos={291,262},size={132,20},title="source shape"
153        PopupMenu VCALCCtrl_0e,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSourceShape
154        PopupMenu VCALCCtrl_0f,pos={283,293},size={141,20},title="source aperture"
155        PopupMenu VCALCCtrl_0f,mode=1,popvalue="1.0 cm",value= root:Packages:NIST:VSANS:VCALC:gSourceDiam
156       
157
158// tab(1) - Sample conditions, initially not visible
159        PopupMenu VCALCCtrl_1a,pos={38,270},size={142,20},title="table location",disable=1
160        PopupMenu VCALCCtrl_1a,mode=1,popvalue="Changer",value= root:Packages:NIST:VSANS:VCALC:gTableLocation
161        PopupMenu VCALCCtrl_1b,pos={270,270},size={115,20},title="Aperture Shape",disable=1
162        PopupMenu VCALCCtrl_1b,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureShape
163        PopupMenu VCALCCtrl_1c,pos={270,330},size={132,20},title="Aperture Size (cm)",disable=1
164        PopupMenu VCALCCtrl_1c,mode=1,popvalue="0.5",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureDiam
165       
166
167// tab(2) - Front detector panels, initially not visible
168        SetVariable VCALCCtrl_2a,pos={30,260},size={150,15},title="LEFT Offset (cm)",proc=VC_FDet_LR_SetVarProc
169        SetVariable VCALCCtrl_2a,limits={-20,19,0.1},disable=1,value=_NUM:-10
170        SetVariable VCALCCtrl_2aa,pos={30,290},size={150,15},title="RIGHT Offset (cm)",proc=VC_FDet_LR_SetVarProc
171        SetVariable VCALCCtrl_2aa,limits={-19,20,0.1},disable=1,value=_NUM:10
172       
173        SetVariable VCALCCtrl_2b,pos={30,330},size={150,15},title="TOP Offset (cm)",proc=VC_FDet_LR_SetVarProc
174        SetVariable VCALCCtrl_2b,limits={0,18,0.1},disable=1,value=_NUM:10
175        SetVariable VCALCCtrl_2bb,pos={30,360},size={150,15},title="BOTTOM Offset (cm)",proc=VC_FDet_LR_SetVarProc
176        SetVariable VCALCCtrl_2bb,limits={-18,0,0.1},disable=1,value=_NUM:-10
177       
178        SetVariable VCALCCtrl_2d,pos={205,260},size={230,15},title="Sample to Detector Distance (cm)",proc=VC_FDet_SDD_SetVarProc
179        SetVariable VCALCCtrl_2d,limits={100,800,1},disable=1   ,value=_NUM:150
180       
181
182// tab(3) - Middle detector panels, initially not visible
183        SetVariable VCALCCtrl_3a,pos={30,260},size={150,15},title="LEFT Offset (cm)",proc=VC_MDet_LR_SetVarProc
184        SetVariable VCALCCtrl_3a,limits={-20,19,0.1},disable=1,value=_NUM:-6
185        SetVariable VCALCCtrl_3aa,pos={30,290},size={150,15},title="RIGHT Offset (cm)",proc=VC_MDet_LR_SetVarProc
186        SetVariable VCALCCtrl_3aa,limits={-19,20,0.1},disable=1,value=_NUM:6
187               
188        SetVariable VCALCCtrl_3b,pos={30,330},size={150,15},title="TOP Offset (cm)",proc=VC_MDet_LR_SetVarProc
189        SetVariable VCALCCtrl_3b,limits={0,18,0.1},disable=1,value=_NUM:6
190        SetVariable VCALCCtrl_3bb,pos={30,360},size={150,15},title="BOTTOM Offset (cm)",proc=VC_MDet_LR_SetVarProc
191        SetVariable VCALCCtrl_3bb,limits={-18,0,0.1},disable=1,value=_NUM:-6
192
193        SetVariable VCALCCtrl_3d,pos={205,260},size={230,15},title="Sample to Detector Distance (cm)",proc=VC_MDet_SDD_SetVarProc
194        SetVariable VCALCCtrl_3d,limits={800,2000,1},disable=1,value=_NUM:1500
195
196       
197// tab(4) - Back detector panel
198        SetVariable VCALCCtrl_4a,pos={188,290},size={150,15},title="Lateral Offset (cm)"
199        SetVariable VCALCCtrl_4a,limits={0,20,0.1},disable=1,value=_NUM:0
200        SetVariable VCALCCtrl_4b,pos={188,260},size={230,15},title="Sample to Detector Distance (cm)",proc=VC_BDet_SDD_SetVarProc
201        SetVariable VCALCCtrl_4b,limits={2000,2500,1},disable=1,value=_NUM:2000
202//      PopupMenu VCALCCtrl_4c,pos={40,260},size={180,20},title="Detector type",disable=1
203//      PopupMenu VCALCCtrl_4c,mode=1,popvalue="2D",value= root:Packages:NIST:VSANS:VCALC:gBackDetType
204
205// tab(5) - Simulation setup
206        SetVariable VCALCCtrl_5a,pos={40,290},size={200,15},title="Neutrons on Sample (imon)"
207        SetVariable VCALCCtrl_5a,limits={1e7,1e15,1e7},disable=1,value=_NUM:1e10,proc=VC_SimImon_SetVarProc
208        PopupMenu VCALCCtrl_5b,pos={40,260},size={180,20},title="Model Function",disable=1
209        PopupMenu VCALCCtrl_5b,mode=1,popvalue="Debye",value= root:Packages:NIST:VSANS:VCALC:gModelFunctionType,proc=VC_SimModelFunc_PopProc
210       
211End
212
213//
214// just recalculates the detector panels, doesn't adjust the views
215//
216Function Recalculate_AllDetectors()
217
218        fPlotBackPanels()
219        fPlotMiddlePanels()
220        fPlotFrontPanels()
221
222        return(0)
223End
224
225// function to control the drawing of controls in the TabControl on the main panel
226// Naming scheme for the controls MUST be strictly adhered to... else controls will
227// appear in odd places...
228// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter denoting
229// the controls position on that particular tab.
230// in this way, they will always be drawn correctly..
231//
232//
233// -- this will need to be modified to allow for the graph to be drawn of the detector bank positions
234//     if that is individual to each tab - or if it's  always visible - that's still to be decided.
235//
236//
237Function VCALCTabProc(name,tab)
238        String name
239        Variable tab
240       
241//      Print "name,number",name,tab
242        String ctrlList = ControlNameList("",";"),item="",nameStr=""
243        Variable num = ItemsinList(ctrlList,";"),ii,onTab
244        for(ii=0;ii<num;ii+=1)
245                //items all start w/"VCALCCtrl_", 10 characters
246                item=StringFromList(ii, ctrlList ,";")
247                nameStr=item[0,9]
248                if(cmpstr(nameStr,"VCALCCtrl_")==0)
249                        onTab = str2num(item[10])                       //[10] is a number
250                        ControlInfo $item
251                        switch(abs(V_flag))     
252                                case 1:
253                                        Button $item,disable=(tab!=onTab)
254                                        break
255                                case 2:
256                                        CheckBox $item,disable=(tab!=onTab)
257                                        break
258                                case 3:
259                                        PopupMenu $item,disable=(tab!=onTab)
260                                        break
261                                case 4:
262                                        ValDisplay $item,disable=(tab!=onTab)
263                                        break
264                                case 5:
265                                        SetVariable $item,disable=(tab!=onTab)
266                                        break
267                                case 7:
268                                        Slider $item,disable=(tab!=onTab)
269                                        break
270                                case 9:
271                                        GroupBox $item,disable=(tab!=onTab)
272                                        break
273                                case 10:       
274                                        TitleBox $item,disable=(tab!=onTab)
275                                        break
276                                // add more items to the switch if different control types are used
277                        endswitch
278                endif
279        endfor
280       
281
282       
283        return(0)
284End
285
286Function Front2DQ_Log_CheckProc(cba) : CheckBoxControl
287        STRUCT WMCheckboxAction &cba
288
289        switch( cba.eventCode )
290                case 2: // mouse up
291                        Variable checked = cba.checked
292                       
293                        Execute "FrontPanels_AsQ()"
294                        Execute "MiddlePanels_AsQ()"
295                        Execute "BackPanels_AsQ()"
296                       
297                        break
298                case -1: // control being killed
299                        break
300        endswitch
301
302        return 0
303End
304
305//
306// recalculate the detectors with a preset model function
307//
308Function VC_SimModelFunc_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
309        String ctrlName
310        Variable popNum // which item is currently selected (1-based)
311        String popStr           // contents of current popup item as string
312
313        Recalculate_AllDetectors()
314       
315        return(0)       
316End
317
318
319//
320// recalculate the I(q) binning. no need to adjust model function or views
321// just rebin
322//
323// this is for the VCALC 1-D plot subwindow only. so it is set up to
324// operate on that window - but uses the same binning and plotting routines
325// as the regualr VSANS data display
326//
327Function VC_RebinIQ_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
328        String ctrlName
329        Variable popNum // which item is currently selected (1-based)
330        String popStr           // contents of current popup item as string
331
332
333        String type = "VCALC"
334        String str,winStr="VCALC#Panels_IQ",workTypeStr
335        workTypeStr = "root:Packages:NIST:VSANS:"+type
336       
337// dispatch based on the string, not on the number of selection in the pop string
338        V_QBinAllPanels_Circular(type,V_BinTypeStr2Num(popStr))
339       
340        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr
341
342        Execute ("V_Back_IQ_Graph"+str)
343        Execute ("V_Middle_IQ_Graph"+str)
344        Execute ("V_Front_IQ_Graph"+str)
345
346// OLD - do not use
347//      // do the q-binning for front panels to get I(Q)
348//      Execute "BinAllFrontPanels()"
349//      Execute "Front_IQ_Graph()"
350//
351//      // do the q-binning for middle panels to get I(Q)
352//      Execute "BinAllMiddlePanels()"
353//      Execute "Middle_IQ_Graph()"
354//     
355//      // do the q-binning for the back panel to get I(Q)
356//      Execute "BinAllBackPanels()"
357//      Execute "Back_IQ_Graph()"
358//     
359        return(0)       
360End
361
362
363
364       
365       
366//
367// setVar for the wavelength
368//
369Function VC_Lambda_SetVarProc(sva) : SetVariableControl
370        STRUCT WMSetVariableAction &sva
371
372        switch( sva.eventCode )
373                case 1: // mouse up
374                case 2: // Enter key
375                case 3: // Live update
376                        Variable dval = sva.dval
377                        String sval = sva.sval
378                       
379//                      // don't need to recalculate the views, but need to recalculate the detectors
380//                      fPlotBackPanels()
381//                      fPlotMiddlePanels()
382//                      fPlotFrontPanels()
383
384                        Recalculate_AllDetectors()             
385                               
386                        break
387                case -1: // control being killed
388                        break
389        endswitch
390
391        return 0
392End
393
394//
395// setVar for the simulation monitor count
396//
397Function VC_SimImon_SetVarProc(sva) : SetVariableControl
398        STRUCT WMSetVariableAction &sva
399
400        switch( sva.eventCode )
401                case 1: // mouse up
402                case 2: // Enter key
403                case 3: // Live update
404                        Variable dval = sva.dval
405                        String sval = sva.sval
406
407                        Recalculate_AllDetectors()             
408                               
409                        break
410                case -1: // control being killed
411                        break
412        endswitch
413
414        return 0
415End
416
417
418// setVar for the range (in degrees) for the FrontView plot of the detectors
419//
420Function FrontView_Range_SetVarProc(sva) : SetVariableControl
421        STRUCT WMSetVariableAction &sva
422
423        switch( sva.eventCode )
424                case 1: // mouse up
425                case 2: // Enter key
426                case 3: // Live update
427                        Variable dval = sva.dval
428                        String sval = sva.sval
429                       
430                        FrontView_1x()
431                       
432                        break
433                case -1: // control being killed
434                        break
435        endswitch
436
437        return 0
438End
439
440// setVar for the range (in Q) for the FrontView plot of the detectors
441//
442// TODO: this assumes that everything (the data) is already updated - this only updates the plot range
443Function Front2DQ_Range_SetVarProc(sva) : SetVariableControl
444        STRUCT WMSetVariableAction &sva
445
446        switch( sva.eventCode )
447                case 1: // mouse up
448                case 2: // Enter key
449                case 3: // Live update
450                        Variable dval = sva.dval
451                        String sval = sva.sval
452                       
453                        SetAxis/W=VCALC#Panels_Q left -dval,dval
454                        SetAxis/W=VCALC#Panels_Q bottom -dval,dval
455                       
456//                      FrontPanels_AsQ()
457                       
458                        break
459                case -1: // control being killed
460                        break
461        endswitch
462
463        return 0
464End
465
466// SDD for the Front detector. triggers a recalculation
467// of the intensity and a redraw of the banks
468//
469Function VC_FDet_SDD_SetVarProc(sva) : SetVariableControl
470        STRUCT WMSetVariableAction &sva
471
472        switch( sva.eventCode )
473                case 1: // mouse up
474                case 2: // Enter key
475                case 3: // Live update
476                        Variable dval = sva.dval
477                        String sval = sva.sval
478                       
479//                      Variable LR_sep,TB_sep
480//                      // don't know if LR or TB called, so get the explicit values
481//                      //
482//                      ControlInfo VCALCCtrl_2a
483//                      LR_sep = V_Value
484//                      ControlInfo VCALCCtrl_2b
485//                      TB_sep = V_Value
486//                     
487//                      UpdateFrontDetector(LR_sep,TB_sep)
488                       
489                        UpdateSideView()
490                        UpdateTopView()
491                        FrontView_1x()
492                       
493                        fPlotFrontPanels()
494                       
495                        break
496                case -1: // control being killed
497                        break
498        endswitch
499
500        return 0
501End
502
503// SDD for the Middle detector. triggers a recalculation
504// of the intensity and a redraw of the banks
505//
506Function VC_MDet_SDD_SetVarProc(sva) : SetVariableControl
507        STRUCT WMSetVariableAction &sva
508
509        switch( sva.eventCode )
510                case 1: // mouse up
511                case 2: // Enter key
512                case 3: // Live update
513                        Variable dval = sva.dval
514                        String sval = sva.sval
515                       
516//                      Variable LR_sep,TB_sep
517//                      // don't know if LR or TB called, so get the explicit values
518//                      //
519//                      ControlInfo VCALCCtrl_2a
520//                      LR_sep = V_Value
521//                      ControlInfo VCALCCtrl_2b
522//                      TB_sep = V_Value
523//                     
524//                      UpdateFrontDetector(LR_sep,TB_sep)
525                       
526                        UpdateSideView()
527                        UpdateTopView()
528                        FrontView_1x()
529                       
530                        fPlotMiddlePanels()
531                       
532                        break
533                case -1: // control being killed
534                        break
535        endswitch
536
537        return 0
538End
539
540// SDD for the Back detector. triggers a recalculation
541// of the intensity and a redraw of the banks
542//
543Function VC_BDet_SDD_SetVarProc(sva) : SetVariableControl
544        STRUCT WMSetVariableAction &sva
545
546        switch( sva.eventCode )
547                case 1: // mouse up
548                case 2: // Enter key
549                case 3: // Live update
550                        Variable dval = sva.dval
551                        String sval = sva.sval
552                       
553//                      Variable LR_sep,TB_sep
554//                      // don't know if LR or TB called, so get the explicit values
555//                      //
556//                      ControlInfo VCALCCtrl_2a
557//                      LR_sep = V_Value
558//                      ControlInfo VCALCCtrl_2b
559//                      TB_sep = V_Value
560//                     
561//                      UpdateFrontDetector(LR_sep,TB_sep)
562                       
563                        UpdateSideView()
564                        UpdateTopView()
565                        FrontView_1x()
566                       
567                        fPlotBackPanels()
568                       
569                        break
570                case -1: // control being killed
571                        break
572        endswitch
573
574        return 0
575End
576
577// separation, either LR or TB of the front detector. triggers a recalculation
578// of the intensity and a redraw of the banks
579//
580Function VC_FDet_LR_SetVarProc(sva) : SetVariableControl
581        STRUCT WMSetVariableAction &sva
582
583        switch( sva.eventCode )
584                case 1: // mouse up
585                case 2: // Enter key
586                case 3: // Live update
587                        Variable dval = sva.dval
588                        String sval = sva.sval
589                       
590//                      Variable LR_sep,TB_sep
591//                      // don't know if LR or TB called, so get the explicit values
592//                      //
593//                      ControlInfo VCALCCtrl_2a
594//                      LR_sep = V_Value
595//                      ControlInfo VCALCCtrl_2b
596//                      TB_sep = V_Value
597//                     
598//                      UpdateFrontDetector(LR_sep,TB_sep)
599                       
600                        UpdateSideView()
601                        UpdateTopView()
602                        FrontView_1x()
603                       
604                        fPlotFrontPanels()
605                       
606                        break
607                case -1: // control being killed
608                        break
609        endswitch
610
611        return 0
612End
613
614
615// separation, either LR or TB of the middle detector. triggers a recalculation
616// of the intensity and a redraw of the banks
617//
618Function VC_MDet_LR_SetVarProc(sva) : SetVariableControl
619        STRUCT WMSetVariableAction &sva
620
621        switch( sva.eventCode )
622                case 1: // mouse up
623                case 2: // Enter key
624                case 3: // Live update
625                        Variable dval = sva.dval
626                        String sval = sva.sval
627                       
628//                      Variable LR_sep,TB_sep
629//                      // don't know if LR or TB called, so get the explicit values
630//                      //
631//                      ControlInfo VCALCCtrl_3a
632//                      LR_sep = V_Value
633//                      ControlInfo VCALCCtrl_3b
634//                      TB_sep = V_Value
635                       
636//                      UpdateMiddleDetector(LR_sep,TB_sep)
637                       
638                        UpdateSideView()
639                        UpdateTopView()
640                        FrontView_1x()
641                       
642                        fPlotMiddlePanels()
643                       
644                        break
645                case -1: // control being killed
646                        break
647        endswitch
648
649        return 0
650End
651
652
653
654
655// this all needs to be fixed and updated - it is all pertinent to SANS (SASCALC)
656// and not yet specific to VSANS
657//
658// -- all of the simulation stuff will need to be re-thought
659// -- all of the integersRead, data, etc. will need to be re-thought...
660// -- but the space needs to be allocated.
661// -- parameters and constants need to be defined in their own space
662//
663// FEB 2016 -- changed the data folder space to mimic the HDF folder structure
664// so that the averaging routines could be re-used (along with everything else)
665// -- painful, but better in the long run
666//
667// -- I have not re-named the detector arrays to all be "data" since that is very difficult to
668//   deal with on images. Added a global "gVCALC_Active" as a crude workaround as needed. Turn it
669//   on when needed and then immediately off
670//
671Proc VC_Initialize_Space()
672//
673        NewDataFolder/O root:Packages
674        NewDataFolder/O root:Packages:NIST
675        NewDataFolder/O root:Packages:NIST:VSANS
676        NewDataFolder/O root:Packages:NIST:VSANS:VCALC
677        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry
678        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument
679        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
680        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
681        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
682        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
683        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
684        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
685        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
686        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
687        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
688
689//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front
690//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Middle
691//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Back
692
693        NewDataFolder/O root:Packages:NIST:VSANS:RawVSANS
694       
695        Variable/G root:Packages:NIST:VSANS:VCALC:gVCALC_Active = 1
696        Variable/G root:Packages:NIST:VSANS:VCALC:gUseNonLinearDet = 0          //if == 1, use RAW non-linear corrections
697       
698        SetDataFolder root:Packages:NIST:VSANS:VCALC
699       
700
701///// FRONT DETECTOR BANKS
702// dimensions for the detector banks (then get them in the drawing functions)
703// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
704// so keep them as variables
705        Variable/G gFront_LR_w = 38.4           //front bank, nominal LR panel width [cm]
706        Variable/G gFront_LR_h = 100.0
707        Variable/G gFront_TB_w = 50.0
708        Variable/G gFront_TB_h = 38.4
709
710// SDD setback of T/B (decide on units??)
711// for the Nexus file, the detector distance should already be corrected for the "setback"
712// of the T/B panels. keep as VCALC variable
713        Variable/G gFront_SDDsetback = 41.0                     // [cm]
714       
715       
716// detector resolution (xy for each bank!)
717        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)
718        Make/O/D/N=1 :entry:instrument:detector_FL:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
719        Make/O/D/N=1 :entry:instrument:detector_FR:x_pixel_size = 0.84
720        Make/O/D/N=1 :entry:instrument:detector_FR:y_pixel_size = 0.8
721        //T/B
722        Make/O/D/N=1 :entry:instrument:detector_FT:x_pixel_size = 0.4           //these tubes are horizontal
723        Make/O/D/N=1 :entry:instrument:detector_FT:y_pixel_size = 0.84
724        Make/O/D/N=1 :entry:instrument:detector_FB:x_pixel_size = 0.4
725        Make/O/D/N=1 :entry:instrument:detector_FB:y_pixel_size = 0.84
726       
727
728// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
729        Make/O/D/N=1 :entry:instrument:detector_FL:pixel_num_x = 48     // == number of tubes
730        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)
731        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_x = 48     // == number of tubes
732        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_y = 128    // == pixels in vertical direction
733        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_x = 128    // == pixels in horizontal direction
734        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_y = 48     // == number of tubes
735        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_x = 128    // == pixels in horizontal direction
736        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_y = 48     // == number of tubes
737
738
739
740// pixel beam center - HDF style
741        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_x = 55           // == x beam center, in pixels
742        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_y = 64           // == y beam center, in pixels
743        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_x = -8   
744        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_y = 64   
745        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_x = 64   
746        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_y = -8   
747        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_x = 64   
748        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_y = 55   
749
750
751
752///// MIDDLE DETECTOR BANKS
753// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
754// so keep them as variables
755        Variable/G gMiddle_LR_w = 38.4          //middle bank, nominal LR panel width (cm)
756        Variable/G gMiddle_LR_h = 100.0
757        Variable/G gMiddle_TB_w = 50.0
758        Variable/G gMiddle_TB_h = 38.4
759// SDD offset of T/B (decide on units??)
760// for the Nexus file, the detector distance should already be corrected for the "setback"
761// of the T/B panels. keep as VCALC variable
762        Variable/G gMiddle_SDDsetback = 41.0                    // [cm]
763       
764// detector resolution (xy for each bank!)
765        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)
766        Make/O/D/N=1 :entry:instrument:detector_ML:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
767        Make/O/D/N=1 :entry:instrument:detector_MR:x_pixel_size = 0.84
768        Make/O/D/N=1 :entry:instrument:detector_MR:y_pixel_size = 0.8
769        //T/B
770        Make/O/D/N=1 :entry:instrument:detector_MT:x_pixel_size = 0.4           //these tubes are horizontal
771        Make/O/D/N=1 :entry:instrument:detector_MT:y_pixel_size = 0.84
772        Make/O/D/N=1 :entry:instrument:detector_MB:x_pixel_size = 0.4
773        Make/O/D/N=1 :entry:instrument:detector_MB:y_pixel_size = 0.84
774
775
776
777// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
778        Make/O/D/N=1 :entry:instrument:detector_ML:pixel_num_x = 48     // == number of tubes
779        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)
780        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_x = 48     // == number of tubes
781        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_y = 128    // == pixels in vertical direction
782        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_x = 128    // == pixels in horizontal direction
783        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_y = 48     // == number of tubes
784        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_x = 128    // == pixels in horizontal direction
785        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_y = 48     // == number of tubes
786       
787
788
789// pixel beam center - HDF style
790        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_x = 55           // == x beam center, in pixels
791        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_y = 64           // == y beam center, in pixels
792        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_x = -8   
793        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_y = 64   
794        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_x = 64   
795        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_y = -8   
796        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_x = 64   
797        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_y = 55   
798
799
800
801
802//// BACK DETECTOR
803        Variable/G gBack_w = 15.0                               //w and h for the back detector, (cm) 150 pix * 1mm/pix
804        Variable/G gBack_h = 15.0
805       
806        Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.1            // 1 mm resolution (units of cm here)
807        Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.1           
808
809
810        Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_x = 150     // detector pixels in x-direction
811        Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_y = 150
812       
813
814// pixel beam center - HDF style
815        Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 75            // == x beam center, in pixels
816        Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 75            // == y beam center, in pixels
817
818
819// Generate all of the waves used for the detector and the q values
820//
821// TODO: the detector dimensions need to be properly defined here...
822// FRONT
823//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
824
825        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
826        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FL
827        Duplicate/O det_FL qTot_FL,qx_FL,qy_FL,qz_FL
828
829        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
830        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FR
831        Duplicate/O det_FR qTot_FR,qx_FR,qy_FR,qz_FR
832
833        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
834        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FT
835        Duplicate/O det_FT qTot_FT,qx_FT,qy_FT,qz_FT
836       
837        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
838        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FB
839        Duplicate/O det_FB qTot_FB,qx_FB,qy_FB,qz_FB
840
841
842//MIDDLE
843// TODO: the detector dimensions need to be properly defined here...
844//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
845
846        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
847        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_ML
848        Duplicate/O det_ML qTot_ML,qx_ML,qy_ML,qz_ML
849       
850        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
851        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MR
852        Duplicate/O det_MR qTot_MR,qx_MR,qy_MR,qz_MR
853
854        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
855        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MT
856        Duplicate/O det_MT qTot_MT,qx_MT,qy_MT,qz_MT
857       
858        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
859        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MB
860        Duplicate/O det_MB qTot_MB,qx_MB,qy_MB,qz_MB
861
862// BACK
863// TODO: the detector dimensions need to be properly defined here...
864//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Back
865
866        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
867        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_B
868        Duplicate/O det_B qTot_B,qx_B,qy_B,qz_B
869
870
871////////////    FOR THE PANEL
872
873        SetDataFolder root:Packages:NIST:VSANS:VCALC
874
875        Make/O/D/N=2 fpx1,fpy1,mpx1,mpy1                // for display of the detector panels
876        Make/O/D/N=2 fv_degX,fv_degY
877
878
879// to fill in:
880// values for always-visible items
881        String/G gPresetPopStr = "Low Q;High Q;Converging Pinholes;Narrow Slit Aperture;White Beam;Polarizer;"
882        String/G gBinTypeStr = ksBinTypeStr
883
884
885
886
887// popup strings for each tab (then use the string in the panel)
888// tab 0 - collimation
889        String/G gMonochromatorType = "Velocity Selector;Graphite;White Beam;"
890        String/G gSourceShape = "circular;rectangular;converging pinholes;"
891        String/G gSourceDiam = "1.0 cm;2.0 cm;5.0 cm;"
892        String/G gSourceDiam_0g = "0.75 cm;1.5 cm;3.0 cm;"              // values from John Mar 2018
893        String/G gDeltaLambda = "0.10;0.20;0.30;"
894       
895// tab 1 - sample conditions
896        String/G gTableLocation = "Changer;Stage;"
897        String/G gSampleApertureShape = "circular;rectangular;converging pinholes;"
898        String/G gSampleApertureDiam = "0.5;1.0;1.5;2.0;"
899       
900// tab 2
901
902// tab 3
903
904// tab 4 - back detector
905        String/G gBackDetType = "1D;2D;"
906
907// tab 5
908        String/G gModelFunctionType = "Debye;Sphere;Big Debye;Big Sphere;AgBeh;Vycor;Empty Cell;Blocked Beam;"
909        gModelFunctionType += "Debye +;AgBeh +;Empty Cell +;"
910
911////////////////////
912
913
914
915// limits for detector travel? or are these limits part of the panel, hard-wired there
916
917
918//      // for the panel
919
920        Variable/G gNg=0
921//      Variable/G gOffset=0
922        Variable/G gSamAp=1.27          //samAp diameter in cm
923        String/G gSourceApString = "1.43 cm;2.54 cm;3.81 cm;"
924        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;"
925        Variable/G gSamApOther = 10             //non-standard aperture diameter, in mm
926        Variable/G gUsingLenses = 0             //0=no lenses, 1=lenses(or prisms)
927//      Variable/G gModelOffsetFactor = 1
928//     
929//      // for the MC simulation
930//      Variable/G doSimulation =0              // == 1 if 1D simulated data, 0 if other from the checkbox
931//      Variable/G gRanDateTime=datetime
932//      Variable/G gImon = 10000
933//      Variable/G gThick = 0.1
934//      Variable/G gSig_incoh = 0.1
935//      String/G gFuncStr = ""
936//      Variable/G gR2 = 2.54/2
937//      Variable/G gSamTrans=0.8                        //for 1D, default value
938//      Variable/G gCntTime = 300
939//      Variable/G gDoMonteCarlo = 0
940//      Variable/G gUse_MC_XOP = 1                              //set to zero to use Igor code
941//      Variable/G gBeamStopIn = 1                      //set to zero for beamstop out (transmission)
942//      Variable/G gRawCounts = 0
943//      Variable/G gSaveIndex = 100
944//      String/G gSavePrefix = "SIMUL"
945//      Variable/G gAutoSaveIndex = 100                 //a way to set the index for automated saves
946//      String/G gAutoSaveLabel = ""                            //a way to set the "sample" label for automated saves
947//      Make/O/D/N=10 results = 0
948//      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"}
949//
950//      Variable/G g_1DTotCts = 0                       //summed counts (simulated)
951//      Variable/G g_1DEstDetCR = 0             // estimated detector count rate
952//      Variable/G g_1DFracScatt = 0            // fraction of beam captured on detector
953//      Variable/G g_1DEstTrans = 0             // estimated transmission of sample
954//      Variable/G g_1D_DoABS = 1
955//      Variable/G g_1D_AddNoise = 1
956//      Variable/G g_MultScattFraction=0
957//      Variable/G g_detectorEff=0.75                   //average value for most wavelengths
958//      Variable/G g_actSimTime = 0                             //for the save
959//      Variable/G g_SimTimeWarn = 10                   //manually set to a very large value for scripted operation
960//     
961
962//     
963//      //for the fake dependency
964//      Variable/G gTouched=0
965//      Variable/G gCalculate=0
966//      //for plotting
967//      Variable/G gFreezeCount=1               //start the count at 1 to keep Jeff happy
968//      Variable/G gDoTraceOffset=0             // (1==Yes, offset 2^n), 0==turn off the offset
969
970
971
972//
973// instrument - specific dimensions
974//
975
976//     
977        Variable/G gInstrument = 6              // files (may) be tagged SA6 as the 6th SANS instrument
978        Variable/G gS12 = 54.8
979//      Variable/G d_det = 0.5
980//      Variable/G a_pixel = 0.5
981//      Variable/G del_r = 0.5
982//      Variable/G det_width = 64.0
983        Variable/G gLambda_t = 5.50
984        Variable/G gL2r_lower = 132.3
985        Variable/G gL2r_upper =  1317
986        Variable/G gLambda_lower = 2.5
987        Variable/G gLambda_upper = 20.0
988        Variable/G gD_upper = 25.0
989        Variable/G gBs_factor = 1.05
990        Variable/G gT1 = 0.63
991        Variable/G gT2 = 1.0
992        Variable/G gT3 = 0.75
993        Variable/G gL_gap = 100.0
994        Variable/G gGuide_width = 6.0
995        Variable/G gIdmax = 100.0
996
997//
998//      //new values, from 11/2009 --- BeamFluxReport_2009.ifn
999        Variable/G gPhi_0 = 2.42e13
1000        Variable/G gB = 0.0
1001        Variable/G gC = -0.0243
1002        Variable/G gGuide_loss = 0.924
1003//     
1004//      //fwhm values (new variables) (+3, 0, -3, calibrated 2009)
1005        Variable/G gFwhm_narrow = 0.109
1006        Variable/G gFwhm_mid = 0.125
1007        Variable/G gFwhm_wide = 0.236
1008//     
1009//      //source apertures (cm)
1010        Variable/G gA1_0_0 = 1.43
1011        Variable/G gA1_0_1 = 2.54
1012        Variable/G gA1_0_2 = 3.81
1013        Variable/G gA1_7_0 = 2.5                        // after the polarizer         
1014        Variable/G gA1_7_1 = 5.0
1015        Variable/G gA1_7_1 = 0.95               //
1016        Variable/G gA1_def = 5.00
1017//     
1018        SetDataFolder root:
1019end
Note: See TracBrowser for help on using the repository browser.