Transfer new features into development branch.

This commit is contained in:
salman 2011-05-13 12:44:38 +00:00
parent 8792445c3f
commit 0af373d6b7
4 changed files with 5391 additions and 5031 deletions

View File

@ -93,6 +93,14 @@ sub CreateMSR {
} }
my @Hists = split( /,/, $All{"LRBF"} ); my @Hists = split( /,/, $All{"LRBF"} );
# TODO
# 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 @TiVals = split( /,/, $All{"Tis"} );
my @TfVals = split( /,/, $All{"Tfs"} ); my @TfVals = split( /,/, $All{"Tfs"} );
my @BINVals = split( /,/, $All{"BINS"} ); my @BINVals = split( /,/, $All{"BINS"} );
@ -159,6 +167,7 @@ FUNCTIONS
} }
# $shcount is a counter for shared parameters # $shcount is a counter for shared parameters
# msr2data \[1363 1365 1366\] _Dolly_2010 msr-1363 global
if ( $#RUNS == 0 ) { if ( $#RUNS == 0 ) {
my $shcount = 1; my $shcount = 1;
} else { } else {
@ -286,28 +295,40 @@ FUNCTIONS
foreach ("t0","Bg1","Bg2","Data1","Data2") { foreach ("t0","Bg1","Bg2","Data1","Data2") {
$Name = "$_$NHist"; $Name = "$_$NHist";
# If empty fill with defaults # If empty fill with defaults
if ($All{$Name} eq $EMPTY) { # if ($All{$Name} eq $EMPTY) {
$All{$Name}=MSR::T0BgData($_,$Hist,$BeamLine); # $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"};
} }
$Bg_Line = $Bg_Line." ".$All{"Bg1$NHist"}." ".$All{"Bg2$NHist"};
$Data_Line =$Data_Line." ".$All{"Data1$NHist"}." ".$All{"Data2$NHist"};
if ($All{"t0$NHist"} ne $EMPTY) { if ($All{"t0$NHist"} ne $EMPTY) {
$T0_Line=$T0_Line." ".$All{"Data1$NHist"}; $T0_Line=$T0_Line." ".$All{"t0$NHist"};
} }
$NHist++; $NHist++;
} }
# Put T0_Line Bg_Line and Data_Line together if not empty
my $T0DataBg=$EMPTY;
if ($T0_Line ne "t0") {
$T0DataBg = $T0DataBg."\n".$T0_Line;
}
if ($Bg_Line ne "background") {
$T0DataBg = $T0DataBg."\n".$Bg_Line;
}
if ($Data_Line ne "data") {
$T0DataBg = $T0DataBg."\n".$Data_Line;
}
$FRANGE_Line = "fit TINI TFIN"; $FRANGE_Line = "fit TINI TFIN";
$PAC_Line = "packing BINNING"; $PAC_Line = "packing BINNING";
if ($T0_Line ne "t0") {
$Data_Line= $Data_Line."\n".$T0_Line;
}
$Single_RUN = $Single_RUN =
"$RUN_Line\n$Type_Line\n$Alpha_Line$Hist_Lines\n$Bg_Line\n$Data_Line\n$MAP_Line\n$FRANGE_Line\n$PAC_Line\n\n"; "$RUN_Line\n$Type_Line\n$Alpha_Line$Hist_Lines\n$T0DataBg\n$MAP_Line\n$FRANGE_Line\n$PAC_Line\n\n";
# Now add the appropriate values of fit range and packing # Now add the appropriate values of fit range and packing
my $Range_Min = 8; my $Range_Min = 8;
@ -396,12 +417,16 @@ SAVE
# } # }
} }
$VIEWBIN_Line ="";
if ( $All{"ViewBin"}!=0 ) { $VIEWBIN_Line = "view_packing ".$All{"ViewBin"};}
my $RRFBlock=MSR::CreateRRFBlock(\%All); my $RRFBlock=MSR::CreateRRFBlock(\%All);
$PLOT_Block = $PLOT_Block =
"############################################################### "###############################################################
PLOT $PLT PLOT $PLT
runs $RUNS_Line runs $RUNS_Line
$PRANGE_Line $PRANGE_Line
$VIEWBIN_Line
$RRFBlock $RRFBlock
$logxy"; $logxy";
@ -443,9 +468,9 @@ STATISTIC --- 0000-00-00 00:00:00
return($Full_T_Block,\@Paramcomp); return($Full_T_Block,\@Paramcomp);
} }
######################## ##########################################################################
# CreateMSRSingleHist # CreateMSRSingleHist
######################## ##########################################################################
sub CreateMSRSingleHist { sub CreateMSRSingleHist {
my %All = %{$_[0]}; my %All = %{$_[0]};
@ -525,7 +550,7 @@ FUNCTIONS
if ( $#RUNS == 0 && $#Hists == 0) { if ( $#RUNS == 0 && $#Hists == 0) {
my $shcount = 1; my $shcount = 1;
} else { } else {
if ( $All{"Sh_N0"} == 1 ) { if ( $All{"Sh_No"} == 1 ) {
my $shcount = 1; my $shcount = 1;
} elsif ( $All{"Sh_NBg"} == 1 ) { } elsif ( $All{"Sh_NBg"} == 1 ) {
my $shcount = 1; my $shcount = 1;
@ -540,6 +565,7 @@ FUNCTIONS
# range order # range order
my $Range_Order = 1; my $Range_Order = 1;
my $iHist = 0;
foreach my $RUN (@RUNS) { foreach my $RUN (@RUNS) {
####################################################################### #######################################################################
# For a single histogram fit we basically need to repeat this for each hist # For a single histogram fit we basically need to repeat this for each hist
@ -561,24 +587,26 @@ FUNCTIONS
# How many non-shared parameter for this RUN? # How many non-shared parameter for this RUN?
my $nonsh = 0; my $nonsh = 0;
# Prepeare N0/NBg line for the RUN block. Empty initially. # Prepeare No/NBg line for the RUN block. Empty initially.
my $N0Bg_Line = $EMPTY; my $NoBg_Line = $EMPTY;
# Loop over all components in the fit # Loop over all components in the fit
foreach my $FitType (@FitTypes) { foreach my $FitType (@FitTypes) {
++$component; ++$component;
my $Parameters = $Paramcomp[ $component - 1 ]; my $Parameters = $Paramcomp[ $component - 1 ];
my @Params = split( /\s+/, $Parameters ); 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 N0 and NBg for SingleHist fits # For the first component we need No and NBg for SingleHist fits
if ( $component == 1 && $All{"FitAsyType"} eq "SingleHist" ) { if ( $component == 1 ) {
unshift( @Params, ( "N0", "NBg" ) ); unshift( @Params, ( "No", "NBg" ) );
} }
foreach $Param (@Params) { foreach $Param (@Params) {
$Param_ORG = $Param; $Param_ORG = $Param;
$Param=$Param.$Hist; $Param=$Param.$Hist;
if ( ($#FitTypes != 0) && ( $Param ne "N0" && $Param ne "NBg" ) ) { if ( ($#FitTypes != 0) && !( $Param_ORG =~ m/^(No|NBg)/ ) ) {
$Param = join( $EMPTY, $Param, "_", "$component" ); $Param = join( $EMPTY, $Param, "_", "$component" );
} }
@ -591,35 +619,35 @@ FUNCTIONS
$Shared = $All{"Sh_$Param"}; $Shared = $All{"Sh_$Param"};
} }
# N0 and NBg Lines # No and NBg Lines
# #
# If you encounter N0 in the parameters list make sure # If you encounter No in the parameters list make sure
# to fill this line for the RUN block. # to fill this line for the RUN block.
if ( $Param_ORG eq "N0" ) { if ( $Param_ORG eq "No" ) {
if ($Shared) { if ($Shared) {
$N0Bg_Line = "norm 1\n"; $NoBg_Line = "norm 1\n";
} }
else { else {
$N0Bg_Line = "norm $PCount\n"; $NoBg_Line = "norm $PCount\n";
} }
# Optional - add lifetime correction for SingleHist fits # Optional - add lifetime correction for SingleHist fits
if ( $All{"ltc"} eq "y" ) { if ( $All{"ltc"} eq "y" ) {
$N0Bg_Line = $N0Bg_Line . "lifetimecorrection\n"; $NoBg_Line = $NoBg_Line . "lifetimecorrection\n";
} }
} }
# If you encounter NBg in the parameters list make sure # If you encounter NBg in the parameters list make sure
# to fill this line for the RUN block. # to fill this line for the RUN block.
elsif ( $Param_ORG eq "NBg" ) { elsif ( $Param_ORG eq "NBg" ) {
if ($Shared) { if ($Shared) {
$N0Bg_Line = $N0Bg_Line . "backgr.fit 2\n"; $NoBg_Line = $NoBg_Line . "backgr.fit 2\n";
} }
else { else {
$N0Bg_Line = $N0Bg_Line . "backgr.fit $PCount\n"; $NoBg_Line = $NoBg_Line . "backgr.fit $PCount\n";
} }
} }
# End of N0 and NBg Lines # End of No and NBg Lines
#################################################################################################### ####################################################################################################
# Start preparing the parameters block # Start preparing the parameters block
@ -633,7 +661,7 @@ FUNCTIONS
} else { } else {
# Parameter is not shared, use map unless it is a single RUN fit # Parameter is not shared, use map unless it is a single RUN fit
# Skip adding to map line in these cases # Skip adding to map line in these cases
if ( $Param ne "N0" && $Param ne "NBg" && ($#RUNS != 0 || $#Hist != 0)) { if ( !( $Param_ORG =~ m/^(No|NBg)/ ) && ($#RUNS != 0 || $#Hist != 0)) {
++$nonsh; ++$nonsh;
$Full_T_Block =~ s/$Param_ORG/map$nonsh/; $Full_T_Block =~ s/$Param_ORG/map$nonsh/;
$MAP_Line = join( ' ', $MAP_Line, $PCount ); $MAP_Line = join( ' ', $MAP_Line, $PCount );
@ -649,7 +677,7 @@ FUNCTIONS
# For each defined range we need a block in the RUN-Block # For each defined range we need a block in the RUN-Block
# Also for each histogram in Single Histograms fits # Also for each histogram in Single Histograms fits
# Also for Imaginaryand and Real for RRF fits # Also for Imaginary and and Real for RRF fits
$RUN = $RUNS[ $iRun - 1 ]; $RUN = $RUNS[ $iRun - 1 ];
@ -686,7 +714,7 @@ FUNCTIONS
$Tmp_Hist_Line = $Hist_Lines; $Tmp_Hist_Line = $Hist_Lines;
$Tmp_Hist_Line =~ s/HIST/$Hist/g; $Tmp_Hist_Line =~ s/HIST/$Hist/g;
$Single_RUN = $Single_RUN $Single_RUN = $Single_RUN
. "$RUN_Line\n$Type_Line\n$N0Bg_Line$Tmp_Hist_Line\n$Data_Line\n$MAP_Line\n$FRANGE_Line\n$PAC_Line\n\n"; . "$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";
# Now add the appropriate values of fit range and packing # Now add the appropriate values of fit range and packing
my $Range_Min = 8; my $Range_Min = 8;
@ -707,6 +735,7 @@ FUNCTIONS
++$k; ++$k;
++$Range_Order; ++$Range_Order;
} }
++$iHist;
} }
++$iRun; ++$iRun;
} }
@ -843,8 +872,8 @@ sub CreateTheory {
"generExpo", "Lam Bet", "generExpo", "Lam Bet",
"simpleGss", "Sgm", "simpleGss", "Sgm",
"statGssKT", "Sgm", "statGssKT", "Sgm",
"statGssKTLF", "Frq Sgm", "statGssKTLF", "Frqg Sgm",
"dynGssKTLF", "Frq Sgm Lam", "dynGssKTLF", "Frql Sgm Lam",
"statExpKT", "Lam", "statExpKT", "Lam",
"statExpKTLF", "Frq Aa", "statExpKTLF", "Frq Aa",
"dynExpKTLF", "Frq Aa Lam", "dynExpKTLF", "Frq Aa Lam",
@ -1011,6 +1040,18 @@ sub CreateTheory {
$Parameters = join( $SPACE, $Parameters, $THEORY{'statGssKTLF'} ); $Parameters = join( $SPACE, $Parameters, $THEORY{'statGssKTLF'} );
} }
# Lorentzian or Gaussian KT LF multiplied by stretched exponential
elsif ( $FitType eq "MolMag" ) {
$T_Block = $T_Block . "\n" . "generExpo " . $THEORY{'generExpo'};
$Parameters = join( $SPACE, $Parameters, $THEORY{'generExpo'} );
$T_Block =
$T_Block . "\n" . "statExpKTLF " . $THEORY{'statExpKTLF'};
$Parameters = join( $SPACE, $Parameters, $THEORY{'statExpKTLF'} );
$T_Block =
$T_Block . "\n" . "statGssKTLF " . $THEORY{'statGssKTLF'};
$Parameters = join( $SPACE, $Parameters, $THEORY{'statGssKTLF'} );
}
# Meissner state model # Meissner state model
elsif ( $FitType eq "Meissner" ) { elsif ( $FitType eq "Meissner" ) {
$T_Block = $T_Block . "\n" . "simpleGss " . $THEORY{'simpleGss'}; $T_Block = $T_Block . "\n" . "simpleGss " . $THEORY{'simpleGss'};
@ -1068,7 +1109,7 @@ sub ExtractBlks {
my @Param=split(/\s+/,$line); my @Param=split(/\s+/,$line);
} }
return(\@TBlock,\@FPBlock) return(\@TBlock,\@FPBlock);
} }
@ -1092,15 +1133,15 @@ sub T0BgData {
"3",",66000,66500,3419,63000", "3",",66000,66500,3419,63000",
"4",",66000,66500,3419,63000"); "4",",66000,66500,3419,63000");
my %GPS=("1",",40,120,135,8000", # my %GPS=("1",",40,120,135,8000",
"2",",40,120,135,8000", # "2",",40,120,135,8000",
"3",",40,120,135,8000", # "3",",40,120,135,8000",
"4",",40,120,135,8000"); # "4",",40,120,135,8000");
my %Dolly=("1",",50,250,297,8000", # my %Dolly=("1",",50,250,297,8000",
"2",",50,250,297,8000", # "2",",50,250,297,8000",
"3",",50,250,297,8000", # "3",",50,250,297,8000",
"4",",50,250,297,8000"); # "4",",50,250,297,8000");
my %RV=(); my %RV=();
@ -1137,8 +1178,8 @@ sub PrepParamTable {
"Asy_min", "0", "Asy_max", "0", "Asy_min", "0", "Asy_max", "0",
"Alpha", "1.0", "dAlpha", "0.01", "Alpha", "1.0", "dAlpha", "0.01",
"Alpha_min", "0", "Alpha_max", "0", "Alpha_min", "0", "Alpha_max", "0",
"N0", "300.0", "dN0", "0.01", "No", "300.0", "dNo", "0.01",
"N0_min", "0", "N0_max", "0", "No_min", "0", "No_max", "0",
"NBg", "30.0", "dNBg", "0.01", "NBg", "30.0", "dNBg", "0.01",
"NBg_min", "0", "NBg_max", "0", "NBg_min", "0", "NBg_max", "0",
"Lam", "1.0", "dLam", "0.01", "Lam", "1.0", "dLam", "0.01",
@ -1248,6 +1289,7 @@ sub PrepParamTable {
# We can remove it from the MSR module later... # We can remove it from the MSR module later...
# Or keep in the MSR as function ?? # Or keep in the MSR as function ??
# We have two options here, either take default values or take values of previous # We have two options here, either take default values or take values of previous
# run if available # run if available
# $ParamPrev =~ s/$iRun-1/$iRun/g; # $ParamPrev =~ s/$iRun-1/$iRun/g;
@ -1273,7 +1315,7 @@ sub PrepParamTable {
my $Parameters=$Paramcomp[$Component-1]; my $Parameters=$Paramcomp[$Component-1];
my @Params = split( /\s+/, $Parameters ); my @Params = split( /\s+/, $Parameters );
if ( $Component == 1 ) { if ( $Component == 1 ) {
unshift( @Params, ( "N0", "NBg" ) ); unshift( @Params, ( "No", "NBg" ) );
} }
# This is the counter for parameters of this component # This is the counter for parameters of this component
@ -1282,8 +1324,10 @@ sub PrepParamTable {
# Change state/label of parameters # Change state/label of parameters
foreach my $Param (@Params) { foreach my $Param (@Params) {
my $Param_ORG = $Param; my $Param_ORG = $Param;
# If multiple histograms (sum or difference) take the first histogram only
($Hist,$tmp) = split(/ /,$Hist);
$Param=$Param.$Hist; $Param=$Param.$Hist;
if ( $#FitTypes != 0 && ( $Param_ORG ne "N0" && $Param_ORG ne "NBg" ) ){ if ( $#FitTypes != 0 && ( $Param_ORG ne "No" && $Param_ORG ne "NBg" ) ){
$Param = join( $EMPTY, $Param, "_", "$Component" ); $Param = join( $EMPTY, $Param, "_", "$Component" );
} }
@ -1433,7 +1477,7 @@ sub ExportParams {
my $Parameters=$Paramcomp[$Component-1]; my $Parameters=$Paramcomp[$Component-1];
my @Params = split( /\s+/, $Parameters ); my @Params = split( /\s+/, $Parameters );
if ( $Component == 1 ) { if ( $Component == 1 ) {
unshift( @Params, ( "N0", "NBg" ) ); unshift( @Params, ( "No", "NBg" ) );
} }
# This is the counter for parameters of this component # This is the counter for parameters of this component
@ -1443,7 +1487,7 @@ sub ExportParams {
foreach my $Param (@Params) { foreach my $Param (@Params) {
my $Param_ORG = $Param; my $Param_ORG = $Param;
$Param=$Param.$Hist; $Param=$Param.$Hist;
if ( $#FitTypes != 0 && ( $Param_ORG ne "N0" && $Param_ORG ne "NBg" ) ){ if ( $#FitTypes != 0 && ( $Param_ORG ne "No" && $Param_ORG ne "NBg" ) ){
$Param = join( $EMPTY, $Param, "_", "$Component" ); $Param = join( $EMPTY, $Param, "_", "$Component" );
} }
@ -1597,41 +1641,20 @@ sub RUNFileNameAuto {
$RUNFILE = "$DATADIR/$YEAR/$RUN_File_Name"; $RUNFILE = "$DATADIR/$YEAR/$RUN_File_Name";
} }
elsif ( $BeamLine eq "GPS" ) { elsif ( $BeamLine eq "GPS" ) {
# $RUN_File_Name = "deltat_pta_gps_" . $RUNtmp;
$RUN_File_Name = "deltat_tdc_gps_" . $RUNtmp; $RUN_File_Name = "deltat_tdc_gps_" . $RUNtmp;
if ( $YEAR == $current_year ) { $RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
$RUNFILE = "$DATADIR/$RUN_File_Name";
}
else {
$RUNFILE = "$DATADIR/d$YEAR/pta/$RUN_File_Name";
}
} }
elsif ( $BeamLine eq "LTF" ) { elsif ( $BeamLine eq "LTF" ) {
$RUN_File_Name = "deltat_pta_ltf_" . $RUNtmp; $RUN_File_Name = "deltat_tdc_ltf_" . $RUNtmp;
if ( $YEAR == $current_year ) { $RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
$RUNFILE = "$DATADIR/$RUN_File_Name";
}
else {
$RUNFILE = "$DATADIR/d$YEAR/pta/$RUN_File_Name";
}
} }
elsif ( $BeamLine eq "Dolly" ) { elsif ( $BeamLine eq "Dolly" ) {
$RUN_File_Name = "deltat_pta_dolly_" . $RUNtmp; $RUN_File_Name = "deltat_tdc_dolly_" . $RUNtmp;
if ( $YEAR == $current_year ) { $RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
$RUNFILE = "$DATADIR/$RUN_File_Name";
}
else {
$RUNFILE = "$DATADIR/d$YEAR/pta/$RUN_File_Name";
}
} }
elsif ( $BeamLine eq "GPD" ) { elsif ( $BeamLine eq "GPD" ) {
$RUN_File_Name = "deltat_pta_gpd_" . $RUNtmp; $RUN_File_Name = "deltat_tdc_gpd_" . $RUNtmp;
if ( $YEAR == $current_year ) { $RUNFILE = "$DATADIR/d$YEAR/tdc/$RUN_File_Name";
$RUNFILE = "$DATADIR/$RUN_File_Name";
}
else {
$RUNFILE = "$DATADIR/d$YEAR/pta/$RUN_File_Name";
}
} }
my $RUN_Line = join( $SPACE, my $RUN_Line = join( $SPACE,
"RUN", $RUNFILE, $BeamLines{$BeamLine}, "PSI", "RUN", $RUNFILE, $BeamLines{$BeamLine}, "PSI",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -212,7 +212,6 @@ void MuSRFitMenu::helpAbout()
void MuSRFitform::CreateAllInput() void MuSRFitform::CreateAllInput()
{ {
# TODO: Need to automatically generage years list depending on beamline
my %All=(); my %All=();
# From RUNS Tab # From RUNS Tab
@ -224,6 +223,14 @@ void MuSRFitform::CreateAllInput()
$All{"optionsFourier"} = optionsFourier->isOn(); $All{"optionsFourier"} = optionsFourier->isOn();
$All{"optionsT0"} = optionsT0->isOn(); $All{"optionsT0"} = optionsT0->isOn();
$All{"YEAR"} =YEAR->currentText; $All{"YEAR"} =YEAR->currentText;
if ($All{"YEAR"} eq "") {
# If year combobox is empty fill it up from 2004 up to current year
my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
my $current_year = 1900 + $yearOffset;
for (my $i=$current_year;$i>=2004;$i--) {
YEAR->insertItem($i,-1);
}
}
# Time range and BINS # Time range and BINS
$All{"Tis"} = Tis->text; $All{"Tis"} = Tis->text;
$All{"Tfs"} = Tfs->text; $All{"Tfs"} = Tfs->text;
@ -245,6 +252,7 @@ void MuSRFitform::CreateAllInput()
$All{"Xf"}=Xf->text; $All{"Xf"}=Xf->text;
$All{"Yi"}=Yi->text; $All{"Yi"}=Yi->text;
$All{"Yf"}=Yf->text; $All{"Yf"}=Yf->text;
$All{"ViewBin"}=ViewBin->text;
# Life time correction # Life time correction
if (ltc->isChecked()) { if (ltc->isChecked()) {
$All{"ltc"}="y"; $All{"ltc"}="y";
@ -320,8 +328,9 @@ void MuSRFitform::CreateAllInput()
10,"GLFExp", 10,"GLFExp",
11,"LLFSExp", 11,"LLFSExp",
12,"GLFSExp", 12,"GLFSExp",
13,"Meissner", 13,"MolMag",
14,"None" 14,"Meissner",
15,"None"
); );
my $FT1=FitType1->currentItem; my $FT1=FitType1->currentItem;
@ -350,6 +359,8 @@ void MuSRFitform::CreateAllInput()
$All{"Func_T_Block"}=TheoryBlock->text; $All{"Func_T_Block"}=TheoryBlock->text;
# Shared settings are detected here # Shared settings are detected here
$All{"EnableSharing"} = buttonGroupSharing->isChecked();
my $Shared = 0; my $Shared = 0;
my $PCount =0; my $PCount =0;
my $Component=1; my $Component=1;
@ -361,7 +372,7 @@ void MuSRFitform::CreateAllInput()
unshift( @Params, "Alpha" ); unshift( @Params, "Alpha" );
} }
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) { elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
unshift( @Params, ( "N0", "NBg" ) ); unshift( @Params, ( "No", "NBg" ) );
} }
# This is the counter for parameters of this component # This is the counter for parameters of this component
@ -374,7 +385,7 @@ void MuSRFitform::CreateAllInput()
if ( $All{"FitAsyType"} eq "SingleHist" ) { if ( $All{"FitAsyType"} eq "SingleHist" ) {
$Param=$Param.$Hists[0]; $Param=$Param.$Hists[0];
} }
if ( $#FitTypes != 0 && ( $Param ne "Alpha" && $Param ne "N0" && $Param ne "NBg" ) ){ if ( $#FitTypes != 0 && ( $Param ne "Alpha" && $Param ne "No" && $Param ne "NBg" ) ){
$Param = join( "", $Param, "_", $Component); $Param = join( "", $Param, "_", $Component);
} }
@ -582,43 +593,47 @@ void MuSRFitform::ActivateShComp()
my @Paramcomp = @$Paramcomp_ref; my @Paramcomp = @$Paramcomp_ref;
my $Full_T_Block= $All{"Full_T_Block"}; my $Full_T_Block= $All{"Full_T_Block"};
my $Component=1; # Possible to share only if sharing is enabled altogether
foreach my $FitType (@FitTypes) { my $EnableSharing = $All{"EnableSharing"};
my $Parameters=$Paramcomp[$Component-1]; if ($EnableSharing) {
my @Params = split( /\s+/, $Parameters ); my $Component=1;
foreach my $FitType (@FitTypes) {
my $Parameters=$Paramcomp[$Component-1];
my @Params = split( /\s+/, $Parameters );
if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) { if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) {
unshift( @Params, "Alpha" ); unshift( @Params, "Alpha" );
} }
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) { elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
unshift( @Params, ( "N0", "NBg" ) ); unshift( @Params, ( "No", "NBg" ) );
} }
# Make the component appear first (only if we have multiple runs) # Make the component appear first (only if we have multiple runs)
my $ShCompG="SharingComp".$Component; my $ShCompG="SharingComp".$Component;
my $ShCG = child($ShCompG); my $ShCG = child($ShCompG);
if ($#RUNS>0) { if ($#RUNS>0) {
$ShCG->setHidden(0); $ShCG->setHidden(0);
$ShCG->setEnabled(1); $ShCG->setEnabled(1);
} }
my $CompShLabel = "Comp".$Component."ShLabel"; my $CompShLabel = "Comp".$Component."ShLabel";
my $CompShL = child($CompShLabel); my $CompShL = child($CompShLabel);
$CompShL->setText($All{"FitType$Component"}); $CompShL->setText($All{"FitType$Component"});
# Change state/label of parameters # Change state/label of parameters
for (my $i=1; $i<=9;$i++) { for (my $i=1; $i<=9;$i++) {
my $ParamChkBx="ShParam_".$Component."_".$i; my $ParamChkBx="ShParam_".$Component."_".$i;
my $ChkBx = child($ParamChkBx); my $ChkBx = child($ParamChkBx);
if ($Params[$i-1] ne "") { if ($Params[$i-1] ne "") {
$ChkBx->setHidden(0); $ChkBx->setHidden(0);
$ChkBx->setEnabled(1); $ChkBx->setEnabled(1);
$ChkBx ->setText($Params[$i-1]); $ChkBx ->setText($Params[$i-1]);
} else { } else {
$ChkBx->setHidden(1); $ChkBx->setHidden(1);
}
} }
$Component++;
} }
$Component++;
} }
} }
@ -648,6 +663,8 @@ void MuSRFitform::InitializeTab()
# Fill the table with labels and values of parametr # Fill the table with labels and values of parametr
for (my $PCount=0;$PCount<$NParam;$PCount++) { for (my $PCount=0;$PCount<$NParam;$PCount++) {
my ($Param,$value,$error,$minvalue,$maxvalue,$RUN) = split(/,/,$PTable{$PCount}); my ($Param,$value,$error,$minvalue,$maxvalue,$RUN) = split(/,/,$PTable{$PCount});
# Now make sure we have no nans
if ($error eq "nan") { $error=0.1;}
# If you use this then reading the parameters from the table is a problem # If you use this then reading the parameters from the table is a problem
# You need to extract the correct parameter name from the row label # You need to extract the correct parameter name from the row label
# InitParamTable->verticalHeader()->setLabel( $PCount,"$RUN: $Param"); # InitParamTable->verticalHeader()->setLabel( $PCount,"$RUN: $Param");
@ -667,6 +684,7 @@ void MuSRFitform::TabChanged()
# First make sure we have sharing initialized # First make sure we have sharing initialized
ActivateShComp(); ActivateShComp();
# Here we need to apply sharing if selected...
InitializeTab(); InitializeTab();
UpdateMSRFileInitTable(); UpdateMSRFileInitTable();
# And also setup T0 and Bg bins # And also setup T0 and Bg bins
@ -737,6 +755,7 @@ void MuSRFitform::ShowMuSRT0()
if (-e $FILENAME) { if (-e $FILENAME) {
my $cmd="musrt0 $FILENAME &"; my $cmd="musrt0 $FILENAME &";
my $pid = system($cmd); my $pid = system($cmd);
t0Update->setEnabled(1)
} else { } else {
print STDERR "Cannot find MSR file!\n"; print STDERR "Cannot find MSR file!\n";
} }
@ -868,19 +887,19 @@ void MuSRFitform::InitializeFunctions()
my $Parameters=$Paramcomp[$Component-1]; my $Parameters=$Paramcomp[$Component-1];
my @Params = split( /\s+/, $Parameters ); my @Params = split( /\s+/, $Parameters );
# Alpha, N0 and NBg are counted in the parameters # Alpha, No and NBg are counted in the parameters
if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) { if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) {
unshift( @Params, "Alpha" ); unshift( @Params, "Alpha" );
} }
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) { elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
unshift( @Params, ( "N0", "NBg" ) ); unshift( @Params, ( "No", "NBg" ) );
} }
# Add list to the constraints drop down menu # Add list to the constraints drop down menu
for (my $i=1; $i<=9;$i++) { for (my $i=1; $i<=9;$i++) {
my $CParam = $Params[$i-1]."_".$Component; my $CParam = $Params[$i-1]."_".$Component;
if ($Params[$i-1] ne "" ) { if ($Params[$i-1] ne "" ) {
if ($Params[$i-1] ne "Alpha" && $Params[$i-1] ne "N0" && $Params[$i-1] ne "NBg") { if ($Params[$i-1] ne "Alpha" && $Params[$i-1] ne "No" && $Params[$i-1] ne "NBg") {
CParamsCombo->insertItem($CParam,-1); CParamsCombo->insertItem($CParam,-1);
$Full_T_Block=~ s/\b$Params[$i-1]\b/$CParam/; $Full_T_Block=~ s/\b$Params[$i-1]\b/$CParam/;
} }
@ -913,3 +932,41 @@ void MuSRFitform::optionConfigure()
# exit $Customize->exec; # exit $Customize->exec;
} }
void MuSRFitform::t0UpdateClicked()
{
# Read MSR file and get new values of t0,Bg and Data
my %All=CreateAllInput();
my $FILENAME=$All{"FILENAME"};
open (MSRF,q{<},"$FILENAME.msr" );
my @lines = <MSRF>;
close(IFILE);
my @T0s = grep {/t0 /} @lines;
my @Bgs = grep {/background /} @lines;
my @Datas = grep {/data /} @lines;
my @Hists = split(/,/, $All{"LRBF"} );
my $NHist = $#Hists+1;
print "Histograms: $NHist\n";
my $FinHist = 1;
# First T0s
while ($FinHist) {
my $counter=0;
(my $tmp,my @SplitT0) = split( /\s+/, $T0s[$counter]);
(my $tmp,my @SplitBg) = split( /\s+/, $Bgs[$counter]);
(my $tmp,my @SplitData) = split( /\s+/, $Datas[$counter]);
if ($#SplitBg>0) {
foreach (@SplitBg) {
print $_."\n";
}
}
$counter++;
if ($counter>=$#Bgs) {$FinHist=0;}
}
# Finally, disable the update button
t0Update->setEnabled(0);
# t0Update->setText("musrt0")
}