From 833ac4ef20898112867b36828f0c92e62d3bcf77 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Fri, 28 Aug 2009 16:10:55 +0000 Subject: [PATCH] Fixed bug with initializing parameters --- src/external/MuSRFitGUI/MSR.pm | 10 ++- src/external/MuSRFitGUI/MuSRFit.pl | 97 +++++++++++++++++++++++++--- src/external/MuSRFitGUI/MuSRFit.ui | 1 + src/external/MuSRFitGUI/MuSRFit.ui.h | 93 +++++++++++++++++++++++--- 4 files changed, 179 insertions(+), 22 deletions(-) diff --git a/src/external/MuSRFitGUI/MSR.pm b/src/external/MuSRFitGUI/MSR.pm index 8d7e0f21..fec16b0a 100755 --- a/src/external/MuSRFitGUI/MSR.pm +++ b/src/external/MuSRFitGUI/MSR.pm @@ -366,11 +366,10 @@ FITPARAMETER # Omit background and data lines for LTF,GPS and Dolly if ( $BeamLine eq "Dolly" ) { $Bg_Line = "background 50 250 50 250"; - $Data_Line = -"t0 287 284\ndata 297 8000 294 8000"; + $Data_Line ="data 297 8000 294 8000"; } elsif ( $BeamLine eq "GPS" ) { $Bg_Line = "background 40 120 40 120"; - $Data_Line = "t0 124 129\ndata 135 8000 135 8000"; + $Data_Line = "data 135 8000 135 8000"; # $Data_Line = "data 135 8000 135 8000"; } @@ -813,11 +812,10 @@ FITPARAMETER # Omit background and data lines for LTG,GPS and Dolly if ( $BeamLine eq "Dolly" ) { $Bg_Line = "background 50 250 50 250"; - $Data_Line = - "t0 287 284\ndata 297 8000 294 8000"; + $Data_Line ="data 297 8000 294 8000"; } elsif ( $BeamLine eq "GPS" ) { $Bg_Line = "background 40 120 40 120"; - $Data_Line = "t0 124 129\ndata 135 8000 135 8000"; + $Data_Line = "data 135 8000 135 8000"; # $Data_Line = "data 135 8000 135 8000"; } diff --git a/src/external/MuSRFitGUI/MuSRFit.pl b/src/external/MuSRFitGUI/MuSRFit.pl index 090e4bde..7bd3e770 100755 --- a/src/external/MuSRFitGUI/MuSRFit.pl +++ b/src/external/MuSRFitGUI/MuSRFit.pl @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'MuSRFit.ui' # -# Created: Thu Aug 27 17:57:40 2009 +# Created: Fri Aug 28 18:06:21 2009 # by: The PerlQt User Interface Compiler (puic) # # WARNING! All changes made in this file will be lost! @@ -27,6 +27,7 @@ use Qt::slots helpIndex => [], helpContents => [], helpAbout => [], + T0BgData => [], CreateAllInput => [], CallMSRCreate => [], UpdateMSRFileInitTable => [], @@ -1660,6 +1661,44 @@ Copyright 2009 by Zaher Salman and the LEM Group. } +sub T0BgData +{ + +# Take this information as input arguments + (my $Name, my $Hist, my $BeamLine) = @_; + +# These are the default values, ordered by beamline +# Comma at the beginning means take default t0 from file +# The order is pairs of "HistNumber","t0,Bg1,Bg2,Data1,Data2" + my %LEM=("1",",66000,66500,3419,63000", + "2",",66000,66500,3419,63000", + "3",",66000,66500,3419,63000", + "4",",66000,66500,3419,63000"); + + my %GPS=("1",",40,120,135,8000", + "2",",40,120,135,8000", + "3",",40,120,135,8000", + "4",",40,120,135,8000"); + + my %Dolly=("1",",50,250,297,8000", + "2",",50,250,297,8000", + "3",",50,250,297,8000", + "4",",50,250,297,8000"); + + +# print "Name = $Name,Hist= $Hist, BeamLine= $BeamLine \n"; + if ($BeamLine = "LEM") { + } + elsif ($BeamLine = "Dolly") { + } + elsif ($BeamLine = "GPS") { + } + + + return ""; + +} + sub CreateAllInput { @@ -1685,6 +1724,21 @@ sub CreateAllInput $All{"FAPODIZATION"}= FApodization->currentText; $All{"FPLOT"}= FPlot->currentText; +# Get values of t0 and Bg/Data bins if given + my $NHist = 1; + foreach my $Hist (@Hists) { + foreach ("t0","Bg1","Bg2","Data1","Data2") { + my $Name = "$_$NHist"; + $All{$Name}=child($Name)->text; +# TODO: If empty fill with defaults + if ($All{$Name} eq "") { + $All{$Name}=T0BgData($_,$Hist,$All{"BeamLine"}); + child($Name)->setText($All{$Name}); + } + } + $NHist++ + } + # Construct fittypes that can be understood by MSR.pm my %FTs=(0,"Exponential", 1,"Gaussian", @@ -1740,7 +1794,7 @@ sub CreateAllInput $All{"$Param$maxadd"}=1.0*InitParamTable->text($i,3); } } - + # Shared settings are detected here my $Shared = 0; @@ -1756,7 +1810,7 @@ sub CreateAllInput elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) { unshift( @Params, ( "N0", "NBg" ) ); } - + # This is the counter for parameters of this component my $NP=1; $Shared = 0; @@ -1770,7 +1824,7 @@ sub CreateAllInput if ( $#FitTypes != 0 && ( $Param ne "Alpha" && $Param ne "N0" && $Param ne "NBg" ) ){ $Param = join( "", $Param, "_", $Component); } - + # Is there any point of sharing, multiple runs? if ( $#RUNS == 0 && $All{"FitAsyType"} eq "Asymmetry") { $Shared = 1; @@ -1869,11 +1923,38 @@ sub UpdateMSRFileInitTable $PCount++; # print "line $PCount: $line \n"; my @Param=split(/\s+/,$line); +# Depending on home many elements in @Param determine what they mean +# 0th element is empty (always) +# 1st element is the order (always) +# 2nd element is the name (always) +# 3rd element is the value (always) +# 4th element can be taken as step/error (always) +# 5th element can be +# if it is last element or there are two more = positive error, check $#Param=5/7 +# if there is only one more = minimum, check $#Param=6 + +# To summarize, check the value of $#Param + my $value=1.0*$Param[3]; + my $error = 1.0*$Param[4]; + my $minvalue=0.0; + my $maxvalue=0.0; + if ($#Param == 4) { + $minvalue=0.0; + $maxvalue=0.0; + } + elsif ($#Param == 6) { + $minvalue=1.0*$Param[5]; + $maxvalue=1.0*$Param[6]; + } + elsif ($#Param == 5 || $#Param == 7) { + $minvalue=1.0*$Param[6]; + $maxvalue=1.0*$Param[7]; + } # print "$Param[2]=$Param[3]+-$Param[4] from $Param[5] to $Param[6]\n"; - InitParamTable->setText($PCount-1,0,1.0*$Param[3]); - InitParamTable->setText($PCount-1,1,1.0*$Param[4]); - InitParamTable->setText($PCount-1,2,1.0*$Param[5]); - InitParamTable->setText($PCount-1,3,1.0*$Param[6]); + InitParamTable->setText($PCount-1,0,$value); + InitParamTable->setText($PCount-1,1,$error); + InitParamTable->setText($PCount-1,2,$minvalue); + InitParamTable->setText($PCount-1,3,$maxvalue); } return; diff --git a/src/external/MuSRFitGUI/MuSRFit.ui b/src/external/MuSRFitGUI/MuSRFit.ui index 07438018..c75ffaa5 100755 --- a/src/external/MuSRFitGUI/MuSRFit.ui +++ b/src/external/MuSRFitGUI/MuSRFit.ui @@ -2965,6 +2965,7 @@ helpIndex() helpContents() helpAbout() + T0BgData() CreateAllInput() CallMSRCreate() UpdateMSRFileInitTable() diff --git a/src/external/MuSRFitGUI/MuSRFit.ui.h b/src/external/MuSRFitGUI/MuSRFit.ui.h index 9b8f0c21..2763e04d 100755 --- a/src/external/MuSRFitGUI/MuSRFit.ui.h +++ b/src/external/MuSRFitGUI/MuSRFit.ui.h @@ -131,7 +131,6 @@ void Form1::helpContents() } - void Form1::helpAbout() { my $AboutText=" @@ -157,6 +156,42 @@ Copyright 2009 by Zaher Salman and the LEM Group. my $AboutWindow = Qt::MessageBox::information( this, "About MuSRFit GUI",$AboutText); } +void MuSRFitform::T0BgData() +{ +# Take this information as input arguments + (my $Name, my $Hist, my $BeamLine) = @_; + +# These are the default values, ordered by beamline +# Comma at the beginning means take default t0 from file +# The order is pairs of "HistNumber","t0,Bg1,Bg2,Data1,Data2" + my %LEM=("1",",66000,66500,3419,63000", + "2",",66000,66500,3419,63000", + "3",",66000,66500,3419,63000", + "4",",66000,66500,3419,63000"); + + my %GPS=("1",",40,120,135,8000", + "2",",40,120,135,8000", + "3",",40,120,135,8000", + "4",",40,120,135,8000"); + + my %Dolly=("1",",50,250,297,8000", + "2",",50,250,297,8000", + "3",",50,250,297,8000", + "4",",50,250,297,8000"); + + +# print "Name = $Name,Hist= $Hist, BeamLine= $BeamLine \n"; + if ($BeamLine = "LEM") { + } + elsif ($BeamLine = "Dolly") { + } + elsif ($BeamLine = "GPS") { + } + + + return ""; +} + void MuSRFitform::CreateAllInput() { # TODO: Need to deliver shared parameters also @@ -181,6 +216,21 @@ void MuSRFitform::CreateAllInput() $All{"FAPODIZATION"}= FApodization->currentText; $All{"FPLOT"}= FPlot->currentText; +# Get values of t0 and Bg/Data bins if given + my $NHist = 1; + foreach my $Hist (@Hists) { + foreach ("t0","Bg1","Bg2","Data1","Data2") { + my $Name = "$_$NHist"; + $All{$Name}=child($Name)->text; +# TODO: If empty fill with defaults + if ($All{$Name} eq "") { + $All{$Name}=T0BgData($_,$Hist,$All{"BeamLine"}); + child($Name)->setText($All{$Name}); + } + } + $NHist++ + } + # Construct fittypes that can be understood by MSR.pm my %FTs=(0,"Exponential", 1,"Gaussian", @@ -236,7 +286,7 @@ void MuSRFitform::CreateAllInput() $All{"$Param$maxadd"}=1.0*InitParamTable->text($i,3); } } - + # Shared settings are detected here my $Shared = 0; @@ -252,7 +302,7 @@ void MuSRFitform::CreateAllInput() elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) { unshift( @Params, ( "N0", "NBg" ) ); } - + # This is the counter for parameters of this component my $NP=1; $Shared = 0; @@ -266,7 +316,7 @@ void MuSRFitform::CreateAllInput() if ( $#FitTypes != 0 && ( $Param ne "Alpha" && $Param ne "N0" && $Param ne "NBg" ) ){ $Param = join( "", $Param, "_", $Component); } - + # Is there any point of sharing, multiple runs? if ( $#RUNS == 0 && $All{"FitAsyType"} eq "Asymmetry") { $Shared = 1; @@ -361,11 +411,38 @@ void MuSRFitform::UpdateMSRFileInitTable() $PCount++; # print "line $PCount: $line \n"; my @Param=split(/\s+/,$line); +# Depending on home many elements in @Param determine what they mean +# 0th element is empty (always) +# 1st element is the order (always) +# 2nd element is the name (always) +# 3rd element is the value (always) +# 4th element can be taken as step/error (always) +# 5th element can be +# if it is last element or there are two more = positive error, check $#Param=5/7 +# if there is only one more = minimum, check $#Param=6 + +# To summarize, check the value of $#Param + my $value=1.0*$Param[3]; + my $error = 1.0*$Param[4]; + my $minvalue=0.0; + my $maxvalue=0.0; + if ($#Param == 4) { + $minvalue=0.0; + $maxvalue=0.0; + } + elsif ($#Param == 6) { + $minvalue=1.0*$Param[5]; + $maxvalue=1.0*$Param[6]; + } + elsif ($#Param == 5 || $#Param == 7) { + $minvalue=1.0*$Param[6]; + $maxvalue=1.0*$Param[7]; + } # print "$Param[2]=$Param[3]+-$Param[4] from $Param[5] to $Param[6]\n"; - InitParamTable->setText($PCount-1,0,1.0*$Param[3]); - InitParamTable->setText($PCount-1,1,1.0*$Param[4]); - InitParamTable->setText($PCount-1,2,1.0*$Param[5]); - InitParamTable->setText($PCount-1,3,1.0*$Param[6]); + InitParamTable->setText($PCount-1,0,$value); + InitParamTable->setText($PCount-1,1,$error); + InitParamTable->setText($PCount-1,2,$minvalue); + InitParamTable->setText($PCount-1,3,$maxvalue); } return; }