From 2e2f4554a95fa815c82b6613d308853c1d2c5fbf Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Mon, 29 Jan 2018 15:31:13 +0100 Subject: [PATCH] Implemented run list following msr2data notations with hyphens and colons. Started implementation of global fits using msr2data. --- src/external/MuSRFitGUI/MSR.pm | 1665 ++++++++++++------------ src/external/MuSRFitGUI/MuSRFit4.pm | 20 +- src/external/MuSRFitGUI/MuSRFit4.ui | 271 ++-- src/external/MuSRFitGUI/Ui_MuSRFit4.pm | 256 ++-- 4 files changed, 1121 insertions(+), 1091 deletions(-) mode change 100755 => 100644 src/external/MuSRFitGUI/MSR.pm diff --git a/src/external/MuSRFitGUI/MSR.pm b/src/external/MuSRFitGUI/MSR.pm old mode 100755 new mode 100644 index 713abcaf..51ff9913 --- a/src/external/MuSRFitGUI/MSR.pm +++ b/src/external/MuSRFitGUI/MSR.pm @@ -22,9 +22,9 @@ my %Def_Format = # Additional information to extract run properties from database # For LEM use summary files -$SUMM_DIR="/afs/psi.ch/project/nemu/data/summ/"; +my $SUMM_DIR="/afs/psi.ch/project/nemu/data/summ/"; # For Bulok use list files -%DBDIR=("LEM","/afs/psi.ch/project/nemu/data/log/", +my %DBDIR=("LEM","/afs/psi.ch/project/nemu/data/log/", "GPS","/afs/psi.ch/project/bulkmusr/olddata/list/", "Dolly","/afs/psi.ch/project/bulkmusr/olddata/list/", "GPD","/afs/psi.ch/project/bulkmusr/olddata/list/", @@ -33,7 +33,7 @@ $SUMM_DIR="/afs/psi.ch/project/nemu/data/summ/"; "LTF","/afs/psi.ch/project/bulkmusr/olddata/list/"); # Information available since -%MinYears=("LEM","2001", +my %MinYears=("LEM","2001", "GPS","1993", "Dolly","1998", "GPD","1993", @@ -42,7 +42,7 @@ $SUMM_DIR="/afs/psi.ch/project/nemu/data/summ/"; "LTF","1995"); # And to deal with old names of bulk muons -%AltArea=("GPS","PIM3","LTF","PIM3","ALC","PIE3","Dolly","PIE1","GPD","MUE1"); +my %AltArea=("GPS","PIM3","LTF","PIM3","ALC","PIE3","Dolly","PIE1","GPD","MUE1"); # Additions to paremeters' names @@ -52,6 +52,7 @@ my $maxadd = "_max"; +sub CreateMSR { ########################################################################## # CreateMSR # @@ -83,9 +84,8 @@ my $maxadd = "_max"; # FILENAME.msr - MSR file saved # ########################################################################## -sub CreateMSR { my %All = %{$_[0]}; - + my $DEBUG = ""; # Start with empty array my @FitTypes = (); @@ -114,16 +114,12 @@ sub CreateMSR { # Works for CGI script my $Step = $All{"go"}; - if ( $Step eq "PLOT" ) { - $FITMINTYPE = $EMPTY; - } - elsif ( $Step eq "MIGRAD" ) { + my $FITMINTYPE = $EMPTY; + if ( $Step eq "MIGRAD" ) { $FITMINTYPE = "MINIMIZE\nMIGRAD\nHESSE"; - } - elsif ( $Step eq "MINOS" ) { + } elsif ( $Step eq "MINOS" ) { $FITMINTYPE = "MIGRAD\nMINOS"; - } - elsif ( $Step eq "SIMPLEX" ) { + } elsif ( $Step eq "SIMPLEX" ) { $FITMINTYPE = "SCAN\nSIMPLEX"; } @@ -132,21 +128,15 @@ sub CreateMSR { $FITMINTYPE = $All{"Minimization"}."\n".$All{"ErrorCalc"}; } - # First create the THEORY Block my ($Full_T_Block,$Paramcomp_ref)=MSR::CreateTheory(@FitTypes); my @Paramcomp = @$Paramcomp_ref; - # If we have a FUNCTIONS Block the Full_T_Block should be # replaced by Func_T_Block - $FUNCTIONS_Block = $EMPTY; + my $FUNCTIONS_Block = $EMPTY; if ($All{"FunctionsBlock"} ne $EMPTY) { - $FUNCTIONS_Block = " -############################################################### -FUNCTIONS -############################################################### -".$All{"FunctionsBlock"}."\n"; + $FUNCTIONS_Block = "FUNCTIONS\n###############################################################\n".$All{"FunctionsBlock"}."\n"; $Full_T_Block=$All{"Func_T_Block"}; # remove all _N to end (may fail with large number of parameters) $Full_T_Block =~ s/_\d\b//g; @@ -158,14 +148,21 @@ FUNCTIONS # Counter of Params my $PCount = 1; + my $PLT = 2; + # For SingleHist fit + if ($All{"FitAsyType"} eq "SingleHist") { $PLT = 0;} + # Need to select here RUNSAuto or RUNSManual # $RUNSType = 0 (Auto) or 1 (Manual) my $RUNSType = 0; my @RUNS=(); if ($All{"RunNumbers"} ne $EMPTY) { # Remove spaces and other illegal characters - $All{"RunNumbers"} =~ s/ //g; + $All{"RunNumbers"} =~ s/[\ \.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; $All{"RunNumbers"} =~ s/[a-zA-Z]//g; + # Expand hyphens + $All{"RunNumbers"} = MSR::ExpandRunNumbers($All{"RunNumbers"}); + # Split commas @RUNS=split( /,/, $All{"RunNumbers"}); $RUNSType = 0; } @@ -219,13 +216,14 @@ FUNCTIONS unshift( @Params, "Alpha" ); } - foreach $Param (@Params) { - $Param_ORG = $Param; + foreach my $Param (@Params) { + my $Param_ORG = $Param; if ( ($#FitTypes != 0) && ($Param ne "Alpha") ) { $Param = join( $EMPTY, $Param, "_", "$component" ); } # If we have only one RUN then everything is shared + my $Shared = 0; if ( $#RUNS == 0 ) { $Shared = 1; } @@ -254,7 +252,6 @@ FUNCTIONS # Start preparing the parameters block if ($Shared) { - # Parameter is shared enough to keep order from first run if ( $iRun == 1 ) { $Full_T_Block =~ s/$Param_ORG/$PCount/; @@ -264,50 +261,41 @@ FUNCTIONS } else { # Parameter is not shared, use map unless it is a single RUN fit # Skip adding to map line in these cases - if ( $Param ne "Alpha" && $#RUNS != 0 ) - { + if ( ( $Param ne "Alpha" && $#RUNS != 0 ) || ( !( $Param_ORG =~ m/^(No|NBg)/ ) && $#RUNS != 0 )) { ++$nonsh; $Full_T_Block =~ s/$Param_ORG/map$nonsh/; $MAP_Line = join( ' ', $MAP_Line, $PCount ); } ++$PCount; } - $NtotPar = $PCount; + my $NtotPar = $PCount; } } # Finished preparing the FITPARAMETERS block ####################################################################### + # Start constructing RUN block here # For each defined range we need a block in the RUN-Block # Also for each histogram in Single Histograms fits - # Also for Imaginaryand and Real for RRF fits $RUN = $RUNS[ $iRun - 1 ]; - + my $RUN_Line = $EMPTY; if ($All{"RUNSType"}) { $RUN_Line = MSR::RUNFileNameAuto($RUN,"0000",$EMPTY); } else { $RUN_Line = MSR::RUNFileNameAuto($RUN,$YEAR,$BeamLine); } - $Type_Line = "fittype 2"; - $PLT = 2; - $Hist_Lines = + my $Type_Line = "fittype 2"; + my $Hist_Lines = "forward $Hists[0]\nbackward $Hists[1]"; - $Bg_Line = "background"; - $Data_Line = "data"; - $T0_Line = "t0"; - $NHist=1; - foreach $Hist (@Hists) { - foreach ("t0","Bg1","Bg2","Data1","Data2") { - $Name = "$_$NHist"; -# If empty fill with defaults -# if ($All{$Name} eq $EMPTY) { -# $All{$Name}=MSR::T0BgData($_,$Hist,$BeamLine); -# } - } + my $Bg_Line = "background"; + my $Data_Line = "data"; + my $T0_Line = "t0"; + my $NHist=1; + foreach my $Hist (@Hists) { # If empty skip lines if ($All{"Bg1$NHist"} ne $EMPTY && $All{"Bg2$NHist"} ne $EMPTY) { $Bg_Line = $Bg_Line." ".$All{"Bg1$NHist"}." ".$All{"Bg2$NHist"}; @@ -364,23 +352,15 @@ FUNCTIONS # The number of runs is $NRUNS = $iRun - 1; - -# Start constructing all blocks + # Start constructing all blocks my $TitleLine = $All{"TITLE"}."\n# Run Numbers: ".$All{"RunNumbers"}; -# if ($All{"RUNSType"}) { -# $TitleLine = $EMPTY; -# } -# $TitleLine =~ s/\n//g; # Get parameter block from MSR::PrepParamTable(\%All); - my $FitParaBlk = " -############################################################### -FITPARAMETER + my $FitParaBlk = "FITPARAMETER ############################################################### # No Name Value Err Min Max "; my %PTable=MSR::PrepParamTable(\%All); my $NParam=scalar keys( %PTable ); - # Fill the table with labels and values of parametr for (my $iP=0;$iP<$NParam;$iP++) { my ($Param,$value,$error,$minvalue,$maxvalue,$RUNtmp) = split(/,/,$PTable{$iP}); @@ -393,26 +373,14 @@ FITPARAMETER $PCount $Param $value $error $error $minvalue $maxvalue"; } - $Full_T_Block = " -############################################################### -THEORY -############################################################### -$Full_T_Block -"; + $Full_T_Block = "THEORY\n###############################################################\n$Full_T_Block\n"; - - $RUN_Block = - "############################################################### -$RUN_Block"; - - $COMMANDS_Block = - "############################################################### -COMMANDS -FITMINTYPE -SAVE -"; + # COMMAND Block + $COMMANDS_Block = "COMMANDS\nFITMINTYPE\nSAVE\n"; $COMMANDS_Block =~ s/FITMINTYPE/$FITMINTYPE/g; + # END- COMMAND Block + # PLOT Block # Check if log x and log y are selected my $logxy = $EMPTY; if ( $All{"logx"} eq "y" ) { $logxy = $logxy . "logx\n"; } @@ -431,63 +399,76 @@ SAVE $VIEWBIN_Line =""; if ( $All{"ViewBin"}!=0 ) { $VIEWBIN_Line = "view_packing ".$All{"ViewBin"};} - my $RRFBlock=MSR::CreateRRFBlock(\%All); - $PLOT_Block = - "############################################################### -PLOT $PLT -runs $RUNS_Line -$PRANGE_Line -$VIEWBIN_Line -$RRFBlock -$logxy"; + my $RRFBlock=MSR::CreateRRFBlk(\%All); + $PLOT_Block = "PLOT $PLT\nruns $RUNS_Line\n$PRANGE_Line\n$VIEWBIN_Line\n$RRFBlock\n$logxy"; + #END - PLOT Block - if ($All{"FUNITS"} eq $EMPTY) {$All{"FUNITS"}="MHz";} - if ($All{"FAPODIZATION"} eq $EMPTY) {$All{"FAPODIZATION"}="STRONG";} - if ($All{"FPLOT"} eq $EMPTY) {$All{"FPLOT"}="POWER";} - if ($All{"FPHASE"} eq $EMPTY) {$All{"FPHASE"}="8.5";} - my $FrqRange = "#range ".$All{"FRQMIN"}." ".$All{"FRQMAX"}; - if ($All{"FRQMAX"} ne $EMPTY && $All{"FRQMIN"} ne $EMPTY && $All{"FRQMAX"} ne $All{"FRQMIN"}) { - $FrqRange = "range ".$All{"FRQMIN"}." ".$All{"FRQMAX"}; - } - - $FOURIER_Block= - "############################################################### -FOURIER -units FUNITS # units either 'Gauss', 'MHz', or 'Mc/s' -fourier_power 12 -apodization FAPODIZATION # NONE, WEAK, MEDIUM, STRONG -plot FPLOT # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE -phase FPHASE -FRQRANGE"; - - $FOURIER_Block=~ s/FUNITS/$All{"FUNITS"}/g; - $FOURIER_Block=~ s/FAPODIZATION/$All{"FAPODIZATION"}/g; - $FOURIER_Block=~ s/FPLOT/$All{"FPLOT"}/g; - $FOURIER_Block=~ s/FPHASE/$All{"FPHASE"}/g; - $FOURIER_Block=~ s/FRQRANGE/$FrqRange/g; + # FFT Block + my $FOURIER_Block = MSR::CreateFFTBlk(\%All); + # END - FFT Block + # STATS Block # Don't know why but it is needed initially - $STAT_Block = - "############################################################### -STATISTIC --- 0000-00-00 00:00:00 -*** FIT DID NOT CONVERGE ***"; - + my $STAT_Block = "STATISTIC --- 0000-00-00 00:00:00\n*** FIT DID NOT CONVERGE ***"; + # END - STATS Block # Empty line at the end of each block - my $FullMSRFile = "$TitleLine$FitParaBlk\n$Full_T_Block\n$FUNCTIONS_Block\n$RUN_Block\n$COMMANDS_Block\n$PLOT_Block\n$FOURIER_Block\n$STAT_Block\n"; + my $FullMSRFile = "$TitleLine +############################################################### +$FitParaBlk +############################################################### +$Full_T_Block +############################################################### +$FUNCTIONS_Block +############################################################### +$RUN_Block +############################################################### +$COMMANDS_Block +############################################################### +$PLOT_Block +############################################################### +$FOURIER_Block +############################################################### +$STAT_Block\n"; # Return information and file return($Full_T_Block,\@Paramcomp,$FullMSRFile); } - - +sub CreateMSRSingleHist { ########################################################################## # CreateMSRSingleHist +# +# Input in %All +# Required: +# $All{"FitType1/2/3"} - Function types, 3 components +# $All{"LRBF"} - Histograms, comma separated +# $All{"Tis"} +# $All{"Tfs"} +# $All{"BINS"} +# $All{"FILENAME"} +# $All{"go"} +# $All{"TITLE"} +# $All{"RunNumbers"} +# $All{"FitAsyType"} +# $All{"BeamLine"} +# $All{"YEAR"} +# +# Optional: +# $All{"Sh_$Param"} +# $All{"ltc"} +# $All{"$Param"} value, error, min, and max +# $All{"logx/y"} +# $All{"Xi/f"} +# +# Output +# $Full_T_Block - Full theory block +# @Paramcomp - Space separated list of parameters for each component +# FILENAME.msr - MSR file saved +# ########################################################################## -sub CreateMSRSingleHist { my %All = %{$_[0]}; - + my $DEBUG = ""; # Start with empty array my @FitTypes = (); @@ -507,9 +488,8 @@ sub CreateMSRSingleHist { # Works for CGI script my $Step = $All{"go"}; - if ( $Step eq "PLOT" ) { - $FITMINTYPE = $EMPTY; - } elsif ( $Step eq "MIGRAD" ) { + my $FITMINTYPE = $EMPTY; + if ( $Step eq "MIGRAD" ) { $FITMINTYPE = "MINIMIZE\nMIGRAD\nHESSE"; } elsif ( $Step eq "MINOS" ) { $FITMINTYPE = "MIGRAD\nMINOS"; @@ -522,20 +502,15 @@ sub CreateMSRSingleHist { $FITMINTYPE = $All{"Minimization"}."\n".$All{"ErrorCalc"}; } - # First create the THEORY Block my ($Full_T_Block,$Paramcomp_ref)=MSR::CreateTheory(@FitTypes); my @Paramcomp = @$Paramcomp_ref; # If we have a FUNCTIONS Block the Full_T_Block should be # replaced by Func_T_Block - $FUNCTIONS_Block = $EMPTY; + my $FUNCTIONS_Block = $EMPTY; if ($All{"FunctionsBlock"} ne $EMPTY) { - $FUNCTIONS_Block = " -############################################################### -FUNCTIONS -############################################################### -".$All{"FunctionsBlock"}."\n"; + $FUNCTIONS_Block = "FUNCTIONS\n###############################################################\n".$All{"FunctionsBlock"}."\n"; $Full_T_Block=$All{"Func_T_Block"}; # remove all _N to end $Full_T_Block =~ s/_\d\b//g; @@ -547,11 +522,21 @@ FUNCTIONS # Counter of Params my $PCount = 1; + my $PLT = 2; + # For SingleHist fit + if ($All{"FitAsyType"} eq "SingleHist") { $PLT = 0;} + # Need to select here RUNSAuto or RUNSManual # $RUNSType = 0 (Auto) or 1 (Manual) my $RUNSType = 0; my @RUNS=(); if ($All{"RunNumbers"} ne $EMPTY) { + # Remove spaces and other illegal characters + $All{"RunNumbers"} =~ s/[\ \.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; + $All{"RunNumbers"} =~ s/[a-zA-Z]//g; + # Expand hyphens + $All{"RunNumbers"} = MSR::ExpandRunNumbers($All{"RunNumbers"}); + # Split commas @RUNS=split( /,/, $All{"RunNumbers"}); $RUNSType = 0; } @@ -584,16 +569,15 @@ FUNCTIONS foreach my $RUN (@RUNS) { # Until here identical to sub CreateMSR -####################################################################### -# For a single histogram fit we basically need to repeat this for each hist -# However, "physical" parameters such as Asymmetry, relaxation etc. should -# be the same for all histograms -# We distinguich between sharing among different runs to common parameters -# for different histograms. The first is done in the usual "Sharing" schame, -# while the second has to be done in the functions block. This can be done -# in a consistent, non-confusing algorithm + ####################################################################### + # For a single histogram fit we basically need to repeat this for each hist + # However, "physical" parameters such as Asymmetry, relaxation etc. should + # be the same for all histograms! + # We distinguich between sharing among different runs to common parameters + # for different histograms. The first is done in the usual "Sharing" schame, + # while the second has to be done in the functions block. This can be done + # in a consistent, non-confusing algorithm foreach my $Hist (@Hists) { - # Prepare the Parameters and initial values block my $component = 0; my $Single_RUN = $EMPTY; @@ -614,27 +598,21 @@ FUNCTIONS my @Params = split( /\s+/, $Parameters ); # Only the first histiograms has new physical parameters # the others keep only Phi if they have it - if ($iHist != 0) { - # look for Phi -# if ( grep( /^Phi$/, @Params ) ) { - # if it is there keep only that -# @Params=("Phi"); -# } - } # For the first component we need No and NBg for SingleHist fits if ( $component == 1 ) { unshift( @Params, ( "No", "NBg" ) ); } - foreach $Param (@Params) { - $Param_ORG = $Param; + foreach my $Param (@Params) { + my $Param_ORG = $Param; $Param=$Param.$Hist; if ( ($#FitTypes != 0) && !( $Param_ORG =~ m/^(No|NBg)/ ) ) { $Param = join( $EMPTY, $Param, "_", "$component" ); } # If we have only one RUN with one Histogram then everything is shared + my $Shared = 0; if ( $#RUNS == 0 && $#Hists == 0 ) { $Shared = 1; } @@ -677,8 +655,6 @@ FUNCTIONS } #################################################################################################### - print $Full_T_Block."\n"; - # Start preparing the parameters block if ($Shared) { @@ -705,12 +681,14 @@ FUNCTIONS # Finished preparing the FITPARAMETERS block ####################################################################### + # Start constructing RUN block here # For each defined range we need a block in the RUN-Block # Also for each histogram in Single Histograms fits - # Also for Imaginary and and Real for RRF fits - + $RUN = $RUNS[ $iRun - 1 ]; + $DEBUG = $DEBUG.MSR::CreateRUNBlk($RUN, $YEAR, $BeamLine, $All{"FitAsyType"}, $All{"LRBF"}, $All{"Tis"}, $All{"Tfs"}, $All{"BINS"}); + if ($All{"RUNSType"}) { $RUN_Line = MSR::RUNFileNameAuto($RUN,"0000",$EMPTY); } else { @@ -725,7 +703,7 @@ FUNCTIONS foreach ("t0","Bg1","Bg2","Data1","Data2") { $Name = "$_$Hist"; -# If empty fill with defaults + # If empty fill with defaults if ($All{$Name} eq $EMPTY) { $All{$Name}=MSR::T0BgData($_,$Hist,$BeamLine); } @@ -746,6 +724,11 @@ FUNCTIONS $Single_RUN = $Single_RUN . "$RUN_Line\n$Type_Line\n$NoBg_Line$Tmp_Hist_Line\n$Data_Line\n$MAP_Line\n$FRANGE_Line\n$PAC_Line\n\n"; + # This is from CreateRUNBlk + $DEBUG =~s /T0LINE/$T0_Line/; + $DEBUG =~s /BGLINE/$Bg_Line/; + $DEBUG =~s /DATALINE/$Data_Line/; + # Now add the appropriate values of fit range and packing my $Range_Min = 8; my $Range_Max = 0; @@ -770,17 +753,14 @@ FUNCTIONS ++$iRun; } + # From here again identical to sub CreateMSR # The number of runs is $NRUNS = $iRun - 1; - -# Start constructing all block + # Start constructing all block my $TitleLine = $All{"TITLE"}."\n# Run Numbers: ".$All{"RunNumbers"}; -# $TitleLine =~ s/\n//g; # Get parameter block from MSR::PrepParamTable(\%All); - my $FitParaBlk = " -############################################################### -FITPARAMETER + my $FitParaBlk = "FITPARAMETER ############################################################### # No Name Value Err Min Max "; my %PTable=MSR::PrepParamTable(\%All); @@ -797,25 +777,14 @@ FITPARAMETER $PCount $Param $value $error $error $minvalue $maxvalue"; } - $Full_T_Block = " -############################################################### -THEORY -############################################################### -$Full_T_Block -"; + $Full_T_Block = "THEORY\n###############################################################\n$Full_T_Block\n"; - $RUN_Block = - "############################################################### -$RUN_Block"; - - $COMMANDS_Block = - "############################################################### -COMMANDS -FITMINTYPE -SAVE -"; + # COMMAND Block + $COMMANDS_Block = "COMMANDS\nFITMINTYPE\nSAVE\n"; $COMMANDS_Block =~ s/FITMINTYPE/$FITMINTYPE/g; + # END- COMMAND Block + # PLOT Block # Check if log x and log y are selected my $logxy = $EMPTY; if ( $All{"logx"} eq "y" ) { $logxy = $logxy . "logx\n"; } @@ -831,50 +800,600 @@ SAVE } } - my $RRFBlock=MSR::CreateRRFBlock(\%All); - $PLOT_Block = - "############################################################### -PLOT $PLT -runs $RUNS_Line -$PRANGE_Line -$RRFBlock -$logxy"; + $VIEWBIN_Line =""; + if ( $All{"ViewBin"}!=0 ) { $VIEWBIN_Line = "view_packing ".$All{"ViewBin"};} - if ($All{"FUNITS"} eq $EMPTY) {$All{"FUNITS"}="MHz";} - if ($All{"FAPODIZATION"} eq $EMPTY) {$All{"FAPODIZATION"}="STRONG";} - if ($All{"FPLOT"} eq $EMPTY) {$All{"FPLOT"}="POWER";} - if ($All{"FPHASE"} eq $EMPTY) {$All{"FPHASE"}="8.5";} + my $RRFBlock=MSR::CreateRRFBlk(\%All); + $PLOT_Block = "PLOT $PLT\nruns $RUNS_Line\n$PRANGE_Line\n$VIEWBIN_Line\n$RRFBlock\n$logxy"; + #END - PLOT Block + # FFT Block + my $FOURIER_Block = MSR::CreateFFTBlk(\%All); + # END - FFT Block - $FOURIER_Block= - "############################################################### -FOURIER -units FUNITS # units either 'Gauss', 'MHz', or 'Mc/s' -fourier_power 12 -apodization FAPODIZATION # NONE, WEAK, MEDIUM, STRONG -plot FPLOT # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE -phase FPHASE -#range FRQMIN FRQMAX"; - - $FOURIER_Block=~ s/FUNITS/$All{"FUNITS"}/g; - $FOURIER_Block=~ s/FAPODIZATION/$All{"FAPODIZATION"}/g; - $FOURIER_Block=~ s/FPLOT/$All{"FPLOT"}/g; - $FOURIER_Block=~ s/FPHASE/$All{"FPHASE"}/g; - + # STATS Block # Don't know why but it is needed initially - $STAT_Block = - "############################################################### -STATISTIC --- 0000-00-00 00:00:00 -*** FIT DID NOT CONVERGE ***"; + my $STAT_Block = "STATISTIC --- 0000-00-00 00:00:00\n*** FIT DID NOT CONVERGE ***"; + # END - STATS Block + # Empty line at the end of each blocks + my $FullMSRFile = "$TitleLine +############################################################### +$FitParaBlk +############################################################### +$Full_T_Block +############################################################### +$FUNCTIONS_Block +############################################################### +$RUN_Block +############################################################### +$COMMANDS_Block +############################################################### +$PLOT_Block +############################################################### +$FOURIER_Block +############################################################### +$STAT_Block\n"; + +# Return information and file +# return($Full_T_Block,\@Paramcomp,$FullMSRFile."\n\n#DEBUG MSG\n$DEBUG\n"); + return($Full_T_Block,\@Paramcomp,$FullMSRFile); +} + +sub CreateMSRUni { +########################################################################## +# CreateMSRUni +# +# Input in %All +# Required: +# $All{"FitType1/2/3"} - Function types, 3 components +# $All{"LRBF"} - Histograms, comma separated +# $All{"Tis"} +# $All{"Tfs"} +# $All{"BINS"} +# $All{"FILENAME"} +# $All{"go"} +# $All{"TITLE"} +# $All{"RunNumbers"} +# $All{"FitAsyType"} +# $All{"BeamLine"} +# $All{"YEAR"} +# +# Optional: +# $All{"Sh_$Param"} +# $All{"ltc"} +# $All{"$Param"} value, error, min, and max +# $All{"logx/y"} +# $All{"Xi/f"} +# +# Output +# $Full_T_Block - Full theory block +# @Paramcomp - Space separated list of parameters for each component +# FILENAME.msr - MSR file saved +# +########################################################################## + my %All = %{$_[0]}; + my $DEBUG = ""; + # Start with empty array + my @FitTypes = (); + + foreach ($All{"FitType1"},$All{"FitType2"},$All{"FitType3"}) { + if ($_ ne "None") { + @FitTypes=(@FitTypes,$_); + } + } + + my @Hists = split( /,/, $All{"LRBF"} ); + # TODO + # : to separate two sets of asymmetries with same parameters + # Check the number of histograms + # should be 2 or 4 histograms + # should be checked in GUI + # for 2 simple asymmetry fit + # for 4 two run blocks with different geometric parameters: + # Alpha, No, NBg, Phi, Asy + + my @TiVals = split( /,/, $All{"Tis"} ); + my @TfVals = split( /,/, $All{"Tfs"} ); + my @BINVals = split( /,/, $All{"BINS"} ); + my $FILENAME = $All{"FILENAME"}; + my $BeamLine = $All{"BeamLine"}; + my $YEAR = $All{"YEAR"}; + + # Works for CGI script + my $Step = $All{"go"}; + my $FITMINTYPE = $EMPTY; + if ( $Step eq "MIGRAD" ) { + $FITMINTYPE = "MINIMIZE\nMIGRAD\nHESSE"; + } elsif ( $Step eq "MINOS" ) { + $FITMINTYPE = "MIGRAD\nMINOS"; + } elsif ( $Step eq "SIMPLEX" ) { + $FITMINTYPE = "SCAN\nSIMPLEX"; + } + + # Proper way + if ( $All{"Minimization"} ne $EMPTY && $All{"ErrorCalc"} ne $EMPTY && $Step ne "PLOT" ) { + $FITMINTYPE = $All{"Minimization"}."\n".$All{"ErrorCalc"}; + } + + # First create the THEORY Block + my ($Full_T_Block,$Paramcomp_ref)=MSR::CreateTheory(@FitTypes); + my @Paramcomp = @$Paramcomp_ref; + + # If we have a FUNCTIONS Block the Full_T_Block should be + # replaced by Func_T_Block + my $FUNCTIONS_Block = $EMPTY; + if ($All{"FunctionsBlock"} ne $EMPTY) { + $FUNCTIONS_Block = "FUNCTIONS\n###############################################################\n".$All{"FunctionsBlock"}."\n"; + $Full_T_Block=$All{"Func_T_Block"}; + # remove all _N to end (may fail with large number of parameters) + $Full_T_Block =~ s/_\d\b//g; + } + + # Counter for RUNS + my $iRun = 1; + + # Counter of Params + my $PCount = 1; + + my $PLT = 2; + # For SingleHist fit + if ($All{"FitAsyType"} eq "SingleHist") { $PLT = 0;} + + # Need to select here RUNSAuto or RUNSManual + # $RUNSType = 0 (Auto) or 1 (Manual) + my $RUNSType = 0; + my @RUNS=(); + if ($All{"RunNumbers"} ne $EMPTY) { + # Remove spaces and other illegal characters + $All{"RunNumbers"} =~ s/[\ \.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; + $All{"RunNumbers"} =~ s/[a-zA-Z]//g; + # Expand hyphens + $All{"RunNumbers"} = MSR::ExpandRunNumbers($All{"RunNumbers"}); + # Split commas + @RUNS=split( /,/, $All{"RunNumbers"}); + $RUNSType = 0; + } + elsif ($All{"RunFiles"} ne $EMPTY) { + @RUNS=split( /,/, $All{"RunFiles"}); + $RUNSType = 1; + } + + # Initialise $shcount, a counter for shared parameters + my $shcount = 1; + my $RUN_Block = $EMPTY; + my $RUNS_Line = $EMPTY; + + # range order + my $Range_Order = 1; + my $iHist = 0; + foreach my $RUN (@RUNS) { + if ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsyGLB") { + # Prepare the Parameters and initial values block + my $component = 0; + my $Single_RUN = $EMPTY; + + # Prepare map line for each run + my $MAP_Line = "map "; + + # How many non-shared parameter for this RUN? + my $nonsh = 0; + + # Prepeare Alpha line for the RUN block. Empty initially. + my $Alpha_Line = $EMPTY; + + # Loop over all components in the fit + foreach my $FitType (@FitTypes) { + ++$component; + my $Parameters = $Paramcomp[ $component - 1 ]; + my @Params = split( /\s+/, $Parameters ); + + # For the first component we need Alpha for Asymmetry fits + if ($component == 1) { + unshift( @Params, "Alpha" ); + } + + foreach my $Param (@Params) { + my $Param_ORG = $Param; + if ( ($#FitTypes != 0) && ($Param ne "Alpha") ) { + $Param = join( $EMPTY, $Param, "_", "$component" ); + } + + # If we have only one RUN then everything is shared + my $Shared = 0; + if ( $#RUNS == 0 ) { + $Shared = 1; + } + # Otherwise check input if it was marked as shared + else { + $Shared = $All{"Sh_$Param"}; + } + + # Alpha Line + # + # If you encounter alpha in the parameters list make sure + # to fill this line for the RUN block. + if ( $Param_ORG eq "Alpha" ) { + if ($Shared) { + # If alpha is shared use always the same line + $Alpha_Line = "alpha 1\n"; + } + else { + # Otherwise modify alpha line accordingly + $Alpha_Line = "alpha $PCount\n"; + } + } + + # End of Alpha Line + + # Start preparing the parameters block + if ($Shared) { + # Parameter is shared enough to keep order from first run + if ( $iRun == 1 ) { + $Full_T_Block =~ s/$Param_ORG/$PCount/; + ++$shcount; + ++$PCount; + } + } else { + # Parameter is not shared, use map unless it is a single RUN fit + # Skip adding to map line in these cases + if ( ( $Param ne "Alpha" && $#RUNS != 0 ) || ( !( $Param_ORG =~ m/^(No|NBg)/ ) && $#RUNS != 0 )) { + ++$nonsh; + $Full_T_Block =~ s/$Param_ORG/map$nonsh/; + $MAP_Line = join( ' ', $MAP_Line, $PCount ); + } + ++$PCount; + } + my $NtotPar = $PCount; + } + } + + # Finished preparing the FITPARAMETERS block + + # Start constructing RUN block here + # For each defined range we need a block in the RUN-Block + # Also for each histogram in Single Histograms fits + + $RUN = $RUNS[ $iRun - 1 ]; + + $DEBUG = $DEBUG.MSR::CreateRUNBlk($RUN, $YEAR, $BeamLine, $All{"FitAsyType"}, $All{"LRBF"}, $All{"Tis"}, $All{"Tfs"}, $All{"BINS"}); + + my $RUN_Line = $EMPTY; + if ($All{"RUNSType"}) { + $RUN_Line = MSR::RUNFileNameAuto($RUN,"0000",$EMPTY); + } else { + $RUN_Line = MSR::RUNFileNameAuto($RUN,$YEAR,$BeamLine); + } + + my $Type_Line = "fittype 2"; + my $Hist_Lines = + "forward $Hists[0]\nbackward $Hists[1]"; + + my $Bg_Line = "background"; + my $Data_Line = "data"; + my $T0_Line = "t0"; + my $NHist=1; + foreach my $Hist (@Hists) { + # If empty skip lines + if ($All{"Bg1$NHist"} ne $EMPTY && $All{"Bg2$NHist"} ne $EMPTY) { + $Bg_Line = $Bg_Line." ".$All{"Bg1$NHist"}." ".$All{"Bg2$NHist"}; + } + if ($All{"Data1$NHist"} ne $EMPTY && $All{"Data2$NHist"} ne $EMPTY) { + $Data_Line =$Data_Line." ".$All{"Data1$NHist"}." ".$All{"Data2$NHist"}; + } + if ($All{"t0$NHist"} ne $EMPTY) { + $T0_Line=$T0_Line." ".$All{"t0$NHist"}; + } + $NHist++; + } + + # Put T0_Line Bg_Line and Data_Line together if not empty + my $T0DataBg=$EMPTY; + if ($T0_Line ne "t0") { + $T0DataBg = $T0DataBg.$T0_Line."\n"; + } + if ($Bg_Line ne "background") { + $T0DataBg = $T0DataBg.$Bg_Line."\n"; + } + if ($Data_Line ne "data") { + $T0DataBg = $T0DataBg.$Data_Line."\n"; + } + + $FRANGE_Line = "fit TINI TFIN"; + $PAC_Line = "packing BINNING"; + + $Single_RUN = + "$RUN_Line\n$Type_Line\n$Alpha_Line$Hist_Lines\n$T0DataBg$MAP_Line\n$FRANGE_Line\n$PAC_Line\n\n"; + + # This is from CreateRUNBlk + $DEBUG =~s /T0LINE/$T0_Line/; + $DEBUG =~s /BGLINE/$Bg_Line/; + $DEBUG =~s /DATALINE/$Data_Line/; + + # Now add the appropriate values of fit range and packing + my $Range_Min = 8; + my $Range_Max = 0; + my $k = 0; + foreach my $Ti (@TiVals) { + my $Tf = $TfVals[$k]; + my $BIN = $BINVals[$k]; + $RUN_Block = $RUN_Block . $Single_RUN; + $RUN_Block =~ s/TINI/$Ti/g; + $RUN_Block =~ s/TFIN/$Tf/g; + $RUN_Block =~ s/BINNING/$BIN/g; + + # For multiple ranges use this + if ( $Ti < $Range_Min ) { $Range_Min = $Ti; } + if ( $Tf > $Range_Max ) { $Range_Max = $Tf; } + + $RUNS_Line = "$RUNS_Line " . $Range_Order; + ++$k; + ++$Range_Order; + } + } else { + ####################################################################### + # For a single histogram fit we basically need to repeat this for each hist + # However, "physical" parameters such as Asymmetry, relaxation etc. should + # be the same for all histograms! + # We distinguich between sharing among different runs to common parameters + # for different histograms. The first is done in the usual "Sharing" schame, + # while the second has to be done in the functions block. This can be done + # in a consistent, non-confusing algorithm + foreach my $Hist (@Hists) { + # Prepare the Parameters and initial values block + my $component = 0; + my $Single_RUN = $EMPTY; + + # Prepare map line for each run + my $MAP_Line = "map "; + + # How many non-shared parameter for this RUN? + my $nonsh = 0; + + # Prepeare No/NBg line for the RUN block. Empty initially. + my $NoBg_Line = $EMPTY; + + # Loop over all components in the fit + foreach my $FitType (@FitTypes) { + ++$component; + my $Parameters = $Paramcomp[ $component - 1 ]; + my @Params = split( /\s+/, $Parameters ); + # Only the first histiograms has new physical parameters + # the others keep only Phi if they have it + + # For the first component we need No and NBg for SingleHist fits + if ( $component == 1 ) { + unshift( @Params, ( "No", "NBg" ) ); + } + + foreach my $Param (@Params) { + my $Param_ORG = $Param; + $Param=$Param.$Hist; + if ( ($#FitTypes != 0) && !( $Param_ORG =~ m/^(No|NBg)/ ) ) { + $Param = join( $EMPTY, $Param, "_", "$component" ); + } + + # If we have only one RUN with one Histogram then everything is shared + my $Shared = 0; + if ( $#RUNS == 0 && $#Hists == 0 ) { + $Shared = 1; + } else { + # Otherwise check input if it was marked as shared + $Shared = $All{"Sh_$Param"}; + } + + # No and NBg Lines + # + # If you encounter No in the parameters list make sure + # to fill this line for the RUN block. + if ( $Param_ORG eq "No" ) { + if ($Shared) { + $NoBg_Line = "norm 1\n"; + } + else { + $NoBg_Line = "norm $PCount\n"; + } + + # Optional - add lifetime correction for SingleHist fits + if ( $All{"ltc"} eq "y" ) { + $NoBg_Line = $NoBg_Line . "lifetimecorrection\n"; + } + } + # If you encounter NBg in the parameters list make sure + # to fill this line for the RUN block. + elsif ( $Param_ORG eq "NBg" ) { + if ($Shared) { + $NoBg_Line = $NoBg_Line . "backgr.fit 2\n"; + } else { + $NoBg_Line = $NoBg_Line . "backgr.fit $PCount\n"; + } + } + + # End of No and NBg Lines + + # Start preparing the parameters block + if ($Shared) { + # Parameter is shared enough to keep order from first run + if ( $iRun == 1 ) { + $Full_T_Block =~ s/$Param_ORG/$PCount/; + ++$shcount; + ++$PCount; + } + } else { + # Parameter is not shared, use map unless it is a single RUN fit + # Skip adding to map line in these cases + if ( !( $Param_ORG =~ m/^(No|NBg)/ ) && ($#RUNS != 0 || $#Hist != 0)) { + ++$nonsh; + $Full_T_Block =~ s/$Param_ORG/map$nonsh/; + $MAP_Line = join( ' ', $MAP_Line, $PCount ); + } + ++$PCount; + } + $NtotPar = $PCount; + } + } + + # Finished preparing the FITPARAMETERS block + + # Start constructing RUN block here + # For each defined range we need a block in the RUN-Block + # Also for each histogram in Single Histograms fits + + $RUN = $RUNS[ $iRun - 1 ]; + + $DEBUG = $DEBUG.MSR::CreateRUNBlk($RUN, $YEAR, $BeamLine, $All{"FitAsyType"}, $All{"LRBF"}, $All{"Tis"}, $All{"Tfs"}, $All{"BINS"}); + + if ($All{"RUNSType"}) { + $RUN_Line = MSR::RUNFileNameAuto($RUN,"0000",$EMPTY); + } else { + $RUN_Line = MSR::RUNFileNameAuto($RUN,$YEAR,$BeamLine); + } + + $Type_Line = "fittype 0"; + $PLT = 0; + $Hist_Lines = "forward HIST"; + $Bg_Line = $EMPTY; + $Data_Line = "data"; + + foreach ("t0","Bg1","Bg2","Data1","Data2") { + $Name = "$_$Hist"; + # If empty fill with defaults + if ($All{$Name} eq $EMPTY) { + $All{$Name}=MSR::T0BgData($_,$Hist,$BeamLine); + } + } + $Bg_Line = $Bg_Line." ".$All{"Bg1$Hist"}." ".$All{"Bg2$Hist"}; + $Data_Line =$Data_Line." ".$All{"Data1$Hist"}." ".$All{"Data2$Hist"}; + if ($All{"t0$Hist"} ne $EMPTY) { + $Data_Line=$Data_Line."\nt0 ".$All{"t0$Hist"}; + } + + $FRANGE_Line = "fit TINI TFIN"; + $PAC_Line = "packing BINNING"; + + $Single_RUN = $EMPTY; + $Tmp_Hist_Line = $Hist_Lines; + $Tmp_Hist_Line =~ s/HIST/$Hist/g; + $Single_RUN = $Single_RUN + . "$RUN_Line\n$Type_Line\n$NoBg_Line$Tmp_Hist_Line\n$Data_Line\n$MAP_Line\n$FRANGE_Line\n$PAC_Line\n\n"; + + # This is from CreateRUNBlk + $DEBUG =~s /T0LINE/$T0_Line/; + $DEBUG =~s /BGLINE/$Bg_Line/; + $DEBUG =~s /DATALINE/$Data_Line/; + + # Now add the appropriate values of fit range and packing + my $Range_Min = 8; + my $Range_Max = 0; + my $k = 0; + foreach my $Ti (@TiVals) { + my $Tf = $TfVals[$k]; + my $BIN = $BINVals[$k]; + $RUN_Block = $RUN_Block . $Single_RUN; + $RUN_Block =~ s/TINI/$Ti/g; + $RUN_Block =~ s/TFIN/$Tf/g; + $RUN_Block =~ s/BINNING/$BIN/g; + + # For multiple ranges use this + if ( $Ti < $Range_Min ) { $Range_Min = $Ti; } + if ( $Tf > $Range_Max ) { $Range_Max = $Tf; } + $RUNS_Line = "$RUNS_Line " . $Range_Order; + ++$k; + ++$Range_Order; + } + ++$iHist; + } + } + ++$iRun; + } + + # The number of runs is + $NRUNS = $iRun - 1; + # Start constructing all blocks + my $TitleLine = $All{"TITLE"}."\n# Run Numbers: ".$All{"RunNumbers"}; + + # Get parameter block from MSR::PrepParamTable(\%All); + my $FitParaBlk = "FITPARAMETER +############################################################### +# No Name Value Err Min Max "; + my %PTable=MSR::PrepParamTable(\%All); + my $NParam=scalar keys( %PTable ); +# Fill the table with labels and values of parametr + for (my $iP=0;$iP<$NParam;$iP++) { + my ($Param,$value,$error,$minvalue,$maxvalue,$RUNtmp) = split(/,/,$PTable{$iP}); + if ( $minvalue == $maxvalue ) { + $minvalue = $EMPTY; + $maxvalue = $EMPTY; + } + $PCount=$iP+1; + $FitParaBlk = $FitParaBlk." + $PCount $Param $value $error $error $minvalue $maxvalue"; + } + + $Full_T_Block = "THEORY\n###############################################################\n$Full_T_Block\n"; + + # COMMAND Block + $COMMANDS_Block = "COMMANDS\nFITMINTYPE\nSAVE\n"; + $COMMANDS_Block =~ s/FITMINTYPE/$FITMINTYPE/g; + # END- COMMAND Block + + # PLOT Block + # Check if log x and log y are selected + my $logxy = $EMPTY; + if ( $All{"logx"} eq "y" ) { $logxy = $logxy . "logx\n"; } + if ( $All{"logy"} eq "y" ) { $logxy = $logxy . "logy\n"; } + + # Check if a plot range is defined (i.e. different from fit) + $PRANGE_Line = "use_fit_ranges"; + if ( $All{"Xi"} != $All{"Xf"} ) { + if ($All{"Yi"} != $All{"Yf"}) { + $PRANGE_Line = "range ".$All{"Xi"}." ".$All{"Xf"}." ".$All{"Yi"}." ".$All{"Yf"}; + } else { + $PRANGE_Line = "range ".$All{"Xi"}." ".$All{"Xf"}; + } + } + + $VIEWBIN_Line =""; + if ( $All{"ViewBin"}!=0 ) { $VIEWBIN_Line = "view_packing ".$All{"ViewBin"};} + + my $RRFBlock=MSR::CreateRRFBlk(\%All); + $PLOT_Block = "PLOT $PLT\nruns $RUNS_Line\n$PRANGE_Line\n$VIEWBIN_Line\n$RRFBlock\n$logxy"; + #END - PLOT Block + + # FFT Block + my $FOURIER_Block = MSR::CreateFFTBlk(\%All); + # END - FFT Block + + # STATS Block + # Don't know why but it is needed initially + my $STAT_Block = "STATISTIC --- 0000-00-00 00:00:00\n*** FIT DID NOT CONVERGE ***"; + # END - STATS Block # Empty line at the end of each block - my $FullMSRFile = "$TitleLine$FitParaBlk\n$Full_T_Block\n$FUNCTIONS_Block\n$RUN_Block\n$COMMANDS_Block\n$PLOT_Block\n$FOURIER_Block\n$STAT_Block\n"; + my $FullMSRFile = "$TitleLine +############################################################### +$FitParaBlk +############################################################### +$Full_T_Block +############################################################### +$FUNCTIONS_Block +############################################################### +$RUN_Block +############################################################### +$COMMANDS_Block +############################################################### +$PLOT_Block +############################################################### +$FOURIER_Block +############################################################### +$STAT_Block\n"; # Return information and file return($Full_T_Block,\@Paramcomp,$FullMSRFile); } + +sub CreateMSRGLB { ########################################################################## # CreateMSRGLB # @@ -888,33 +1407,32 @@ STATISTIC --- 0000-00-00 00:00:00 # FILENAME.msr - MSR file saved # ########################################################################## -sub CreateMSRGLB { my %All = %{$_[0]}; my @RUNS = (); if ($All{"RUNSType"}) { # Make sure this globalization is disabled if RunFiles are used @RUNS = split( /,/, $All{"RunFiles"} ); +# Make example from first run + $All{"RunFiles"}=$RUNS[0]; } else { - @RUNS = split( /,/, $All{"RunNumbers"} ); + @RUNS = split( /,/, MSR::ExpandRunNumbers($All{"RunNumbers"}) ); +# Make example from first run + $All{"RunNumbers"}=$RUNS[0]; } -# Make example from first run - $All{"RunNumbers"}=$RUNS[0]; - my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateMSR(\%All); - -# TODO: create global file from example file - + my ($Full_T_Block,$Paramcomp_ref,$MSRTemplate)= MSR::CreateMSRUni(\%All); # Return as usual my @Paramcomp = @$Paramcomp_ref; - return($Full_T_Block,\@Paramcomp); + + return($Full_T_Block,\@Paramcomp,$MSRTemplate); } -######################## -# Createheory -######################## sub CreateTheory { +######################## +# CreateTheory +######################## # This subroutine requires: # @FitTypes - the array of the types of components (summed) @@ -1178,12 +1696,12 @@ sub CreateTheory { ####################################################################### } return($Full_T_Block,\@Paramcomp); -} # End CreateTheory +} +sub ExtractBlks { ######################## # ExtractBlks ######################## -sub ExtractBlks { # This subroutine takes the MSR file as input and extracts the parameters # with the corresponding values, errors etc... @@ -1221,6 +1739,7 @@ sub ExtractBlks { } +sub T0BgData { ######################## # T0BgData # Function return the defaul value of t0, Bg and Data bin @@ -1229,7 +1748,6 @@ sub ExtractBlks { # $Hist is the histogram number # $BeamLine in the name of beamline ######################## -sub T0BgData { # Take this information as input arguments (my $Name, my $Hist, my $BeamLine) = @_; @@ -1239,7 +1757,13 @@ sub T0BgData { my %LEM=("1",",66000,66500,3419,63000", "2",",66000,66500,3419,63000", "3",",66000,66500,3419,63000", - "4",",66000,66500,3419,63000"); + "4",",66000,66500,3419,63000", + "5",",66000,66500,3419,63000", + "6",",66000,66500,3419,63000", + "7",",66000,66500,3419,63000", + "8",",66000,66500,3419,63000", + "9",",66000,66500,3419,63000", + "10",",66000,66500,3419,63000"); # my %GPS=("1",",40,120,135,8000", # "2",",40,120,135,8000", @@ -1272,17 +1796,17 @@ sub T0BgData { } +sub PrepParamTable { ######################## # PrepParamTable # Function return a Hash with a table of parameters for the fit # input should be # %All ######################## -sub PrepParamTable { # Take this information as input arguments # "Smart" default value of the fit parameters. my %Defaults = ( - "Asy", "0.15", "dAsy", "0.01", + "Asy", "0.20", "dAsy", "0.01", "Asy_min", "0", "Asy_max", "0", "Alpha", "1.0", "dAlpha", "0.01", "Alpha_min", "0", "Alpha_max", "0", @@ -1368,7 +1892,7 @@ sub PrepParamTable { foreach my $RUN (@RUNS) { $iRun++; $Component=1; - if ($All{"FitAsyType"} eq "Asymmetry") { + if ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsyGLB") { foreach my $FitType (@FitTypes) { my $Parameters=$Paramcomp[$Component-1]; my @Params = split( /\s+/, $Parameters ); @@ -1423,7 +1947,7 @@ sub PrepParamTable { $Component++; } } - elsif ($All{"FitAsyType"} eq "SingleHist") { + elsif ($All{"FitAsyType"} eq "SingleHist" || $All{"FitAsyType"} eq "SingHistGLB") { # For a single histogram fit we basically need to repeat this for each hist foreach my $Hist (@Hists) { $Component=1; @@ -1482,14 +2006,13 @@ sub PrepParamTable { return %ParTable; } - +sub ExportParams { ######################## # ExportParams # Function return a tab separated table of parameters for the fit # input should be # %All ######################## -sub ExportParams { my $erradd = "d"; my $minadd = "_min"; my $maxadd = "_max"; @@ -1521,14 +2044,6 @@ sub ExportParams { my @Paramcomp = @$Paramcomp_ref; my $Full_T_Block= $All{"Full_T_Block"}; -# Extract parameter block form the MSR file -# my $FILENAME=$All{"FILENAME"}; -# open (MSRF,q{<},"$FILENAME.msr" ); -# my @lines = ; -# close(IFILE); -# my $FPBlock_ref=MSR::ExtractBlks(@lines); -# my @FPBloc = @$FPBlock_ref; - # Then loop over expected parameters and extract their values and error bar my $PCount =0; my $iRun =0; @@ -1588,7 +2103,7 @@ sub ExportParams { $Component++; } } - elsif ($All{"FitAsyType"} eq "SingleHist") { + elsif ($All{"FitAsyType"} eq "SingleHist" ) { # For a single histogram fit we basically need to repeat this for each hist foreach my $Hist (@Hists) { $Component=1; @@ -1640,13 +2155,13 @@ sub ExportParams { return $TABLE; } +sub MSR2Dat { ######################## # MSR2Dat # Function return a tab separated table of parameters from an MSR file # input should be # @msrfile ######################## -sub MSR2Dat { # Take the msr file as input array of lines my @file=@_; @@ -1731,7 +2246,7 @@ sub MSR2Dat { return $DatFile; } - +sub RUNFileNameAuto { ######################## # RUNFileNameAuto # Function return the RUN_Line for a given RUN @@ -1740,7 +2255,6 @@ sub MSR2Dat { # $YEAR is the year # $BeamLine in the name of beamline ######################## -sub RUNFileNameAuto { # Take this information as input arguments (my $RUN, my $YEAR, my $BeamLine) = @_; @@ -1827,11 +2341,11 @@ sub RUNFileNameAuto { return $RUN_Line; } +sub CreateRRFBlk { ######################## -# CreateRRFBlock +# CreateRRFBlk ######################## # This creates the RRF related lines, these are the same always -sub CreateRRFBlock { my %All = %{$_[0]}; @@ -1846,13 +2360,12 @@ sub CreateRRFBlock { return $RRFBlock; } - +sub ExtractInfo { ######################## # ExtractInfo ######################## # Used to extract information from data file header. The header (using # "dump_header" is sent to this function from musrfit.cgi or MuSRFit -sub ExtractInfo { my ($header,$Arg) = @_; my @lines = split(/\n/,$header); @@ -1863,7 +2376,7 @@ sub ExtractInfo { } elsif ( $Arg eq "Temp" ) { foreach my $line (@lines) { - if ( $line =~ /Mean Sample_CF1/ ) { + if ( $line =~ /Temp/ ) { ( my $tmp, my $T ) = split( /=/, $line ); ( $T, $tmp ) = split( /\(/, $T ); $RTRN_Val = $T; @@ -1894,12 +2407,11 @@ sub ExtractInfo { return $RTRN_Val; } - +sub ExtractInfoLEM { ######################## # ExtractInfoLEM ######################## # Uset to extract information from summary files -sub ExtractInfoLEM { my ($RUN,$YEAR,$Arg) = @_; # Use file header my $Summ_File_Name = "lem" . substr( $YEAR, 2 ) . "_" . $RUN . ".summ"; @@ -1946,8 +2458,8 @@ sub ExtractInfoLEM { return $RTRN_Val; } -# Uset to extract information from log files sub ExtractInfoBulk { +# Uset to extract information from log files my ($RUN,$AREA,$YEAR,$Arg) = @_; my $RUNtmp=sprintf("%04d",$RUN); $RUN=$RUNtmp; @@ -1978,638 +2490,113 @@ sub ExtractInfoBulk { return $RTRN_Val; } -# Subroutine to create a clean run block (Not finished yet) sub CreateRUNBlk { +# Subroutine to create a clean run block (Not finished or used yet) # Take this information as input arguments - (my $RUN, my $YEAR, my $BeamLine, my $Fit_Type, my $LRBF, my $Ti, my $Tf, my $BIN) = @_; + my ($RUN,$YEAR,$BeamLine,$FitAsyType,$LRBF,$Ti,$Tf,$BIN) = @_; +# $RUN is the run number +# $YEAR is the corresponding year +# $BeamLine is the corresponding beam line +# $FitAsyType is SH or Asy +# $LRBF are the histogram numbers +# $Ti, $Tf and $BIN are the corresponding initial/final time range and binning factor respectively my $RUN_Block = -"RUN_LINE -fittype FIT_TYPE -ALPHA_LINE -forward FHIST -backward BHIST -MAP_LINE -fit TIVAL TFVAL -packing BINNING +"#RUN_LINE +#fittype FIT_TYPE +#ALPHA_LINE +#HISTOLINES +#MAP_LINE +#T0LINE +#BGLINE +#DATALINE +#fit TIVAL TFVAL +#packing BINNING "; + # HISTOLINES is the only thing that significantly changes between SH and Asy + + # Prepare the RUN_LINE my $RUN_Line = MSR::RUNFileNameAuto($RUN,$YEAR,$BeamLine); + # Split the histograms my @Hists = split( /,/, $LRBF ); + $Fit_Type = 0; + if ($FitAsyType eq "Asymmetry" || $FitAsyType eq "AsyGLB") { + $Fit_Type = 2; + } $RUN_Block =~ s/RUN_LINE/$RUN_Line/; $RUN_Block =~ s/FIT_TYPE/$Fit_Type/; - $RUN_Block =~ s/FHIST/$Hists[0]/; - $RUN_Block =~ s/BHIST/$Hists[1]/; $RUN_Block =~ s/TIVAL TFVAL/$Ti $Tf/; $RUN_Block =~ s/BINNING/$BIN/; + my $HistLines = $EMPTY; + my $Run_Block_ORG = $RUN_Block; + $RUN_Block = $EMPTY; + if ($Fit_Type == 2) { + # Asymmetry fit + $HistLines = "forward $Hists[0]\n#backward $Hists[1]"; + $RUN_Block = $RUN_Block.$Run_Block_ORG."\n\n"; + $RUN_Block =~ s/HISTOLINES/$HistLines/; + } else { + # Single histogram fit + foreach my $Hist (@Hists) { + $HistLines = "forward $Hist"; + # Create multiple blocks with the same lines except for the histogram line + $RUN_Block = $RUN_Block.$Run_Block_ORG."\n\n"; + $RUN_Block =~ s/HISTOLINES/$HistLines/; + } + } + return $RUN_Block; } - -########################################################################## -# CreateMSRSh - to generate template file for msr2data global fit -# -# Input in %All -# Required: -# $All{"FitType1/2/3"} - Function types, 3 components -# $All{"LRBF"} - Histograms, comma separated -# $All{"Tis"} -# $All{"Tfs"} -# $All{"BINS"} -# $All{"FILENAME"} -# $All{"go"} -# $All{"TITLE"} -# $All{"RunNumbers"} -# $All{"FitAsyType"} -# $All{"BeamLine"} -# $All{"YEAR"} -# -# Optional: -# $All{"Sh_$Param"} -# $All{"ltc"} -# $All{"$Param"} value, error, min, and max -# $All{"logx/y"} -# $All{"Xi/f"} -# -# Output -# $Full_T_Block - Full theory block -# @Paramcomp - Space separated list of parameters for each component -# FILENAME.msr - MSR file saved -# -########################################################################## -sub CreateMSRSh { +sub CreateFFTBlk { my %All = %{$_[0]}; - - # Start with empty array - my @FitTypes = (); - - foreach ($All{"FitType1"},$All{"FitType2"},$All{"FitType3"}) { - if ($_ ne "None") { - @FitTypes=(@FitTypes,$_); - } - } - - my @Hists = split( /,/, $All{"LRBF"} ); - # TODO - # : to separate two sets of asymmetries with same parameters - # Check the number of histograms - # should be 2 or 4 histograms - # should be checked in GUI - # for 2 simple asymmetry fit - # for 4 two run blocks with different geometric parameters: - # Alpha, No, NBg, Phi, Asy - - my @TiVals = split( /,/, $All{"Tis"} ); - my @TfVals = split( /,/, $All{"Tfs"} ); - my @BINVals = split( /,/, $All{"BINS"} ); - my $FILENAME = $All{"FILENAME"}; - my $BeamLine = $All{"BeamLine"}; - my $YEAR = $All{"YEAR"}; - - my $Step = $All{"go"}; - if ( $Step eq "PLOT" ) { - $FITMINTYPE = $EMPTY; - } - elsif ( $Step eq "MIGRAD" ) { - $FITMINTYPE = "MINIMIZE\nMIGRAD\nHESSE"; - } - elsif ( $Step eq "MINOS" ) { - $FITMINTYPE = "MIGRAD\nMINOS"; - } - elsif ( $Step eq "SIMPLEX" ) { - $FITMINTYPE = "SCAN\nSIMPLEX"; - } - - # Proper way - if ( $All{"Minimization"} ne $EMPTY && $All{"ErrorCalc"} ne $EMPTY && $Step ne "PLOT" ) { - $FITMINTYPE = $All{"Minimization"}."\n".$All{"ErrorCalc"}; - } - - - # First create the THEORY Block - my ($Full_T_Block,$Paramcomp_ref)=MSR::CreateTheory(@FitTypes); - my @Paramcomp = @$Paramcomp_ref; - - - # If we have a FUNCTIONS Block the Full_T_Block should be - # replaced by Func_T_Block - $FUNCTIONS_Block = $EMPTY; - if ($All{"FunctionsBlock"} ne $EMPTY) { - $FUNCTIONS_Block = " -############################################################### -FUNCTIONS -############################################################### -".$All{"FunctionsBlock"}."\n"; - $Full_T_Block=$All{"Func_T_Block"}; - # remove all _N to end (may fail with large number of parameters) - $Full_T_Block =~ s/_\d\b//g; - } - - # Counter of Params - my $PCount = 1; - - # Need to select here RUNSAuto or RUNSManual - # $RUNSType = 0 (Auto) or 1 (Manual) - my $RUNSType = 0; - my @RUNS=(); - if ($All{"RunNumbers"} ne $EMPTY) { - @RUNS=split( /,/, $All{"RunNumbers"}); - $RUNSType = 0; - } - elsif ($All{"RunFiles"} ne $EMPTY) { - @RUNS=split( /,/, $All{"RunFiles"}); - $RUNSType = 1; - } - - # $shcount is a counter for shared parameters - # msr2data \[1363 1365 1366\] _Dolly_2010 msr-1363 global - if ( $#RUNS == 0 ) { - my $shcount = 1; - } else { - if ( $All{"Sh_Alpha"} == 1 ) { - my $shcount = 1; - } else { - my $shcount = 0; - } - } - - $shcount = 1; - my $RUN_Block = $EMPTY; - my $RUNS_Line = $EMPTY; - - # range order - my $Range_Order = 1; - - # Create template from the first run - # Prepare the Parameters and initial values block - my $component = 0; - my $Single_RUN = $EMPTY; - - # Prepare map line for each run - my $MAP_Line = "map "; - - # How many non-shared parameter for this RUN? - my $nonsh = 0; - - # Prepeare Alpha line for the RUN block. Empty initially. - my $Alpha_Line = $EMPTY; - - # Loop over all components in the fit - foreach my $FitType (@FitTypes) { - ++$component; - my $Parameters = $Paramcomp[ $component - 1 ]; - my @Params = split( /\s+/, $Parameters ); - - # For the first component we need Alpha for Asymmetry fits - if ($component == 1) { - unshift( @Params, "Alpha" ); - } - - foreach $Param (@Params) { - $Param_ORG = $Param; - if ( ($#FitTypes != 0) && ($Param ne "Alpha") ) { - $Param = join( $EMPTY, $Param, "_", "$component" ); - } - - # If we have only one RUN then everything is shared - if ( $#RUNS == 0 ) { - $Shared = 1; - } - # Otherwise check input if it was marked as shared - else { - $Shared = $All{"Sh_$Param"}; - } - - # Alpha Line - # - # If you encounter alpha in the parameters list make sure - # to fill this line for the RUN block. - if ( $Param_ORG eq "Alpha" ) { - if ($Shared) { - # If alpha is shared use always the same line - $Alpha_Line = "alpha 1\n"; - } - else { - # Otherwise modify alpha line accordingly - $Alpha_Line = "alpha $PCount\n"; - } - } - - # End of Alpha Line -#################################################################################################### - - # Start preparing the parameters block - if ($Shared) { - - # Parameter is shared enough to keep order from first run - $Full_T_Block =~ s/$Param_ORG/$PCount/; - ++$shcount; - ++$PCount; - } else { - # Parameter is not shared, use map unless it is a single RUN fit - # Skip adding to map line in these cases - if ( $Param ne "Alpha" && $#RUNS != 0 ) - { - ++$nonsh; - $Full_T_Block =~ s/$Param_ORG/map$nonsh/; - $MAP_Line = join( ' ', $MAP_Line, $PCount ); - } - ++$PCount; - } - $NtotPar = $PCount; - } - } - - # Finished preparing the FITPARAMETERS block -####################################################################### - - # For each defined range we need a block in the RUN-Block - # Also for each histogram in Single Histograms fits - # Also for Imaginaryand and Real for RRF fits - - $RUN = $RUNS[0]; - - if ($All{"RUNSType"}) { - $RUN_Line = MSR::RUNFileNameAuto($RUN,"0000",$EMPTY); - } else { - $RUN_Line = MSR::RUNFileNameAuto($RUN,$YEAR,$BeamLine); - } - - $Type_Line = "fittype 2"; - $PLT = 2; - $Hist_Lines = - "forward $Hists[0]\nbackward $Hists[1]"; - - $Bg_Line = "background"; - $Data_Line = "data"; - $T0_Line = "t0"; - $NHist=1; - foreach $Hist (@Hists) { - foreach ("t0","Bg1","Bg2","Data1","Data2") { - $Name = "$_$NHist"; -# If empty fill with defaults -# if ($All{$Name} eq $EMPTY) { -# $All{$Name}=MSR::T0BgData($_,$Hist,$BeamLine); -# } - } -# If empty skip lines - if ($All{"Bg1$NHist"} ne $EMPTY && $All{"Bg2$NHist"} ne $EMPTY) { - $Bg_Line = $Bg_Line." ".$All{"Bg1$NHist"}." ".$All{"Bg2$NHist"}; - } - if ($All{"Data1$NHist"} ne $EMPTY && $All{"Data2$NHist"} ne $EMPTY) { - $Data_Line =$Data_Line." ".$All{"Data1$NHist"}." ".$All{"Data2$NHist"}; - } - if ($All{"t0$NHist"} ne $EMPTY) { - $T0_Line=$T0_Line." ".$All{"t0$NHist"}; - } - $NHist++; - } - -# Put T0_Line Bg_Line and Data_Line together if not empty - my $T0DataBg=$EMPTY; - if ($T0_Line ne "t0") { - $T0DataBg = $T0DataBg.$T0_Line."\n"; - } - if ($Bg_Line ne "background") { - $T0DataBg = $T0DataBg.$Bg_Line."\n"; - } - if ($Data_Line ne "data") { - $T0DataBg = $T0DataBg.$Data_Line."\n"; - } - - $FRANGE_Line = "fit TINI TFIN"; - $PAC_Line = "packing BINNING"; - - $Single_RUN = - "$RUN_Line\n$Type_Line\n$Alpha_Line$Hist_Lines\n$T0DataBg$MAP_Line\n$FRANGE_Line\n$PAC_Line\n\n"; - - # Now add the appropriate values of fit range and packing - my $Range_Min = 8; - my $Range_Max = 0; - my $k = 0; - foreach my $Ti (@TiVals) { - my $Tf = $TfVals[$k]; - my $BIN = $BINVals[$k]; - $RUN_Block = $RUN_Block . $Single_RUN; - $RUN_Block =~ s/TINI/$Ti/g; - $RUN_Block =~ s/TFIN/$Tf/g; - $RUN_Block =~ s/BINNING/$BIN/g; - - # For multiple ranges use this - if ( $Ti < $Range_Min ) { $Range_Min = $Ti; } - if ( $Tf > $Range_Max ) { $Range_Max = $Tf; } - - $RUNS_Line = "$RUNS_Line " . $Range_Order; - ++$k; - ++$Range_Order; - } - -# For the plotting command of multiple runs - foreach $RUN (@RUNS) { - foreach $Ti (@TiVals) { - $RUNS_Line = "$RUNS_Line " . $Range_Order; - ++$Range_Order; - } - } - -# Start constructing all blocks - my $TitleLine = $All{"TITLE"}."\n# Run Numbers: ".$All{"RunNumbers"}; -# $TitleLine =~ s/\n//g; - - # Get parameter block from MSR::PrepParamTable(\%All); - my $FitParaBlk = -"############################################################### -FITPARAMETER -############################################################### -# No Name Value Err Min Max "; - my %PTable=MSR::PrepParamTable(\%All); - my $NParam=scalar keys( %PTable ); -# Fill the table with labels and values of parametr - for (my $iP=0;$iP<$NParam;$iP++) { - my ($Param,$value,$error,$minvalue,$maxvalue,$RUNtmp) = split(/,/,$PTable{$iP}); - if ( $minvalue == $maxvalue ) { - $minvalue = $EMPTY; - $maxvalue = $EMPTY; - } - $PCount=$iP+1; - $FitParaBlk = $FitParaBlk." - $PCount $Param $value $error $error $minvalue $maxvalue"; - } - - $Full_T_Block = " -############################################################### -THEORY -############################################################### -$Full_T_Block -"; - - - $RUN_Block = - "############################################################### -$RUN_Block"; - - $COMMANDS_Block = - "############################################################### -COMMANDS -FITMINTYPE -SAVE -"; - $COMMANDS_Block =~ s/FITMINTYPE/$FITMINTYPE/g; - - # Check if log x and log y are selected - my $logxy = $EMPTY; - if ( $All{"logx"} eq "y" ) { $logxy = $logxy . "logx\n"; } - if ( $All{"logy"} eq "y" ) { $logxy = $logxy . "logy\n"; } - - # Check if a plot range is defined (i.e. different from fit) - $PRANGE_Line = "use_fit_ranges"; - if ( $All{"Xi"} != $All{"Xf"} ) { - if ($All{"Yi"} != $All{"Yf"}) { - $PRANGE_Line = "range ".$All{"Xi"}." ".$All{"Xf"}." ".$All{"Yi"}." ".$All{"Yf"}; - } else { - $PRANGE_Line = "range ".$All{"Xi"}." ".$All{"Xf"}; - } - } - - $VIEWBIN_Line =""; - if ( $All{"ViewBin"}!=0 ) { $VIEWBIN_Line = "view_packing ".$All{"ViewBin"};} - - my $RRFBlock=MSR::CreateRRFBlock(\%All); - $PLOT_Block = - "############################################################### -PLOT $PLT -runs $RUNS_Line -$PRANGE_Line -$VIEWBIN_Line -$RRFBlock -$logxy"; - if ($All{"FUNITS"} eq $EMPTY) {$All{"FUNITS"}="MHz";} if ($All{"FAPODIZATION"} eq $EMPTY) {$All{"FAPODIZATION"}="STRONG";} if ($All{"FPLOT"} eq $EMPTY) {$All{"FPLOT"}="POWER";} if ($All{"FPHASE"} eq $EMPTY) {$All{"FPHASE"}="8.5";} + my $FrqRange = $EMPTY; + if ($All{"FRQMAX"} ne $EMPTY && $All{"FRQMIN"} ne $EMPTY && $All{"FRQMAX"} ne $All{"FRQMIN"}) { + $FrqRange = "range ".$All{"FRQMIN"}." ".$All{"FRQMAX"}; + } - - $FOURIER_Block= - "############################################################### -FOURIER + my $FOURIER_Block="FOURIER units FUNITS # units either 'Gauss', 'MHz', or 'Mc/s' fourier_power 12 apodization FAPODIZATION # NONE, WEAK, MEDIUM, STRONG plot FPLOT # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE phase FPHASE -#range FRQMIN FRQMAX"; +FRQRANGE"; $FOURIER_Block=~ s/FUNITS/$All{"FUNITS"}/g; $FOURIER_Block=~ s/FAPODIZATION/$All{"FAPODIZATION"}/g; $FOURIER_Block=~ s/FPLOT/$All{"FPLOT"}/g; $FOURIER_Block=~ s/FPHASE/$All{"FPHASE"}/g; + $FOURIER_Block=~ s/FRQRANGE/$FrqRange/g; - # Don't know why but it is needed initially - $STAT_Block = - "############################################################### -STATISTIC --- 0000-00-00 00:00:00 -*** FIT DID NOT CONVERGE ***"; - - - # Empty line at the end of each block - my $FullMSRFile = "$TitleLine$FitParaBlk\n$Full_T_Block\n$FUNCTIONS_Block\n$RUN_Block\n$COMMANDS_Block\n$PLOT_Block\n$FOURIER_Block\n$STAT_Block\n"; - -# Return information and file - return($Full_T_Block,\@Paramcomp,$FullMSRFile); + return $FOURIER_Block; } -######################## -# PrepParamTableSh - Prepare fir parameters block for global fit using msr2data -# Function return a Hash with a table of parameters for the fit -# input should be -# %All -######################## -sub PrepParamTableSh { -# Take this information as input arguments -# "Smart" default value of the fit parameters. - my %Defaults = ( - "Asy", "0.15", "dAsy", "0.01", - "Asy_min", "0", "Asy_max", "0", - "Alpha", "1.0", "dAlpha", "0.01", - "Alpha_min", "0", "Alpha_max", "0", - "No", "300.0", "dNo", "0.01", - "No_min", "0", "No_max", "0", - "NBg", "30.0", "dNBg", "0.01", - "NBg_min", "0", "NBg_max", "0", - "Lam", "1.0", "dLam", "0.01", - "Lam_min", "0", "Lam_max", "0", - "Gam", "1.0", "dGam", "0.01", - "Gam_min", "0", "Gam_max", "0", - "Bet", "0.5", "dBet", "0.01", - "Bet_min", "0", "Bet_max", "0", - "Two", "2.0", "dTwo", "0.0", - "Two_min", "0", "Two_max", "0", - "Del", "0.1", "dDel", "0.01", - "Del_min", "0", "Del_max", "0", - "Sgm", "0.1", "dSgm", "0.01", - "Sgm_min", "0", "Sgm_max", "0", - "Aa", "60.", "dAa", "0.01", - "Aa_min", "0", "Aa_max", "0", - "q", "0.1", "dq", "0.01", - "q_min", "0", "q_max", "0", - "Bg", "0.036", "dBg", "0.01", - "Bg_min", "0", "Bg_max", "0", - "bgrlx", "0.", "dbgrlx", "0.0", - "bgrlx_min", "0", "bgrlx_max", "0", - "Frq", "1.0", "dFrq", "1.", - "Frq_min", "0", "Frq_max", "0", - "Field", "100.0", "dField", "1.", - "Field_min", "0", "Field_max", "0", - "Energy", "14.1", "dEnergy", "0.", - "Energy_min", "0", "Energy_max", "0", - "DeadLayer", "10.", "dDeadLayer", "0.1", - "DeadLayer_min", "0", "DeadLayer_max", "0", - "Lambda", "128.1", "dLambda", "0.1", - "Lambda_min", "0", "Lambda_max", "0", - "Phi", "1.", "dPhi", "0.01", - "Phi_min", "0", "Phi_max", "0" - ); - - my $erradd = "d"; - my $minadd = "_min"; - my $maxadd = "_max"; - -# First assume nothing is shared - my $Shared = 0; - -# Reset output Hash - %ParTable = (); - - my %All = %{$_[0]}; - my @RUNS = (); - if ($All{"RUNSType"}) { - @RUNS = split( /,/, $All{"RunFiles"} ); - } else { - @RUNS = split( /,/, $All{"RunNumbers"} ); +sub ExpandRunNumbers { +# Subroutine to conver hyphens in the RunNumbers into a series of comma separated runs + my ($RunNumbers) = @_; + # Split by commas + @RUNS=split( /,/, $RunNumbers); + # Find array members that include a hyphen (-) + my @RUNseries = grep { /\-/ } @RUNS; + foreach my $tmp (@RUNseries) { + # Each item that includes a hyphen is expanded as from-to array + my ($Begin,$End)=split('-',$tmp); + my @Series = ($Begin..$End); + # Join the expanded series using commas + my $RunJoined = join(',',@Series); + # Replace the original hyphens by the expanded series + $RunNumbers =~ s/$tmp/$RunJoined/; } - my @Hists = split( /,/, $All{"LRBF"} ); - - my @FitTypes =(); - foreach my $FitType ($All{"FitType1"}, $All{"FitType2"}, $All{"FitType3"}) { - if ( $FitType ne "None" ) { push( @FitTypes, $FitType ); } - } -# Get theory block to determine the size of the table - my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateTheory(@FitTypes); -# For now the line below does not work. Why? -# my $Paramcomp_ref=$All{"Paramcomp_ref"}; - my @Paramcomp = @$Paramcomp_ref; - my $Full_T_Block= $All{"Full_T_Block"}; - my $PCount =0; - my $value =0; - my $error = 0; - my $minvalue = 0; - my $maxvalue = 0; - my $Component=1; - - $Component=1; - if ($All{"FitAsyType"} eq "Asymmetry") { - foreach my $FitType (@FitTypes) { - my $Parameters=$Paramcomp[$Component-1]; - my @Params = split( /\s+/, $Parameters ); - if ( $Component == 1 ) { - unshift( @Params, "Alpha" ); - } - -# This is the counter for parameters of this component - my $NP=1; - $Shared = 0; -# Change state/label of parameters - foreach my $Param (@Params) { - my $Param_ORG = $Param; - if ( $#FitTypes != 0 && ( $Param ne "Alpha" ) ){ - $Param = join( $EMPTY, $Param, "_", "$Component" ); - } - - $Shared = $All{"Sh_$Param"}; -# It there are multiple runs index the parameters accordingly - my $RUNtmp=sprintf("%04d",$RUN); - if ($Shared!=1) { - $Param=$Param."_".$RUNtmp; - } -# Check if this parameter has been initialized befor. If not take from defaults - $value = $All{"$Param"}; - if ( $value ne $EMPTY ) { - $error = $All{"$erradd$Param"}; - $minvalue = $All{"$Param$minadd"}; - $maxvalue = $All{"$Param$maxadd"}; - } else { -# We have two options here, either take default values or take values of previous -# run if available - $value = $Defaults{$Param_ORG}; - $error = $Defaults{ join( $EMPTY, $erradd, $Param_ORG ) }; - $minvalue = $Defaults{ join($EMPTY, $Param_ORG, $minadd ) }; - $maxvalue = $Defaults{ join($EMPTY, $Param_ORG, $maxadd ) }; - } - $values=join(",",$Param,$value,$error,$minvalue,$maxvalue,$RUN); - $ParTable{$PCount}=$values; - $PCount++; - } - $NP++; - } - $Component++; - } - elsif ($All{"FitAsyType"} eq "SingleHist") { -# For a single histogram fit we basically need to repeat this for each hist - foreach my $Hist (@Hists) { - $Component=1; - foreach my $FitType (@FitTypes) { - my $Parameters=$Paramcomp[$Component-1]; - my @Params = split( /\s+/, $Parameters ); - if ( $Component == 1 ) { - unshift( @Params, ( "No", "NBg" ) ); - } - -# This is the counter for parameters of this component - my $NP=1; - $Shared = 0; -# Change state/label of parameters - foreach my $Param (@Params) { - my $Param_ORG = $Param; - # If multiple histograms (sum or difference) take the first histogram only - ($Hist,$tmp) = split(/ /,$Hist); - $Param=$Param.$Hist; - if ( $#FitTypes != 0 && ( $Param_ORG ne "No" && $Param_ORG ne "NBg" ) ){ - $Param = join( $EMPTY, $Param, "_", "$Component" ); - } - - $Shared = $All{"Sh_$Param"}; -# It there are multiple runs index the parameters accordingly - my $RUNtmp=sprintf("%04d",$RUN); - if ($Shared!=1) {$Param=$Param."_".$RUNtmp;} -# Check if this parameter has been initialized befor. If not take from defaults - $value = $All{"$Param"}; - if ( $value ne $EMPTY ) { - $error = $All{"$erradd$Param"}; - $minvalue = $All{"$Param$minadd"}; - $maxvalue = $All{"$Param$maxadd"}; - } else { -# I need this although it is already in the MSR.pm module, just for this table -# We can remove it from the MSR module later... -# Or keep in the MSR as function ?? - $value = $Defaults{$Param_ORG}; - $error = $Defaults{ join( $EMPTY, $erradd, $Param_ORG ) }; - $minvalue = $Defaults{ join($EMPTY, $Param_ORG, $minadd ) }; - $maxvalue = $Defaults{ join($EMPTY, $Param_ORG, $maxadd ) }; - } - $values=join(",",$Param,$value,$error,$minvalue,$maxvalue,$RUN); - $ParTable{$PCount}=$values; - $PCount++; - } - $NP++; - } - $Component++; - } - } - return %ParTable; + return $RunNumbers; } 1; diff --git a/src/external/MuSRFitGUI/MuSRFit4.pm b/src/external/MuSRFitGUI/MuSRFit4.pm index 2bb46742..a589f149 100644 --- a/src/external/MuSRFitGUI/MuSRFit4.pm +++ b/src/external/MuSRFitGUI/MuSRFit4.pm @@ -278,14 +278,17 @@ sub CreateAllInput() $All{"Tfs"} = this->{ui}->tfs->text; $All{"BINS"} = this->{ui}->bins->text; $All{"FitAsyType"} = this->{ui}->fitAsyType->currentText; + $All{"FitAsyType"} =~ s/ //g; $All{"LRBF"} = this->{ui}->histsLRBF->text; my @Hists = split(/,/, $All{"LRBF"} ); # Lifetime corrections in enabled/visible only for SingleHis fits if ( $All{"FitAsyType"} eq "Asymmetry" ) { this->{ui}->ltc->setHidden(1); + $All{"fittype"}=2; } elsif ( $All{"FitAsyType"} eq "SingleHist" ) { this->{ui}->ltc->setHidden(0); + $All{"fittype"}=0; } # From Fitting Tab @@ -313,13 +316,16 @@ sub CreateAllInput() $All{"ErrorCalc"} = this->{ui}->errorCalc->currentText(); $All{"go"}=$All{"ErrorCalc"}; +# Commands block + $All{"CommandsBlock"}= $All{"Minimization"}."\n".$All{"ErrorCalc"}; + RunSelectionToggle(); my @RUNS = (); if ($All{"RUNSType"} ) { @RUNS = split( /,/, $All{"RunFiles"}); } else { $All{"RunNumbers"} =~ s/[\ \.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g; - @RUNS = split( /,/, $All{"RunNumbers"} ); + @RUNS = split( /,/, MSR::ExpandRunNumbers($All{"RunNumbers"}) ); } # From MSR File Tab @@ -534,13 +540,11 @@ sub CallMSRCreate() print OUTF ("$FullMSRFile"); close(OUTF); } else { -# my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRSh(\%All); my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSR(\%All); # Open output file FILENAME.msr open( OUTF,q{>},"$FILENAME" ); print OUTF ("$FullMSRFile"); close(OUTF); - # if it is multiple runs then the produced file is a template my $FILENAME=$All{"FILENAME"}.".msr"; my $Extension = "_".$All{"BeamLine"}."_".$All{"YEAR"}; @@ -674,7 +678,7 @@ sub ActivateT0Hists() sub ActivateShComp() { my %All=CreateAllInput(); - my @RUNS = split( /,/, $All{"RunNumbers"} ); + my @RUNS = split( /,/, MSR::ExpandRunNumbers($All{"RunNumbers"}) ); # Hide all sharing components this->{ui}->sharingComp1->setHidden(1); @@ -906,9 +910,9 @@ sub t0Update() foreach ("t0","Bg1","Bg2","Data1","Data2") { my $Name = "$_$NHist"; my $tmp=MSR::T0BgData($_,$Hist,$All{"BeamLine"}); - if (defined(child("Qt::Widget",$Name))) { - child("Qt::Widget",$Name)->setText($tmp); - } +# if (defined(child("Qt::Widget",$Name))) { +# child("Qt::Widget",$Name)->setText($tmp); +# } } $NHist++ } @@ -986,7 +990,7 @@ sub AppendToFunctions() sub InitializeFunctions() { my %All=CreateAllInput(); - my @RUNS = split( /,/, $All{"RunNumbers"} ); + my @RUNS = split( /,/, MSR::ExpandRunNumbers($All{"RunNumbers"}) ); my @FitTypes =(); foreach my $FitType ($All{"FitType1"}, $All{"FitType2"}, $All{"FitType3"}) { diff --git a/src/external/MuSRFitGUI/MuSRFit4.ui b/src/external/MuSRFitGUI/MuSRFit4.ui index d6b8805e..a8ce1a1e 100644 --- a/src/external/MuSRFitGUI/MuSRFit4.ui +++ b/src/external/MuSRFitGUI/MuSRFit4.ui @@ -6,8 +6,8 @@ 0 0 - 600 - 505 + 674 + 541 @@ -236,7 +236,17 @@ - SingleHist + Single Hist + + + + + Asymmetry GLB + + + + + Single Hist GLB @@ -303,7 +313,7 @@ - + 1 1 @@ -311,7 +321,7 @@ 0 - 80 + 100 @@ -323,6 +333,15 @@ + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + 0 @@ -360,119 +379,6 @@ - - - - - 0 - 0 - - - - - 0 - 20 - - - - Year - - - false - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - - 16777215 - 30 - - - - On beam line - - - false - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - - 16777215 - 25 - - - - - LEM - - - - - GPS - - - - - Dolly - - - - - LTF - - - - - LEM (PPC) - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 181 - 21 - - - - @@ -507,6 +413,129 @@ + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 181 + 21 + + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + + 16777215 + 25 + + + + + LEM + + + + + GPD + + + + + HAL + + + + + GPS + + + + + Dolly + + + + + LTF + + + + + LEM (PPC) + + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + Year + + + false + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + 16777215 + 30 + + + + On beam line + + + false + + + @@ -3488,7 +3517,7 @@ 10 18 265 - 100 + 107 @@ -5412,8 +5441,8 @@ 0 0 - 600 - 20 + 674 + 27 diff --git a/src/external/MuSRFitGUI/Ui_MuSRFit4.pm b/src/external/MuSRFitGUI/Ui_MuSRFit4.pm index 8a0fe95f..4ac83c51 100644 --- a/src/external/MuSRFitGUI/Ui_MuSRFit4.pm +++ b/src/external/MuSRFitGUI/Ui_MuSRFit4.pm @@ -5,8 +5,8 @@ ################################################################################# ## Form generated from reading UI file 'MuSRFit4.ui' ## -## Created: Thu Mar 23 16:58:52 2017 -## by: Qt User Interface Compiler version 4.8.6 +## Created: Mon Jan 29 14:11:03 2018 +## by: Qt User Interface Compiler version 4.8.7 ## ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ @@ -162,24 +162,24 @@ sub year { return shift->{year}; } -sub yearLabel { - return shift->{yearLabel}; -} - -sub beamLineLabel { - return shift->{beamLineLabel}; -} - -sub beamLine { - return shift->{beamLine}; +sub runNumbers { + return shift->{runNumbers}; } sub spacer2 { return shift->{spacer2}; } -sub runNumbers { - return shift->{runNumbers}; +sub beamLine { + return shift->{beamLine}; +} + +sub yearLabel { + return shift->{yearLabel}; +} + +sub beamLineLabel { + return shift->{beamLineLabel}; } sub groupBox { @@ -993,7 +993,7 @@ sub setupUi { if ( !defined $muSRFit4->objectName() ) { $muSRFit4->setObjectName( "muSRFit4" ); } - $muSRFit4->resize( 600, 505 ); + $muSRFit4->resize( 674, 541 ); my $sizePolicy = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::Expanding() ); $self->{$sizePolicy} = $sizePolicy; $sizePolicy->setHorizontalStretch( 1 ); @@ -1219,9 +1219,13 @@ sub setupUi { my $runsAuto = Qt::GroupBox( $runsPage ); $self->{runsAuto} = $runsAuto; $runsAuto->setObjectName( "runsAuto" ); - $sizePolicy->setHeightForWidth( $runsAuto->sizePolicy()->hasHeightForWidth() ); - $runsAuto->setSizePolicy( $sizePolicy ); - $runsAuto->setMinimumSize( Qt::Size(0, 80) ); + my $sizePolicy4 = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::Maximum() ); + $self->{$sizePolicy4} = $sizePolicy4; + $sizePolicy4->setHorizontalStretch( 1 ); + $sizePolicy4->setVerticalStretch( 1 ); + $sizePolicy4->setHeightForWidth( $runsAuto->sizePolicy()->hasHeightForWidth() ); + $runsAuto->setSizePolicy( $sizePolicy4 ); + $runsAuto->setMinimumSize( Qt::Size(0, 100) ); $runsAuto->setAlignment( Qt::AlignHCenter()|Qt::AlignTop() ); my $gridLayout_3 = Qt::GridLayout( $runsAuto ); $self->{gridLayout_3} = $gridLayout_3; @@ -1232,6 +1236,8 @@ sub setupUi { $self->{runNumbers_2} = $runNumbers_2; $runNumbers_2->setSpacing( 0 ); $runNumbers_2->setObjectName( "runNumbers_2" ); + $runNumbers_2->setSizeConstraint( Qt::Layout::SetDefaultConstraint() ); + $runNumbers_2->setContentsMargins(-1, 0, -1, 0 ); my $year = Qt::ComboBox( $runsAuto ); $self->{year} = $year; $year->setObjectName( "year" ); @@ -1246,45 +1252,6 @@ sub setupUi { $runNumbers_2->addWidget( $year, 1, 4, 1, 1 ); - my $yearLabel = Qt::Label( $runsAuto ); - $self->{yearLabel} = $yearLabel; - $yearLabel->setObjectName( "yearLabel" ); - my $sizePolicy4 = Qt::SizePolicy( Qt::SizePolicy::Preferred(), Qt::SizePolicy::Preferred() ); - $self->{$sizePolicy4} = $sizePolicy4; - $sizePolicy4->setHorizontalStretch( 0 ); - $sizePolicy4->setVerticalStretch( 0 ); - $sizePolicy4->setHeightForWidth( $yearLabel->sizePolicy()->hasHeightForWidth() ); - $yearLabel->setSizePolicy( $sizePolicy4 ); - $yearLabel->setMinimumSize( Qt::Size(0, 20) ); - $yearLabel->setWordWrap( 0 ); - - $runNumbers_2->addWidget( $yearLabel, 1, 3, 1, 1 ); - - my $beamLineLabel = Qt::Label( $runsAuto ); - $self->{beamLineLabel} = $beamLineLabel; - $beamLineLabel->setObjectName( "beamLineLabel" ); - $sizePolicy4->setHeightForWidth( $beamLineLabel->sizePolicy()->hasHeightForWidth() ); - $beamLineLabel->setSizePolicy( $sizePolicy4 ); - $beamLineLabel->setMinimumSize( Qt::Size(0, 20) ); - $beamLineLabel->setMaximumSize( Qt::Size(16777215, 30) ); - $beamLineLabel->setWordWrap( 0 ); - - $runNumbers_2->addWidget( $beamLineLabel, 1, 1, 1, 1 ); - - my $beamLine = Qt::ComboBox( $runsAuto ); - $self->{beamLine} = $beamLine; - $beamLine->setObjectName( "beamLine" ); - $sizePolicy2->setHeightForWidth( $beamLine->sizePolicy()->hasHeightForWidth() ); - $beamLine->setSizePolicy( $sizePolicy2 ); - $beamLine->setMinimumSize( Qt::Size(0, 20) ); - $beamLine->setMaximumSize( Qt::Size(16777215, 25) ); - - $runNumbers_2->addWidget( $beamLine, 1, 2, 1, 1 ); - - my $spacer2 = Qt::SpacerItem( 181, 21, Qt::SizePolicy::Expanding(), Qt::SizePolicy::Minimum() ); - - $runNumbers_2->addItem( $spacer2, 1, 0, 1, 1 ); - my $runNumbers = Qt::LineEdit( $runsAuto ); $self->{runNumbers} = $runNumbers; $runNumbers->setObjectName( "runNumbers" ); @@ -1296,6 +1263,45 @@ sub setupUi { $runNumbers_2->addWidget( $runNumbers, 0, 0, 1, 5 ); + my $spacer2 = Qt::SpacerItem( 181, 21, Qt::SizePolicy::Expanding(), Qt::SizePolicy::Minimum() ); + + $runNumbers_2->addItem( $spacer2, 1, 0, 1, 1 ); + + my $beamLine = Qt::ComboBox( $runsAuto ); + $self->{beamLine} = $beamLine; + $beamLine->setObjectName( "beamLine" ); + $sizePolicy2->setHeightForWidth( $beamLine->sizePolicy()->hasHeightForWidth() ); + $beamLine->setSizePolicy( $sizePolicy2 ); + $beamLine->setMinimumSize( Qt::Size(0, 20) ); + $beamLine->setMaximumSize( Qt::Size(16777215, 25) ); + + $runNumbers_2->addWidget( $beamLine, 1, 2, 1, 1 ); + + my $yearLabel = Qt::Label( $runsAuto ); + $self->{yearLabel} = $yearLabel; + $yearLabel->setObjectName( "yearLabel" ); + my $sizePolicy5 = Qt::SizePolicy( Qt::SizePolicy::Preferred(), Qt::SizePolicy::Preferred() ); + $self->{$sizePolicy5} = $sizePolicy5; + $sizePolicy5->setHorizontalStretch( 0 ); + $sizePolicy5->setVerticalStretch( 0 ); + $sizePolicy5->setHeightForWidth( $yearLabel->sizePolicy()->hasHeightForWidth() ); + $yearLabel->setSizePolicy( $sizePolicy5 ); + $yearLabel->setMinimumSize( Qt::Size(0, 20) ); + $yearLabel->setWordWrap( 0 ); + + $runNumbers_2->addWidget( $yearLabel, 1, 3, 1, 1 ); + + my $beamLineLabel = Qt::Label( $runsAuto ); + $self->{beamLineLabel} = $beamLineLabel; + $beamLineLabel->setObjectName( "beamLineLabel" ); + $sizePolicy5->setHeightForWidth( $beamLineLabel->sizePolicy()->hasHeightForWidth() ); + $beamLineLabel->setSizePolicy( $sizePolicy5 ); + $beamLineLabel->setMinimumSize( Qt::Size(0, 30) ); + $beamLineLabel->setMaximumSize( Qt::Size(16777215, 30) ); + $beamLineLabel->setWordWrap( 0 ); + + $runNumbers_2->addWidget( $beamLineLabel, 1, 1, 1, 1 ); + $gridLayout_3->addLayout( $runNumbers_2, 0, 0, 1, 1 ); @@ -1305,12 +1311,12 @@ sub setupUi { my $groupBox = Qt::GroupBox( $runsPage ); $self->{groupBox} = $groupBox; $groupBox->setObjectName( "groupBox" ); - my $sizePolicy5 = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::Expanding() ); - $self->{$sizePolicy5} = $sizePolicy5; - $sizePolicy5->setHorizontalStretch( 0 ); - $sizePolicy5->setVerticalStretch( 0 ); - $sizePolicy5->setHeightForWidth( $groupBox->sizePolicy()->hasHeightForWidth() ); - $groupBox->setSizePolicy( $sizePolicy5 ); + my $sizePolicy6 = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::Expanding() ); + $self->{$sizePolicy6} = $sizePolicy6; + $sizePolicy6->setHorizontalStretch( 0 ); + $sizePolicy6->setVerticalStretch( 0 ); + $sizePolicy6->setHeightForWidth( $groupBox->sizePolicy()->hasHeightForWidth() ); + $groupBox->setSizePolicy( $sizePolicy6 ); $groupBox->setMinimumSize( Qt::Size(0, 220) ); $groupBox->setBaseSize( Qt::Size(0, 0) ); my $gridLayout_8 = Qt::GridLayout( $groupBox ); @@ -1761,8 +1767,8 @@ sub setupUi { my $buttonGroupSharing = Qt::GroupBox( $sharingPage ); $self->{buttonGroupSharing} = $buttonGroupSharing; $buttonGroupSharing->setObjectName( "buttonGroupSharing" ); - $sizePolicy5->setHeightForWidth( $buttonGroupSharing->sizePolicy()->hasHeightForWidth() ); - $buttonGroupSharing->setSizePolicy( $sizePolicy5 ); + $sizePolicy6->setHeightForWidth( $buttonGroupSharing->sizePolicy()->hasHeightForWidth() ); + $buttonGroupSharing->setSizePolicy( $sizePolicy6 ); $buttonGroupSharing->setAlignment( Qt::AlignLeading() ); $buttonGroupSharing->setCheckable( 1 ); $buttonGroupSharing->setChecked( 0 ); @@ -1779,12 +1785,12 @@ sub setupUi { $self->{sharingComp1} = $sharingComp1; $sharingComp1->setObjectName( "sharingComp1" ); $sharingComp1->setEnabled( 0 ); - my $sizePolicy6 = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::MinimumExpanding() ); - $self->{$sizePolicy6} = $sizePolicy6; - $sizePolicy6->setHorizontalStretch( 0 ); - $sizePolicy6->setVerticalStretch( 0 ); - $sizePolicy6->setHeightForWidth( $sharingComp1->sizePolicy()->hasHeightForWidth() ); - $sharingComp1->setSizePolicy( $sizePolicy6 ); + my $sizePolicy7 = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::MinimumExpanding() ); + $self->{$sizePolicy7} = $sizePolicy7; + $sizePolicy7->setHorizontalStretch( 0 ); + $sizePolicy7->setVerticalStretch( 0 ); + $sizePolicy7->setHeightForWidth( $sharingComp1->sizePolicy()->hasHeightForWidth() ); + $sharingComp1->setSizePolicy( $sizePolicy7 ); $sharingComp1->setAlignment( Qt::AlignLeading() ); my $layout14 = Qt::Widget( $sharingComp1 ); $self->{layout14} = $layout14; @@ -1872,8 +1878,8 @@ sub setupUi { $self->{sharingComp2} = $sharingComp2; $sharingComp2->setObjectName( "sharingComp2" ); $sharingComp2->setEnabled( 0 ); - $sizePolicy6->setHeightForWidth( $sharingComp2->sizePolicy()->hasHeightForWidth() ); - $sharingComp2->setSizePolicy( $sizePolicy6 ); + $sizePolicy7->setHeightForWidth( $sharingComp2->sizePolicy()->hasHeightForWidth() ); + $sharingComp2->setSizePolicy( $sizePolicy7 ); my $comp2ShLabel = Qt::Label( $sharingComp2 ); $self->{comp2ShLabel} = $comp2ShLabel; $comp2ShLabel->setObjectName( "comp2ShLabel" ); @@ -1958,8 +1964,8 @@ sub setupUi { $self->{sharingComp3} = $sharingComp3; $sharingComp3->setObjectName( "sharingComp3" ); $sharingComp3->setEnabled( 0 ); - $sizePolicy6->setHeightForWidth( $sharingComp3->sizePolicy()->hasHeightForWidth() ); - $sharingComp3->setSizePolicy( $sizePolicy6 ); + $sizePolicy7->setHeightForWidth( $sharingComp3->sizePolicy()->hasHeightForWidth() ); + $sharingComp3->setSizePolicy( $sizePolicy7 ); $sharingComp3->setAlignment( Qt::AlignJustify()|Qt::AlignVCenter() ); my $comp3ShLabel = Qt::Label( $sharingComp3 ); $self->{comp3ShLabel} = $comp3ShLabel; @@ -2095,8 +2101,8 @@ sub setupUi { my $titleLabel = Qt::Label( $groupTitle ); $self->{titleLabel} = $titleLabel; $titleLabel->setObjectName( "titleLabel" ); - $sizePolicy4->setHeightForWidth( $titleLabel->sizePolicy()->hasHeightForWidth() ); - $titleLabel->setSizePolicy( $sizePolicy4 ); + $sizePolicy5->setHeightForWidth( $titleLabel->sizePolicy()->hasHeightForWidth() ); + $titleLabel->setSizePolicy( $sizePolicy5 ); $titleLabel->setWordWrap( 0 ); $vboxLayout1->addWidget( $titleLabel ); @@ -2104,12 +2110,12 @@ sub setupUi { my $title = Qt::LineEdit( $groupTitle ); $self->{title} = $title; $title->setObjectName( "title" ); - my $sizePolicy7 = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::Fixed() ); - $self->{$sizePolicy7} = $sizePolicy7; - $sizePolicy7->setHorizontalStretch( 1 ); - $sizePolicy7->setVerticalStretch( 1 ); - $sizePolicy7->setHeightForWidth( $title->sizePolicy()->hasHeightForWidth() ); - $title->setSizePolicy( $sizePolicy7 ); + my $sizePolicy8 = Qt::SizePolicy( Qt::SizePolicy::Expanding(), Qt::SizePolicy::Fixed() ); + $self->{$sizePolicy8} = $sizePolicy8; + $sizePolicy8->setHorizontalStretch( 1 ); + $sizePolicy8->setVerticalStretch( 1 ); + $sizePolicy8->setHeightForWidth( $title->sizePolicy()->hasHeightForWidth() ); + $title->setSizePolicy( $sizePolicy8 ); $vboxLayout1->addWidget( $title ); @@ -2163,8 +2169,8 @@ sub setupUi { my $fourierBox = Qt::GroupBox( $fourierPage ); $self->{fourierBox} = $fourierBox; $fourierBox->setObjectName( "fourierBox" ); - $sizePolicy5->setHeightForWidth( $fourierBox->sizePolicy()->hasHeightForWidth() ); - $fourierBox->setSizePolicy( $sizePolicy5 ); + $sizePolicy6->setHeightForWidth( $fourierBox->sizePolicy()->hasHeightForWidth() ); + $fourierBox->setSizePolicy( $sizePolicy6 ); my $layout34 = Qt::Widget( $fourierBox ); $self->{layout34} = $layout34; $layout34->setObjectName( "layout34" ); @@ -2178,28 +2184,28 @@ sub setupUi { my $frqMax = Qt::LineEdit( $layout34 ); $self->{frqMax} = $frqMax; $frqMax->setObjectName( "frqMax" ); - $sizePolicy4->setHeightForWidth( $frqMax->sizePolicy()->hasHeightForWidth() ); - $frqMax->setSizePolicy( $sizePolicy4 ); + $sizePolicy5->setHeightForWidth( $frqMax->sizePolicy()->hasHeightForWidth() ); + $frqMax->setSizePolicy( $sizePolicy5 ); $gridLayout7->addWidget( $frqMax, 0, 6, 1, 1 ); my $funits = Qt::ComboBox( $layout34 ); $self->{funits} = $funits; $funits->setObjectName( "funits" ); - my $sizePolicy8 = Qt::SizePolicy( Qt::SizePolicy::Ignored(), Qt::SizePolicy::Preferred() ); - $self->{$sizePolicy8} = $sizePolicy8; - $sizePolicy8->setHorizontalStretch( 0 ); - $sizePolicy8->setVerticalStretch( 0 ); - $sizePolicy8->setHeightForWidth( $funits->sizePolicy()->hasHeightForWidth() ); - $funits->setSizePolicy( $sizePolicy8 ); + my $sizePolicy9 = Qt::SizePolicy( Qt::SizePolicy::Ignored(), Qt::SizePolicy::Preferred() ); + $self->{$sizePolicy9} = $sizePolicy9; + $sizePolicy9->setHorizontalStretch( 0 ); + $sizePolicy9->setVerticalStretch( 0 ); + $sizePolicy9->setHeightForWidth( $funits->sizePolicy()->hasHeightForWidth() ); + $funits->setSizePolicy( $sizePolicy9 ); $gridLayout7->addWidget( $funits, 0, 2, 1, 1 ); my $fplot = Qt::ComboBox( $layout34 ); $self->{fplot} = $fplot; $fplot->setObjectName( "fplot" ); - $sizePolicy4->setHeightForWidth( $fplot->sizePolicy()->hasHeightForWidth() ); - $fplot->setSizePolicy( $sizePolicy4 ); + $sizePolicy5->setHeightForWidth( $fplot->sizePolicy()->hasHeightForWidth() ); + $fplot->setSizePolicy( $sizePolicy5 ); $gridLayout7->addWidget( $fplot, 2, 2, 1, 1 ); @@ -2234,8 +2240,8 @@ sub setupUi { my $fapodization = Qt::ComboBox( $layout34 ); $self->{fapodization} = $fapodization; $fapodization->setObjectName( "fapodization" ); - $sizePolicy4->setHeightForWidth( $fapodization->sizePolicy()->hasHeightForWidth() ); - $fapodization->setSizePolicy( $sizePolicy4 ); + $sizePolicy5->setHeightForWidth( $fapodization->sizePolicy()->hasHeightForWidth() ); + $fapodization->setSizePolicy( $sizePolicy5 ); $gridLayout7->addWidget( $fapodization, 1, 2, 1, 1 ); @@ -2270,8 +2276,8 @@ sub setupUi { my $fphase = Qt::LineEdit( $layout34 ); $self->{fphase} = $fphase; $fphase->setObjectName( "fphase" ); - $sizePolicy4->setHeightForWidth( $fphase->sizePolicy()->hasHeightForWidth() ); - $fphase->setSizePolicy( $sizePolicy4 ); + $sizePolicy5->setHeightForWidth( $fphase->sizePolicy()->hasHeightForWidth() ); + $fphase->setSizePolicy( $sizePolicy5 ); $gridLayout7->addWidget( $fphase, 1, 4, 1, 1 ); @@ -2292,8 +2298,8 @@ sub setupUi { my $frqMin = Qt::LineEdit( $layout34 ); $self->{frqMin} = $frqMin; $frqMin->setObjectName( "frqMin" ); - $sizePolicy4->setHeightForWidth( $frqMin->sizePolicy()->hasHeightForWidth() ); - $frqMin->setSizePolicy( $sizePolicy4 ); + $sizePolicy5->setHeightForWidth( $frqMin->sizePolicy()->hasHeightForWidth() ); + $frqMin->setSizePolicy( $sizePolicy5 ); $gridLayout7->addWidget( $frqMin, 0, 4, 1, 1 ); @@ -2316,12 +2322,12 @@ sub setupUi { my $rrfBox = Qt::GroupBox( $fourierPage ); $self->{rrfBox} = $rrfBox; $rrfBox->setObjectName( "rrfBox" ); - $sizePolicy5->setHeightForWidth( $rrfBox->sizePolicy()->hasHeightForWidth() ); - $rrfBox->setSizePolicy( $sizePolicy5 ); + $sizePolicy6->setHeightForWidth( $rrfBox->sizePolicy()->hasHeightForWidth() ); + $rrfBox->setSizePolicy( $sizePolicy6 ); my $layout35 = Qt::Widget( $rrfBox ); $self->{layout35} = $layout35; $layout35->setObjectName( "layout35" ); - $layout35->setGeometry( Qt::Rect(10, 18, 265, 100) ); + $layout35->setGeometry( Qt::Rect(10, 18, 265, 107) ); my $gridLayout8 = Qt::GridLayout( $layout35 ); $self->{gridLayout8} = $gridLayout8; $gridLayout8->setSpacing( 5 ); @@ -2668,12 +2674,12 @@ sub setupUi { $self->{t0Update} = $t0Update; $t0Update->setObjectName( "t0Update" ); $t0Update->setEnabled( 0 ); - my $sizePolicy9 = Qt::SizePolicy( Qt::SizePolicy::Fixed(), Qt::SizePolicy::Fixed() ); - $self->{$sizePolicy9} = $sizePolicy9; - $sizePolicy9->setHorizontalStretch( 0 ); - $sizePolicy9->setVerticalStretch( 0 ); - $sizePolicy9->setHeightForWidth( $t0Update->sizePolicy()->hasHeightForWidth() ); - $t0Update->setSizePolicy( $sizePolicy9 ); + my $sizePolicy10 = Qt::SizePolicy( Qt::SizePolicy::Fixed(), Qt::SizePolicy::Fixed() ); + $self->{$sizePolicy10} = $sizePolicy10; + $sizePolicy10->setHorizontalStretch( 0 ); + $sizePolicy10->setVerticalStretch( 0 ); + $sizePolicy10->setHeightForWidth( $t0Update->sizePolicy()->hasHeightForWidth() ); + $t0Update->setSizePolicy( $sizePolicy10 ); $hboxLayout2->addWidget( $t0Update ); @@ -2835,16 +2841,16 @@ sub setupUi { my $cParamsCombo = Qt::ComboBox( $tabPage ); $self->{cParamsCombo} = $cParamsCombo; $cParamsCombo->setObjectName( "cParamsCombo" ); - $sizePolicy9->setHeightForWidth( $cParamsCombo->sizePolicy()->hasHeightForWidth() ); - $cParamsCombo->setSizePolicy( $sizePolicy9 ); + $sizePolicy10->setHeightForWidth( $cParamsCombo->sizePolicy()->hasHeightForWidth() ); + $cParamsCombo->setSizePolicy( $sizePolicy10 ); $hboxLayout3->addWidget( $cParamsCombo ); my $textLabel1_4_6 = Qt::Label( $tabPage ); $self->{textLabel1_4_6} = $textLabel1_4_6; $textLabel1_4_6->setObjectName( "textLabel1_4_6" ); - $sizePolicy9->setHeightForWidth( $textLabel1_4_6->sizePolicy()->hasHeightForWidth() ); - $textLabel1_4_6->setSizePolicy( $sizePolicy9 ); + $sizePolicy10->setHeightForWidth( $textLabel1_4_6->sizePolicy()->hasHeightForWidth() ); + $textLabel1_4_6->setSizePolicy( $sizePolicy10 ); $textLabel1_4_6->setWordWrap( 0 ); $hboxLayout3->addWidget( $textLabel1_4_6 ); @@ -2861,8 +2867,8 @@ sub setupUi { my $addConstraint = Qt::PushButton( $tabPage ); $self->{addConstraint} = $addConstraint; $addConstraint->setObjectName( "addConstraint" ); - $sizePolicy9->setHeightForWidth( $addConstraint->sizePolicy()->hasHeightForWidth() ); - $addConstraint->setSizePolicy( $sizePolicy9 ); + $sizePolicy10->setHeightForWidth( $addConstraint->sizePolicy()->hasHeightForWidth() ); + $addConstraint->setSizePolicy( $sizePolicy10 ); $hboxLayout3->addWidget( $addConstraint ); @@ -2965,7 +2971,7 @@ sub setupUi { $self->{menuBar} = $menuBar; $menuBar->setObjectName( "menuBar" ); $menuBar->setEnabled( 1 ); - $menuBar->setGeometry( Qt::Rect(0, 0, 600, 20) ); + $menuBar->setGeometry( Qt::Rect(0, 0, 674, 27) ); my $fileMenu = Qt::Menu( $menuBar ); $self->{fileMenu} = $fileMenu; $fileMenu->setObjectName( "fileMenu" ); @@ -3194,20 +3200,24 @@ sub retranslateUi { $self->{browse}->setText( Qt::Application::translate( 'MuSRFit4', "Browse", undef, Qt::Application::UnicodeUTF8() ) ); $self->{fitAsyTypeLabel}->setText( Qt::Application::translate( 'MuSRFit4', "Fit type", undef, Qt::Application::UnicodeUTF8() ) ); $self->{fitAsyType}->insertItems(0, [Qt::Application::translate( 'MuSRFit4', "Asymmetry", undef, Qt::Application::UnicodeUTF8() ), - Qt::Application::translate( 'MuSRFit4', "SingleHist", undef, Qt::Application::UnicodeUTF8() )]); + Qt::Application::translate( 'MuSRFit4', "Single Hist", undef, Qt::Application::UnicodeUTF8() ), + Qt::Application::translate( 'MuSRFit4', "Asymmetry GLB", undef, Qt::Application::UnicodeUTF8() ), + Qt::Application::translate( 'MuSRFit4', "Single Hist GLB", undef, Qt::Application::UnicodeUTF8() )]); $self->{histsLRBFLabel}->setText( Qt::Application::translate( 'MuSRFit4', "Histograms list", undef, Qt::Application::UnicodeUTF8() ) ); $self->{histsLRBF}->setText( Qt::Application::translate( 'MuSRFit4', "1 5,3 7", undef, Qt::Application::UnicodeUTF8() ) ); $self->{runsAuto}->setTitle( Qt::Application::translate( 'MuSRFit4', "RUN Numbers", undef, Qt::Application::UnicodeUTF8() ) ); - $self->{yearLabel}->setText( Qt::Application::translate( 'MuSRFit4', "Year", undef, Qt::Application::UnicodeUTF8() ) ); - $self->{beamLineLabel}->setText( Qt::Application::translate( 'MuSRFit4', "On beam line", undef, Qt::Application::UnicodeUTF8() ) ); + $self->{runNumbers}->setToolTip( Qt::Application::translate( 'MuSRFit4', "Numbers of RUNs to fit. Multiple runs are comma separated.", undef, Qt::Application::UnicodeUTF8() ) ); + $self->{runNumbers}->setWhatsThis( Qt::Application::translate( 'MuSRFit4', "Numbers of RUNs to fit. Multiple runs are comma separated.", undef, Qt::Application::UnicodeUTF8() ) ); + $self->{runNumbers}->setText( '' ); $self->{beamLine}->insertItems(0, [Qt::Application::translate( 'MuSRFit4', "LEM", undef, Qt::Application::UnicodeUTF8() ), + Qt::Application::translate( 'MuSRFit4', "GPD", undef, Qt::Application::UnicodeUTF8() ), + Qt::Application::translate( 'MuSRFit4', "HAL", undef, Qt::Application::UnicodeUTF8() ), Qt::Application::translate( 'MuSRFit4', "GPS", undef, Qt::Application::UnicodeUTF8() ), Qt::Application::translate( 'MuSRFit4', "Dolly", undef, Qt::Application::UnicodeUTF8() ), Qt::Application::translate( 'MuSRFit4', "LTF", undef, Qt::Application::UnicodeUTF8() ), Qt::Application::translate( 'MuSRFit4', "LEM (PPC)", undef, Qt::Application::UnicodeUTF8() )]); - $self->{runNumbers}->setToolTip( Qt::Application::translate( 'MuSRFit4', "Numbers of RUNs to fit. Multiple runs are comma separated.", undef, Qt::Application::UnicodeUTF8() ) ); - $self->{runNumbers}->setWhatsThis( Qt::Application::translate( 'MuSRFit4', "Numbers of RUNs to fit. Multiple runs are comma separated.", undef, Qt::Application::UnicodeUTF8() ) ); - $self->{runNumbers}->setText( '' ); + $self->{yearLabel}->setText( Qt::Application::translate( 'MuSRFit4', " Year ", undef, Qt::Application::UnicodeUTF8() ) ); + $self->{beamLineLabel}->setText( Qt::Application::translate( 'MuSRFit4', "On beam line ", undef, Qt::Application::UnicodeUTF8() ) ); $self->{groupBox}->setTitle( Qt::Application::translate( 'MuSRFit4', "Theory Function", undef, Qt::Application::UnicodeUTF8() ) ); $self->{comp1Label}->setText( Qt::Application::translate( 'MuSRFit4', "First Component", undef, Qt::Application::UnicodeUTF8() ) ); $self->{comp2Label}->setText( Qt::Application::translate( 'MuSRFit4', "Second Component", undef, Qt::Application::UnicodeUTF8() ) );