Commit 33583b27 authored by Miguel Angel Gonzalez's avatar Miguel Angel Gonzalez
Browse files

Added Figaro's chopper separation (cht) to machine tab + removed beam width lambda smearing

parent 0ff94a40
......@@ -211,7 +211,7 @@ function cosmos_get_settings, main
tags = tag_names(settings)
for i = 0, n_elements(tags) - 1 do begin
;special treatment of calculation method (droplist)
if (tags[i] eq 'METHOD1') then begin
wid = widget_info(main, find_by_uname = 'CALCMETHOD1')
......
;PG 2022-04-20 Removed the wavelength smearing due to finite beam width at chopper position. This should have been there only for the incoherent case and even then only if the foreground width is large. This situation is unlikely to happen, so better removed.
;MG 2022-04-13 Working version allowing to switch on/off gravity (gravity = 1/0) to check gravity effects
;PG 2022-04-08 Changed FIGARO sample-to-detector distance to sample-to-detector-center distance and updated the horizontal sample offset to be taken into account in d0 and sdet for FIGARO and added coherent DET option
;TS 2021-04-27 Bug fixes
......@@ -1881,6 +1882,7 @@ pro cosmos_anal_run, result, groupedresult, direct, reflect, instr, theta, runno
grouping_value = c_settings.groupvar1
c_params.poff = c_settings.poff1
c_params.d0 = c_settings.d01
c_params.chopsep = c_settings.chopsep1
c_params.openoff = c_settings.openoff1
c_params.offset = c_settings.spoff1
c_params.pixelwidth = c_settings.pixelwidth
......@@ -1913,6 +1915,7 @@ pro cosmos_anal_run, result, groupedresult, direct, reflect, instr, theta, runno
grouping_value = c_settings.groupvar2
c_params.poff = c_settings.poff2
c_params.d0 = c_settings.d02
c_params.chopsep = c_settings.chopsep2
c_params.openoff = c_settings.openoff2
c_params.offset = c_settings.spoff2
c_params.pixelwidth = c_settings.pixelwidth
......@@ -1945,6 +1948,7 @@ pro cosmos_anal_run, result, groupedresult, direct, reflect, instr, theta, runno
grouping_value = c_settings.groupvar3
c_params.poff = c_settings.poff3
c_params.d0 = c_settings.d03
c_params.chopsep = c_settings.chopsep3
c_params.openoff = c_settings.openoff3
c_params.offset = c_settings.spoff3
c_params.pixelwidth = c_settings.pixelwidth
......@@ -2401,7 +2405,7 @@ pro cosmos_anal_run, result, groupedresult, direct, reflect, instr, theta, runno
cosmos_logmessage, ' Constant q-binning option. Reflect peak position (from gaussian fit) = ' + cosmos_str_make(newpeakref)
if (strcmp(strtrim(c_params.inst,2),'figaro',/FOLD_CASE)) then begin
;trueSampleDetDistance = parref.sdetd - parref.offset ;PG on 27/7/15
;trueSampleDetDistance = parref.sdetd - parref.offset ;PG on 27/7/15
trueSampleDetDistance = parref.sdetd ;PG on 08/04/22: This is the correct distance now
if parref.refdown eq 0 then begin ;determine if reflection down
......@@ -2639,22 +2643,12 @@ pro cosmos_anal_run, result, groupedresult, direct, reflect, instr, theta, runno
;Determine wavelength (in angstroms) from TOF channels --> lambda[t] (using RB)
corrected_sdetd = cosmos_anal_correctdistance(peakref, parref.x_min, parref.pixeldensity, parref.sdetd)
ref_total_tofd = parref.tofd - parref.sdetd + corrected_sdetd
print, 'CHECKING DISTANCES, RB # ', reflect
print, 'L = tofd - sdetd + corrected_sdetd'
print, 'total L (RB) = ', ref_total_tofd
print, 'parref.tofd, sdetd, d0, offset = ', parref.tofd, parref.sdetd, c_params.d0, parref.offset
print, 'corrected_sdetd (after call to cosmos_anal_correctdistance) = ', corrected_sdetd
if normal_run then begin
corrected_sdetd = cosmos_anal_correctdistance(peakdir, parref.x_min, parref.pixeldensity, pardir.sdetd)
dir_total_tofd = pardir.tofd - pardir.sdetd + corrected_sdetd
dir_ref_diff = abs(ref_total_tofd - dir_total_tofd)
cosmos_logmessage, ' Difference in corrected TOF distance between direct and reflect beams is ' + cosmos_str_make(dir_ref_diff)
if (dir_ref_diff / ref_total_tofd) gt 0.01 then cosmos_logmessage, ' Run no. ' + cosmos_str_make(runno) + ': Different TOF distances from direct and reflect runs.', /WARNING
print, 'DB # ', direct
print, 'total L (DB) = ', dir_total_tofd
print, 'pardir.tofd, sdetd, d0, offset = ', pardir.tofd, pardir.sdetd, c_params.d0, pardir.offset
print, 'corrected_sdetd (after call to cosmos_anal_correctdistance) = ', corrected_sdetd
print, ''
endif
lambda = 1e10 * (c_params.planckperkg * ((findgen(tsize) + 0.5) * parref.channelwidth + parref.delay) / ref_total_tofd)
;TS 2019-01-11 Lower and upper bound of wavelength for each time channel.
......@@ -2987,20 +2981,11 @@ pro cosmos_anal_run, result, groupedresult, direct, reflect, instr, theta, runno
( lambda[lambda_range] * 1.e-10) / (2.0 * parref.tofd)
err_res = 0.98 * (3*chop_res^2 + det_res^2 + 3*chop_res*det_res)/(2*chop_res + det_res) ;FWHM of resulting trapezoid
;PG on 07/08/2017: Added wavelength smearing due to finite beam size at chopper 1 position:
tempratio=(parref.tofd-sdr)*1000/c_params.interslit
tempa=tempratio*abs(parref.s2w-parref.s3w)+parref.s2w
tempb=tempratio*(parref.s2w+parref.s3w)+parref.s2w
tempwidthfwhm=0.49*(tempb^3-tempa^3)/(tempb^2-tempa^2)
;calculate beam width lambda resolution
width_res = tempwidthfwhm/1000.0 * parref.period / $
(2 * !pi * c_params.cr)* c_params.planckperkg / $
( lambda[lambda_range] * 1.e-10) / parref.tofd
err_res = sqrt(err_res^2+width_res^2)
;PG on 20/04/22: Removed the beam width lambda smearing.
;For the coherent method: the slope integration (partially) recovers the smearing.
;For incoherent: The foreground width determines the effective beam size.
s3_fwhm=(0.68*parref.s3w)/(parref.slit3*1000.0+parref.sdetd*1000.0) ; fwhm angles of second slit PG on 28/04/15: corrected for interslit distance
;Resolution calculation (different depending on coherent/incoherent treatment)
......@@ -3746,7 +3731,7 @@ pro cosmos_raw_read, files, monitors, counts, params, path, override, reflect=re
readf, raw_lun, par1
;MAG: Reading machine options (if override not selected)
if (override eq 0) then begin
if (strcmp(strtrim(c_params.inst,2),'d17',/FOLD_CASE)) then begin
......@@ -4007,6 +3992,42 @@ pro cosmos_raw_read, files, monitors, counts, params, path, override, reflect=re
; 93 : slit value
; 95 : slit value
;MG 02/06/2022 Added option to set chopsep manually in machine tab (only for Figaro)
if (override eq 0) and (strcmp(strtrim(c_params.inst,2),'figaro',/FOLD_CASE)) then begin
chopper1 = par2[200] ;first controlling chopper
chopper2 = par2[201] ;second controlling chopper
case chopper1 of
1 : begin
case chopper2 of
2 : c_params.chopsep = c_params.chopsep12_fig
3 : c_params.chopsep = c_params.chopsep13_fig
4 : c_params.chopsep = c_params.chopsep14_fig
endcase
end
2 : begin
case chopper2 of
3 : c_params.chopsep = c_params.chopsep23_fig
4 : c_params.chopsep = c_params.chopsep24_fig
endcase
end
3 : begin
case chopper2 of
4 : c_params.chopsep = c_params.chopsep34_fig
endcase
end
else : cosmos_logmessage, 'No right value in par2[200] for controlling chopper 1', /WARNING
endcase
endif
if (strcmp(strtrim(c_params.inst,2),'d17',/FOLD_CASE)) then begin
;TS 2021-02-25
......@@ -4250,36 +4271,18 @@ pro cosmos_raw_read, files, monitors, counts, params, path, override, reflect=re
case chopper1 of
1 : begin
speed1 = par2[180]
phase1 = par2[181]
case chopper2 of
2 : c_params.chopsep = c_params.chopsep12_fig
3 : c_params.chopsep = c_params.chopsep13_fig
4 : c_params.chopsep = c_params.chopsep14_fig
endcase
end
2 : begin
speed1 = par2[185]
phase1 = par2[186]
case chopper2 of
3 : c_params.chopsep = c_params.chopsep23_fig
4 : c_params.chopsep = c_params.chopsep24_fig
endcase
end
3 : begin
speed1 = par2[190]
phase1 = par2[191]
case chopper2 of
4 : c_params.chopsep = c_params.chopsep34_fig
endcase
end
else : cosmos_logmessage, 'No right value in par2[200] for controlling chopper 1', /WARNING
......@@ -4289,24 +4292,18 @@ pro cosmos_raw_read, files, monitors, counts, params, path, override, reflect=re
case chopper2 of
2 : begin
speed2 = par2[185]
phase2 = par2[186]
end
3 : begin
speed2 = par2[190]
phase2 = par2[191]
end
4 : begin
speed2 = par2[195]
phase2 = par2[196]
end
else : cosmos_logmessage, 'No right value in par2[201] for controlling chopper 2', /WARNING
......
......@@ -195,7 +195,10 @@ function cosmos_get_default_settings
makesubdir : 1 , $
gtable : ptr_new(strarr(4,20)) , $
peakref : [0, 0, 0] , $
polcorrfile : ''}
polcorrfile : '' , $
chopsep1 : 0.0 , $
chopsep2 : 0.0 , $
chopsep3 : 0.0 }
return, settings
......@@ -344,16 +347,27 @@ pro cosmos_globals
c_results = {}
cosmos_version = '3.3.16'
cosmos_version = '3.3.17'
cosmos_help_message = [$
'',$
'COSMOS V. 3.3.16',$
'7 May 2021',$
'Updated to read correctly the different NeXus versions.',$
'For NeXus v. >=2, Ascii and NeXus should give the same result for D17.',$
'In the case of Figaro, there is a discrepancy in the sample to detector',$
'distance that still needs to be resolved.',$
'',$
'COSMOS V. 3.3.17',$
'2 June 2022',$
'Series of changes affecting only Figaro:',$
' Corrected bug in the way the sample offset value was used when computing distances.',$
' Force NeXus files to have beam peak at same position as in Ascii files.',$
' Option to activate/deactivate gravity --> needs to change gravity variable and recompile.',$
' Added possibility of setting chopper separation value manually in machine tab (cht entry).',$
'Removed beam width lambda smearing',$
'',$
'',$
'COSMOS V. 3.3.16',$
'7 May 2021',$
'Updated to read correctly the different NeXus versions.',$
'For NeXus v. >=2, Ascii and NeXus should give the same result for D17.',$
'In the case of Figaro, there is a discrepancy in the sample to detector',$
'distance that still needs to be resolved.',$
'',$
'',$
'COSMOS V. 3.3.15',$
'25 January 2021',$
......@@ -875,6 +889,7 @@ pro cosmos_globals
ANGLE_METHOD : 'To be documented.', $
DET_CALIBRATION : 'To be documented.', $
POL_CORR : 'To be documented.', $
USE_NEXUS : 'Uses files in NeXus format'}
USE_NEXUS : 'Uses files in NeXus format',$
CHOPSEP : 'To be documented.'}
end
......@@ -1852,9 +1852,9 @@ pro cosmos_take_machine_settings, event
path = strtrim(path, 2) + path_sep()
wids = [['TAKENUM1','POFF1','D01','OPENOFF1','PIXELWIDTH','SDETD','EDELAY1','SPOFF1','XDH1','XDH2','YDET'], $
['TAKENUM2','POFF2','D02','OPENOFF2','PIXELWIDTH','SDETD','EDELAY2','SPOFF2','XDH1','XDH2','YDET'], $
['TAKENUM3','POFF3','D03','OPENOFF3','PIXELWIDTH','SDETD','EDELAY3','SPOFF3','XDH1','XDH2','YDET']]
wids = [['TAKENUM1','POFF1','D01','OPENOFF1','PIXELWIDTH','SDETD','EDELAY1','SPOFF1','XDH1','XDH2','YDET','CHOPSEP1'], $
['TAKENUM2','POFF2','D02','OPENOFF2','PIXELWIDTH','SDETD','EDELAY2','SPOFF2','XDH1','XDH2','YDET','CHOPSEP2'], $
['TAKENUM3','POFF3','D03','OPENOFF3','PIXELWIDTH','SDETD','EDELAY3','SPOFF3','XDH1','XDH2','YDET','CHOPSEP3']]
s = size(wids)
......@@ -1997,6 +1997,17 @@ pro cosmos_machine_tab, parent = parent
l = widget_label(b, ysize=10, value = "")
bb = widget_base(b, /row, /base_align_center)
l = widget_label(bb, font = c_font_big, xsize=150, value = " cht (FIGARO) (m)", uname='CHOPSEP', /ALIGN_LEFT, /TRACKING_EVENTS)
l = widget_label(bb, xsize=40, value = "")
w = cw_field(bb, title = "Angle 1 ", xsize = 10, /floating, uname = 'CHOPSEP1')
l = widget_label(bb, xsize=20, value = "")
w = cw_field(bb, title = "Angle 2 ", xsize = 10, /floating, uname = 'CHOPSEP2')
l = widget_label(bb, xsize=20, value = "")
w = cw_field(bb, title = "Angle 3 ", xsize = 10, /floating, uname = 'CHOPSEP3')
l = widget_label(b, ysize=10, value = "")
bb = widget_base(b, /row, /base_align_center)
l = widget_label(bb, font = c_font_big, xsize=150, value = " Take values from numor", uname='TAKE_VALUES', /ALIGN_LEFT, /TRACKING_EVENTS)
l = widget_label(bb, xsize=40, value = "")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment