1 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
2 | |
---|
3 | //////////////////////// |
---|
4 | // |
---|
5 | // |
---|
6 | // a bunch of utility procedures to access information from the VCALC panel and to access |
---|
7 | // constants based in which of the detectors I'm trying to work with. Saves a lot of repetitive switches |
---|
8 | // |
---|
9 | // start the function names with VCALC_ to avoid the eventual conflicts with the file loading utilities |
---|
10 | // for reduction of real VSANS data |
---|
11 | // |
---|
12 | // |
---|
13 | // -- add more of these procedures as more items are added to the panel |
---|
14 | // |
---|
15 | //////////////////////// |
---|
16 | |
---|
17 | |
---|
18 | // Values from the VCALC panel |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | // returns the panel separation [cm] |
---|
24 | Function VCALC_getPanelTranslation(type) |
---|
25 | String type |
---|
26 | |
---|
27 | Variable sep |
---|
28 | |
---|
29 | strswitch(type) |
---|
30 | case "FL": |
---|
31 | ControlInfo/W=VCALC VCALCCtrl_2a |
---|
32 | sep = V_Value |
---|
33 | break |
---|
34 | case "FR": |
---|
35 | ControlInfo/W=VCALC VCALCCtrl_2aa |
---|
36 | sep = V_Value |
---|
37 | break |
---|
38 | case "FT": |
---|
39 | ControlInfo/W=VCALC VCALCCtrl_2b |
---|
40 | sep = V_Value |
---|
41 | break |
---|
42 | case "FB": |
---|
43 | ControlInfo/W=VCALC VCALCCtrl_2bb |
---|
44 | sep = V_Value |
---|
45 | break |
---|
46 | |
---|
47 | case "ML": |
---|
48 | ControlInfo/W=VCALC VCALCCtrl_3a |
---|
49 | sep = V_Value |
---|
50 | break |
---|
51 | case "MR": |
---|
52 | ControlInfo/W=VCALC VCALCCtrl_3aa |
---|
53 | sep = V_Value |
---|
54 | break |
---|
55 | case "MT": |
---|
56 | ControlInfo/W=VCALC VCALCCtrl_3b |
---|
57 | sep = V_Value |
---|
58 | break |
---|
59 | case "MB": |
---|
60 | ControlInfo/W=VCALC VCALCCtrl_3bb |
---|
61 | sep = V_Value |
---|
62 | break |
---|
63 | |
---|
64 | case "B": |
---|
65 | sep = 0 |
---|
66 | break |
---|
67 | |
---|
68 | default: |
---|
69 | Print "Error -- type not found in VCALC_getPanelSeparation(type)" |
---|
70 | sep = NaN //no match for type |
---|
71 | endswitch |
---|
72 | |
---|
73 | return(sep) |
---|
74 | end |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | // returns the (mean) wavelength from the panel -- value is angstroms |
---|
79 | Function VCALC_getWavelength() |
---|
80 | |
---|
81 | ControlInfo/W=VCALC VCALCCtrl_0b |
---|
82 | |
---|
83 | return(V_Value) |
---|
84 | end |
---|
85 | |
---|
86 | // returns the wavelength spread from the panel -- value is fraction |
---|
87 | Function VCALC_getWavelengthSpread() |
---|
88 | |
---|
89 | ControlInfo/W=VCALC VCALCCtrl_0d |
---|
90 | |
---|
91 | return(V_Value) |
---|
92 | end |
---|
93 | |
---|
94 | // returns the number of neutrons on the sample |
---|
95 | Function VCALC_getImon() |
---|
96 | |
---|
97 | ControlInfo/W=VCALC VCALCCtrl_5a |
---|
98 | |
---|
99 | return(V_Value) |
---|
100 | end |
---|
101 | |
---|
102 | // returns the model function to use |
---|
103 | Function/S VCALC_getModelFunctionStr() |
---|
104 | |
---|
105 | ControlInfo/W=VCALC VCALCCtrl_5b |
---|
106 | |
---|
107 | return(S_Value) |
---|
108 | end |
---|
109 | |
---|
110 | |
---|
111 | |
---|
112 | /// NVARs set in VCALC space (not necessarily matching the true instrument values) |
---|
113 | // -- these all set to the proper data folder, then BACK TO ROOT: |
---|
114 | |
---|
115 | |
---|
116 | // return the pixel X size, in [cm] |
---|
117 | Function VCALC_getPixSizeX(type) |
---|
118 | String type |
---|
119 | |
---|
120 | Variable pixSizeX = V_getDet_x_pixel_size("VCALC",type) |
---|
121 | |
---|
122 | return(pixSizeX) |
---|
123 | end |
---|
124 | |
---|
125 | // return the pixel Y size, in [cm] |
---|
126 | Function VCALC_getPixSizeY(type) |
---|
127 | String type |
---|
128 | |
---|
129 | Variable pixSizeY = V_getDet_y_pixel_size("VCALC",type) |
---|
130 | |
---|
131 | return(pixSizeY) |
---|
132 | end |
---|
133 | |
---|
134 | |
---|
135 | // return the number of pixels in x-dimension |
---|
136 | Function VCALC_get_nPix_X(type) |
---|
137 | String type |
---|
138 | |
---|
139 | Variable nPix = V_getDet_pixel_num_x("VCALC",type) |
---|
140 | |
---|
141 | return(nPix) |
---|
142 | end |
---|
143 | |
---|
144 | // return the number of pixels in y-dimension |
---|
145 | Function VCALC_get_nPix_Y(type) |
---|
146 | String type |
---|
147 | |
---|
148 | Variable nPix = V_getDet_pixel_num_y("VCALC",type) |
---|
149 | |
---|
150 | return(nPix) |
---|
151 | end |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | // SDD offset of the top/bottom panels |
---|
156 | // value returned is in [cm] |
---|
157 | // |
---|
158 | Function VCALC_getTopBottomSDDSetback(type) |
---|
159 | String type |
---|
160 | |
---|
161 | SetDataFolder root:Packages:NIST:VSANS:VCALC |
---|
162 | |
---|
163 | strswitch(type) |
---|
164 | case "FL": |
---|
165 | case "FR": |
---|
166 | SetDataFolder root: |
---|
167 | return(0) |
---|
168 | break //already zero, do nothing |
---|
169 | case "FT": |
---|
170 | case "FB": |
---|
171 | NVAR sdd_setback = gFront_SDDsetback //T/B are 41 cm farther back |
---|
172 | break |
---|
173 | |
---|
174 | case "ML": |
---|
175 | case "MR": |
---|
176 | SetDataFolder root: |
---|
177 | return(0) |
---|
178 | break //already zero, do nothing |
---|
179 | case "MT": |
---|
180 | case "MB": |
---|
181 | NVAR sdd_setback = gMiddle_SDDsetback //T/B are 41 cm farther back |
---|
182 | break |
---|
183 | |
---|
184 | case "B": |
---|
185 | case "B ": |
---|
186 | SetDataFolder root: |
---|
187 | return(0) |
---|
188 | break //already zero, do nothing |
---|
189 | |
---|
190 | default: |
---|
191 | Print "Error -- type not found in VCALC_getTopBottomSDDSetback(type)" |
---|
192 | sdd_setback = 0 //no match for type |
---|
193 | endswitch |
---|
194 | |
---|
195 | SetDataFolder root: |
---|
196 | |
---|
197 | return(sdd_setback) |
---|
198 | End |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | ////////////////////////////////// |
---|
203 | // |
---|
204 | // Actions for the VCALC controls |
---|
205 | // |
---|
206 | ////////////////////////////////// |
---|
207 | |
---|
208 | // get the sourceAperture_to_GateValve distance from the table |
---|
209 | // |
---|
210 | // correct for the sampleAperture_to_GateValve distance |
---|
211 | // |
---|
212 | // return the SourceAp to SampleAp Distance in [cm] |
---|
213 | Function VC_calcSSD() |
---|
214 | |
---|
215 | Variable ng,ssd,samAp_to_GV |
---|
216 | ControlInfo/W=VCALC VCALCCtrl_0a |
---|
217 | ng = V_Value |
---|
218 | |
---|
219 | ControlInfo/W=VCALC VCALCCtrl_1d |
---|
220 | samAp_to_GV = V_Value // [cm] |
---|
221 | |
---|
222 | switch(ng) |
---|
223 | case 0: |
---|
224 | ssd = 2441 |
---|
225 | break |
---|
226 | case 1: |
---|
227 | ssd = 2157 |
---|
228 | break |
---|
229 | case 2: |
---|
230 | ssd = 1976 |
---|
231 | break |
---|
232 | case 3: |
---|
233 | ssd = 1782 |
---|
234 | break |
---|
235 | case 4: |
---|
236 | ssd = 1582 |
---|
237 | break |
---|
238 | case 5: |
---|
239 | ssd = 1381 |
---|
240 | break |
---|
241 | case 6: |
---|
242 | ssd = 1181 |
---|
243 | break |
---|
244 | case 7: |
---|
245 | ssd = 980 |
---|
246 | break |
---|
247 | case 8: |
---|
248 | ssd = 780 |
---|
249 | break |
---|
250 | case 9: |
---|
251 | ssd = 579 |
---|
252 | break |
---|
253 | default: |
---|
254 | Print "Error - using default SSD value" |
---|
255 | ssd = 2441 |
---|
256 | endswitch |
---|
257 | ssd -= samAp_to_GV |
---|
258 | |
---|
259 | // print "SSD (cm) = ",ssd |
---|
260 | return(ssd) |
---|
261 | End |
---|
262 | |
---|
263 | |
---|
264 | // read the number of guides from the slider |
---|
265 | // return the Source aperture diameter [cm] |
---|
266 | // TODO - needs a case statement since a1 can depend on Ng |
---|
267 | Function VC_sourceApertureDiam() |
---|
268 | |
---|
269 | Variable ng,a1 |
---|
270 | ControlInfo/W=VCALC VCALCCtrl_0a |
---|
271 | ng = V_Value |
---|
272 | |
---|
273 | ControlInfo/W=VCALC VCALCCtrl_0f |
---|
274 | String apStr = S_Value |
---|
275 | |
---|
276 | |
---|
277 | if(ng > 0) |
---|
278 | a1 = 6 // 60 mm diameter |
---|
279 | else |
---|
280 | sscanf apStr, "%g cm", a1 |
---|
281 | endif |
---|
282 | |
---|
283 | // Print "Source Ap diam (cm) = ",a1 |
---|
284 | return(a1) |
---|
285 | End |
---|
286 | |
---|
287 | // reports tha value in [cm] |
---|
288 | Function VC_sampleApertureDiam() |
---|
289 | |
---|
290 | ControlInfo/W=VCALC VCALCCtrl_1c |
---|
291 | Variable val = str2num(S_Value) |
---|
292 | |
---|
293 | return(val) |
---|
294 | End |
---|
295 | /////////////////// |
---|
296 | // |
---|
297 | // Presets |
---|
298 | // |
---|
299 | /////////////////// |
---|
300 | |
---|
301 | |
---|
302 | // for Front+Middle Only |
---|
303 | // x F SDD=120 |
---|
304 | // x (L=-20, R=20) (T=4, B=-4) |
---|
305 | // |
---|
306 | // x M SDD = 1900 |
---|
307 | // x (L=0, R=0) |
---|
308 | // |
---|
309 | // x Velocity selector |
---|
310 | // x Ng = 0 |
---|
311 | // x Lam = 8 |
---|
312 | // x delLam = 0.12 |
---|
313 | // source ap = ? (circular) |
---|
314 | // |
---|
315 | // ignore back detector |
---|
316 | // x set plot type to F2-M2xTB-B |
---|
317 | // |
---|
318 | // |
---|
319 | Function VC_FrontMiddlePreset() |
---|
320 | |
---|
321 | // front carriage |
---|
322 | SetVariable VCALCCtrl_2a,value=_NUM:-20 //Left offset |
---|
323 | SetVariable VCALCCtrl_2aa,value=_NUM:20 //Right offset |
---|
324 | SetVariable VCALCCtrl_2b,value=_NUM:4 //Top offset |
---|
325 | SetVariable VCALCCtrl_2bb,value=_NUM:-4 //Bottom offset |
---|
326 | |
---|
327 | SetVariable VCALCCtrl_2d,value=_NUM:120 //SDD |
---|
328 | |
---|
329 | // middle carriage |
---|
330 | SetVariable VCALCCtrl_3a,value=_NUM:-10 //Left offset |
---|
331 | SetVariable VCALCCtrl_3aa,value=_NUM:-10 //Right offset |
---|
332 | SetVariable VCALCCtrl_3b,value=_NUM:4 //Top offset (doesn't matter) |
---|
333 | SetVariable VCALCCtrl_3bb,value=_NUM:-4 //Bottom offset (doesn't matter) |
---|
334 | |
---|
335 | SetVariable VCALCCtrl_3d,value=_NUM:1900 //SDD |
---|
336 | |
---|
337 | |
---|
338 | // monochromator |
---|
339 | PopupMenu VCALCCtrl_0c,mode=1,popvalue="Velocity Selector" |
---|
340 | |
---|
341 | // wavelength spread |
---|
342 | SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda |
---|
343 | DLStr = "0.12;" |
---|
344 | // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda |
---|
345 | PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12" |
---|
346 | |
---|
347 | // wavelength |
---|
348 | SetVariable VCALCCtrl_0b,value=_NUM:8,disable=0 ,noedit=0 // allow user editing again |
---|
349 | |
---|
350 | //number of guides |
---|
351 | Slider VCALCCtrl_0a,value= 0 |
---|
352 | |
---|
353 | |
---|
354 | // binning mode |
---|
355 | PopupMenu popup_b,mode=1,popValue="F2-M2xTB-B" |
---|
356 | |
---|
357 | |
---|
358 | return(0) |
---|
359 | End |
---|
360 | |
---|
361 | |
---|
362 | // White beam preset |
---|
363 | // - set monochromator (this sets lam, delLam) |
---|
364 | // - disregard the back detector (set as front/middle) |
---|
365 | // |
---|
366 | Function VC_WhiteBeamPreset() |
---|
367 | |
---|
368 | VC_FrontMiddlePreset() // moves Middle into contact (but w/ wrong lambda) |
---|
369 | // monochromator |
---|
370 | PopupMenu VCALCCtrl_0c,mode=1,popvalue="White Beam" |
---|
371 | |
---|
372 | // wavelength spread |
---|
373 | SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda |
---|
374 | DLStr = "0.40;" |
---|
375 | // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda |
---|
376 | PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40" |
---|
377 | |
---|
378 | // wavelength |
---|
379 | SetVariable VCALCCtrl_0b,value=_NUM:5.3,disable=0 ,noedit=0 // allow user editing again |
---|
380 | |
---|
381 | return(0) |
---|
382 | end |
---|
383 | |
---|
384 | |
---|
385 | // Graphite - high resolution beam preset |
---|
386 | // - set monochromator (this sets lam, delLam) |
---|
387 | // - uses the back detector (set as front/middle) |
---|
388 | // |
---|
389 | Function VC_GraphiteMonoPreset() |
---|
390 | |
---|
391 | // front carriage |
---|
392 | SetVariable VCALCCtrl_2a,value=_NUM:-20 //Left offset |
---|
393 | SetVariable VCALCCtrl_2aa,value=_NUM:20 //Right offset |
---|
394 | SetVariable VCALCCtrl_2b,value=_NUM:4 //Top offset |
---|
395 | SetVariable VCALCCtrl_2bb,value=_NUM:-4 //Bottom offset |
---|
396 | |
---|
397 | SetVariable VCALCCtrl_2d,value=_NUM:120 //SDD |
---|
398 | |
---|
399 | // middle carriage |
---|
400 | SetVariable VCALCCtrl_3a,value=_NUM:-8 //Left offset |
---|
401 | SetVariable VCALCCtrl_3aa,value=_NUM:08 //Right offset |
---|
402 | SetVariable VCALCCtrl_3b,value=_NUM:18 //Top offset (doesn't matter) |
---|
403 | SetVariable VCALCCtrl_3bb,value=_NUM:-18 //Bottom offset (doesn't matter) |
---|
404 | |
---|
405 | SetVariable VCALCCtrl_3d,value=_NUM:1500 //SDD |
---|
406 | |
---|
407 | // back carriage |
---|
408 | SetVariable VCALCCtrl_4b,value=_NUM:2300 //SDD |
---|
409 | |
---|
410 | // monochromator |
---|
411 | PopupMenu VCALCCtrl_0c,mode=1,popvalue="Graphite" |
---|
412 | |
---|
413 | // wavelength spread |
---|
414 | SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda |
---|
415 | DLStr = "0.01;" |
---|
416 | // PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda |
---|
417 | PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01" |
---|
418 | |
---|
419 | // wavelength |
---|
420 | SetVariable VCALCCtrl_0b,value=_NUM:4.75,disable=0 ,noedit=0 // allow user editing again |
---|
421 | |
---|
422 | //number of guides |
---|
423 | Slider VCALCCtrl_0a,value= 0 |
---|
424 | |
---|
425 | |
---|
426 | // binning mode |
---|
427 | PopupMenu popup_b,mode=1,popValue="F4-M4-B" |
---|
428 | |
---|
429 | return(0) |
---|
430 | end |
---|
431 | |
---|
432 | // calculates L2, the sample aperture to detector distance |
---|
433 | Function VC_calc_L2(detStr) |
---|
434 | String detStr |
---|
435 | |
---|
436 | Variable a2_to_GV,sam_to_GV,sdd,l2 |
---|
437 | sdd = VC_getSDD(detStr) //sample pos to detector |
---|
438 | ControlInfo VCALCCtrl_1d |
---|
439 | a2_to_GV = V_Value |
---|
440 | ControlInfo VCALCCtrl_1e |
---|
441 | sam_to_GV = V_Value |
---|
442 | l2 = sdd - sam_to_GV + a2_to_GV |
---|
443 | |
---|
444 | return(l2) |
---|
445 | End |
---|
446 | |
---|
447 | // |
---|
448 | //direction = one of "vertical;horizontal;maximum;" |
---|
449 | // all of this is bypassed if the lenses are in |
---|
450 | // |
---|
451 | // carrNum = 1,2,3 for F,M,B |
---|
452 | // |
---|
453 | // returns a value in [cm] |
---|
454 | Function VC_beamDiameter(direction,detStr) |
---|
455 | String direction |
---|
456 | String detStr |
---|
457 | |
---|
458 | // NVAR lens = root:Packages:NIST:SAS:gUsingLenses |
---|
459 | // if(lens) |
---|
460 | // return sourceApertureDiam() |
---|
461 | // endif |
---|
462 | |
---|
463 | Variable l1,l2,l2Diff |
---|
464 | Variable d1,d2,bh,bv,bm,umbra,a1,a2 |
---|
465 | Variable lambda,lambda_width,bs_factor |
---|
466 | |
---|
467 | // TODO: proper value for bs_factor |
---|
468 | bs_factor = 1.05 |
---|
469 | |
---|
470 | l1 = VC_calcSSD() |
---|
471 | lambda = VCALC_getWavelength() |
---|
472 | lambda_width = VCALC_getWavelengthSpread() |
---|
473 | |
---|
474 | |
---|
475 | Variable a2_to_GV,sam_to_GV,sdd |
---|
476 | sdd = VC_getSDD(detStr) //sample pos to detector |
---|
477 | ControlInfo VCALCCtrl_1d |
---|
478 | a2_to_GV = V_Value |
---|
479 | ControlInfo VCALCCtrl_1e |
---|
480 | sam_to_GV = V_Value |
---|
481 | l2 = sdd - sam_to_GV + a2_to_GV |
---|
482 | |
---|
483 | |
---|
484 | // TODO verify that these values are in cm |
---|
485 | a1 = VC_sourceApertureDiam() |
---|
486 | |
---|
487 | // sample aperture diam [cm] |
---|
488 | ControlInfo VCALCCtrl_1c |
---|
489 | a2 = V_Value |
---|
490 | |
---|
491 | d1 = a1*l2/l1 |
---|
492 | d2 = a2*(l1+l2)/l1 |
---|
493 | bh = d1+d2 //beam size in horizontal direction |
---|
494 | umbra = abs(d1-d2) |
---|
495 | //vertical spreading due to gravity |
---|
496 | bv = bh + 1.25e-8*(l1+l2)*l2*lambda*lambda*lambda_width |
---|
497 | bm = (bs_factor*bh > bv) ? bs_factor*bh : bv //use the larger of horiz*safety or vertical |
---|
498 | |
---|
499 | strswitch(direction) // string switch |
---|
500 | case "vertical": // execute if case matches expression |
---|
501 | return(bv) |
---|
502 | break // exit from switch |
---|
503 | case "horizontal": // execute if case matches expression |
---|
504 | return(bh) |
---|
505 | break |
---|
506 | case "maximum": // execute if case matches expression |
---|
507 | return(bm) |
---|
508 | break |
---|
509 | default: // optional default expression executed |
---|
510 | return(bm) // when no case matches |
---|
511 | endswitch |
---|
512 | |
---|
513 | return(0) |
---|
514 | |
---|
515 | End |
---|
516 | |
---|
517 | // 1=front |
---|
518 | // 2=middle |
---|
519 | // 3=back |
---|
520 | // return value is in cm |
---|
521 | // actual Sample position to detector distance is reported |
---|
522 | // Top/Bottom setback is included |
---|
523 | Function VC_getSDD(detStr) |
---|
524 | String detStr |
---|
525 | |
---|
526 | Variable sdd |
---|
527 | |
---|
528 | strswitch(detstr) |
---|
529 | case "B": |
---|
530 | case "B ": |
---|
531 | ControlInfo VCALCCtrl_4b |
---|
532 | break |
---|
533 | case "ML": |
---|
534 | case "MR": |
---|
535 | case "MT": |
---|
536 | case "MB": |
---|
537 | ControlInfo VCALCCtrl_3d |
---|
538 | break |
---|
539 | case "FL": |
---|
540 | case "FR": |
---|
541 | case "FT": |
---|
542 | case "FB": |
---|
543 | ControlInfo VCALCCtrl_2d |
---|
544 | break |
---|
545 | default: |
---|
546 | Print "no case matched in VC_getSDD()" |
---|
547 | endswitch |
---|
548 | |
---|
549 | // this is gate valve to detector distance |
---|
550 | sdd = V_Value |
---|
551 | |
---|
552 | sdd += VCALC_getTopBottomSDDSetback(detStr) |
---|
553 | |
---|
554 | // VCALCCtrl_1e is Sample Pos to Gate Valve (cm) |
---|
555 | ControlInfo VCALCCtrl_1e |
---|
556 | sdd += V_Value |
---|
557 | |
---|
558 | return(sdd) |
---|
559 | end |
---|
560 | |
---|
561 | |
---|
562 | // TODO |
---|
563 | // -- verify all of the numbers, constants, and "empirical" transmission corrections |
---|
564 | // -- |
---|
565 | // |
---|
566 | Function V_beamIntensity() |
---|
567 | |
---|
568 | Variable as,solid_angle,l1,d2_phi |
---|
569 | Variable a1,a2,retVal |
---|
570 | Variable ng |
---|
571 | Variable lambda_t |
---|
572 | Variable lambda,phi_0 |
---|
573 | Variable lambda_width |
---|
574 | Variable guide_loss,t_guide,t_filter,t_total,t_special |
---|
575 | |
---|
576 | NVAR gBeamInten = root:Packages:NIST:VSANS:VCALC:gBeamIntensity |
---|
577 | |
---|
578 | // TODO |
---|
579 | // -- verify these numbers |
---|
580 | lambda_t = 6.20 |
---|
581 | phi_0 = 1.82e13 |
---|
582 | guide_loss = 0.97 |
---|
583 | t_special = 1 |
---|
584 | |
---|
585 | ControlInfo VCALCCtrl_0a |
---|
586 | ng = V_Value |
---|
587 | |
---|
588 | lambda = VCALC_getWavelength() |
---|
589 | lambda_width = VCALC_getWavelengthSpread() |
---|
590 | l1 = VC_calcSSD() |
---|
591 | |
---|
592 | // TODO verify that these values are in cm |
---|
593 | a1 = VC_sourceApertureDiam() |
---|
594 | |
---|
595 | // sample aperture diam [cm] |
---|
596 | ControlInfo VCALCCtrl_1c |
---|
597 | a2 = V_Value |
---|
598 | |
---|
599 | // alpha = (a1+a2)/(2*l1) //angular divergence of beam |
---|
600 | // f = l_gap*alpha/(2*guide_width) |
---|
601 | // t4 = (1-f)*(1-f) |
---|
602 | // t6 = 1 - lambda*(b-(ng/8)*(b-c)) //experimental correction factor |
---|
603 | |
---|
604 | t_guide = exp(ng*ln(guide_loss)) // trans losses of guides in pre-sample flight |
---|
605 | t_filter = exp(-0.371 - 0.0305*lambda - 0.00352*lambda*lambda) |
---|
606 | t_total = t_special*t_guide*t_filter |
---|
607 | |
---|
608 | |
---|
609 | as = pi/4*a2*a2 //area of sample in the beam |
---|
610 | d2_phi = phi_0/(2*pi) |
---|
611 | d2_phi *= exp(4*ln(lambda_t/lambda)) |
---|
612 | d2_phi *= exp(-1*(lambda_t*lambda_t/lambda/lambda)) |
---|
613 | |
---|
614 | solid_angle = pi/4* (a1/l1)*(a1/l1) |
---|
615 | |
---|
616 | retVal = as * d2_phi * lambda_width * solid_angle * t_total |
---|
617 | |
---|
618 | // set the global for display |
---|
619 | gBeamInten = retVal |
---|
620 | |
---|
621 | return (retVal) |
---|
622 | end |
---|
623 | |
---|
624 | // |
---|
625 | Function VC_figureOfMerit() |
---|
626 | |
---|
627 | Variable bi = V_beamIntensity() |
---|
628 | Variable lambda = VCALC_getWavelength() |
---|
629 | |
---|
630 | return (lambda*lambda*bi) |
---|
631 | End |
---|
632 | |
---|
633 | // return a beamstop diameter (cm) larger than maximum beam dimension |
---|
634 | Function VC_beamstopDiam(detStr) |
---|
635 | String detStr |
---|
636 | |
---|
637 | Variable bm=0 |
---|
638 | Variable bs=0.0 |
---|
639 | Variable yesLens=0 |
---|
640 | |
---|
641 | if(yesLens) |
---|
642 | //bm = sourceApertureDiam() //ideal result, not needed |
---|
643 | bs = 1 //force the diameter to 1" |
---|
644 | else |
---|
645 | bm = VC_beamDiameter("maximum",detStr) |
---|
646 | do |
---|
647 | bs += 1 |
---|
648 | while ( (bs*2.54 < bm) || (bs > 30.0)) //30 = ridiculous limit to avoid inf loop |
---|
649 | endif |
---|
650 | |
---|
651 | return (bs*2.54) //return diameter in cm, not inches for txt |
---|
652 | End |
---|
653 | |
---|
654 | // multiply the appropriate IQ data by the beamstop shadow factor for display |
---|
655 | // |
---|
656 | Function V_IQ_BeamstopShadow() |
---|
657 | |
---|
658 | String popStr |
---|
659 | Variable binType |
---|
660 | |
---|
661 | ControlInfo/W=VCALC popup_b |
---|
662 | popStr = S_Value |
---|
663 | |
---|
664 | binType = V_BinTypeStr2Num(popStr) |
---|
665 | |
---|
666 | String folderStr = "root:Packages:NIST:VSANS:VCALC:" |
---|
667 | |
---|
668 | |
---|
669 | String extStr ="" |
---|
670 | |
---|
671 | switch(binType) |
---|
672 | case 1: |
---|
673 | extStr = ksBinType1 |
---|
674 | |
---|
675 | break |
---|
676 | case 2: |
---|
677 | extStr = ksBinType2 |
---|
678 | |
---|
679 | break |
---|
680 | case 3: |
---|
681 | extStr = ksBinType3 |
---|
682 | |
---|
683 | break |
---|
684 | case 4: /// this is for a tall, narrow slit mode |
---|
685 | extStr = ksBinType4 |
---|
686 | |
---|
687 | break |
---|
688 | case 5: |
---|
689 | extStr = ksBinType5 |
---|
690 | |
---|
691 | break |
---|
692 | case 6: |
---|
693 | extStr = ksBinType6 |
---|
694 | |
---|
695 | break |
---|
696 | case 7: |
---|
697 | extStr = ksBinType7 |
---|
698 | |
---|
699 | break |
---|
700 | |
---|
701 | default: |
---|
702 | Abort "Binning mode not found in V_IQ_BeamstopShadow"// when no case matches |
---|
703 | endswitch |
---|
704 | |
---|
705 | |
---|
706 | // root:Packages:NIST:VSANS:VCALC:fSubS_qxqy_MLR |
---|
707 | // root:Packages:NIST:VSANS:VCALC:iBin_qxqy_MLR |
---|
708 | |
---|
709 | Variable ii |
---|
710 | String ext |
---|
711 | // loop over all of the types of data |
---|
712 | for(ii=0;ii<ItemsInList(extStr);ii+=1) |
---|
713 | ext = StringFromList(ii, extStr, ";") |
---|
714 | Wave iq = $(folderStr+"iBin_qxqy_"+ext) |
---|
715 | Wave fs = $(folderStr+"fSubS_qxqy_"+ext) |
---|
716 | iq = (fs < 0.1) ? iq*0.1 : iq*fs |
---|
717 | // iq *= fs |
---|
718 | endfor |
---|
719 | |
---|
720 | return(0) |
---|
721 | end |
---|