Partial implementation of global fit option using msr2data.
This commit is contained in:
parent
2e2f4554a9
commit
924edcf70f
1162
src/external/MuSRFitGUI/MSR.pm
vendored
1162
src/external/MuSRFitGUI/MSR.pm
vendored
File diff suppressed because it is too large
Load Diff
82
src/external/MuSRFitGUI/MuSRFit4.pm
vendored
82
src/external/MuSRFitGUI/MuSRFit4.pm
vendored
@ -282,13 +282,12 @@ sub CreateAllInput()
|
|||||||
$All{"LRBF"} = this->{ui}->histsLRBF->text;
|
$All{"LRBF"} = this->{ui}->histsLRBF->text;
|
||||||
my @Hists = split(/,/, $All{"LRBF"} );
|
my @Hists = split(/,/, $All{"LRBF"} );
|
||||||
# Lifetime corrections in enabled/visible only for SingleHis fits
|
# Lifetime corrections in enabled/visible only for SingleHis fits
|
||||||
if ( $All{"FitAsyType"} eq "Asymmetry" ) {
|
if ( $All{"FitAsyType"} eq "SingleHist" ) {
|
||||||
this->{ui}->ltc->setHidden(1);
|
|
||||||
$All{"fittype"}=2;
|
|
||||||
}
|
|
||||||
elsif ( $All{"FitAsyType"} eq "SingleHist" ) {
|
|
||||||
this->{ui}->ltc->setHidden(0);
|
this->{ui}->ltc->setHidden(0);
|
||||||
$All{"fittype"}=0;
|
$All{"fittype"}=0;
|
||||||
|
} else {
|
||||||
|
this->{ui}->ltc->setHidden(1);
|
||||||
|
$All{"fittype"}=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
# From Fitting Tab
|
# From Fitting Tab
|
||||||
@ -419,10 +418,9 @@ sub CreateAllInput()
|
|||||||
my $Parameters=$Paramcomp[$Component-1];
|
my $Parameters=$Paramcomp[$Component-1];
|
||||||
my @Params = split( /\s+/, $Parameters );
|
my @Params = split( /\s+/, $Parameters );
|
||||||
|
|
||||||
if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) {
|
if ( $Component == 1 && ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB" )) {
|
||||||
unshift( @Params, "Alpha" );
|
unshift( @Params, "Alpha" );
|
||||||
}
|
} elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||||
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
|
||||||
unshift( @Params, ( "No", "NBg" ) );
|
unshift( @Params, ( "No", "NBg" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +439,7 @@ sub CreateAllInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Is there any point of sharing, multiple runs?
|
# Is there any point of sharing, multiple runs?
|
||||||
if ( $#RUNS == 0 && $All{"FitAsyType"} eq "Asymmetry") {
|
if ( $#RUNS == 0 && ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB")) {
|
||||||
$Shared = 1;
|
$Shared = 1;
|
||||||
}
|
}
|
||||||
elsif ( $#RUNS == 0 && $#Hists == 0 && $All{"FitAsyType"} eq "SingleHist" ) {
|
elsif ( $#RUNS == 0 && $#Hists == 0 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||||
@ -532,49 +530,54 @@ sub CallMSRCreate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Answer) {
|
if ($Answer) {
|
||||||
if ( $All{"FitAsyType"} eq "Asymmetry" ) {
|
if ( $All{"FitAsyType"} eq "Asymmetry") {
|
||||||
if ($All{"RUNSType"}) {
|
if ($All{"RUNSType"}) {
|
||||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSR(\%All);
|
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRUni(\%All);
|
||||||
# Open output file FILENAME.msr
|
# Open output file FILENAME.msr
|
||||||
open( OUTF,q{>},"$FILENAME" );
|
open( OUTF,q{>},"$FILENAME" );
|
||||||
print OUTF ("$FullMSRFile");
|
print OUTF ("$FullMSRFile");
|
||||||
close(OUTF);
|
close(OUTF);
|
||||||
} else {
|
} else {
|
||||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSR(\%All);
|
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRUni(\%All);
|
||||||
# Open output file FILENAME.msr
|
# Open output file FILENAME.msr
|
||||||
open( OUTF,q{>},"$FILENAME" );
|
open( OUTF,q{>},"$FILENAME" );
|
||||||
print OUTF ("$FullMSRFile");
|
print OUTF ("$FullMSRFile");
|
||||||
close(OUTF);
|
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"};
|
|
||||||
if ($All{"BeamLine"} eq "LEM (PPC)") {
|
|
||||||
$Extension = "_LEM_".$All{"YEAR"};
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRGLB(\%All);
|
||||||
|
my @RUNS = split( /,/,MSR::ExpandRunNumbers($All{"RunNumbers"}));
|
||||||
|
my @Hists = split( /,/, $All{"LRBF"} );
|
||||||
|
# Write to template file
|
||||||
|
open( OUTF,q{>},"$RUNS[0]_tmpl.msr" );
|
||||||
|
print OUTF ("$FullMSRFile");
|
||||||
|
close(OUTF);
|
||||||
|
|
||||||
if (-e $FILENAME) {
|
# Change runs line in the final global fit
|
||||||
my $RUN0 = $FILENAME;
|
my $NSpectra = ($#RUNS+1)*($#Hists+1);
|
||||||
$RUN0 =~ s/$Extension//g;
|
my $NewRunLine = "runs ".join(" ",(1...$NSpectra));
|
||||||
$RUN0 =~ s/.msr//g;
|
# Use msr2data to generate global fit MSR file
|
||||||
my $cmd = $All{"RunNumbers"};
|
my $RunList = join(" ",@RUNS);
|
||||||
$cmd =~ s/,/ /g;
|
my $cmd = "msr2data \[".$RunList."\] "." _tmpl msr-".$RUNS[0]." global";
|
||||||
$cmd = "msr2data \[".$cmd."\] ".$Extension." msr-".$RUN0." global";
|
# create the global file
|
||||||
$cmd = $cmd."; mv $RUN0+global$Extension.msr ".$FILENAME;
|
|
||||||
print $cmd."\n";
|
print $cmd."\n";
|
||||||
my $pid = open(FTO,"$cmd 2>&1 |");
|
my $pid = open(FTO,"$cmd 2>&1 |");
|
||||||
while (<FTO>) {
|
while (<FTO>) {
|
||||||
this->{ui}->fitTextOutput->append("$_");
|
this->{ui}->fitTextOutput->append("$_");
|
||||||
}
|
}
|
||||||
close(FTO);
|
close(FTO);
|
||||||
|
# change the stupid name
|
||||||
|
my $StupidName = $RUNS[0]."+global_tmpl.msr";
|
||||||
|
# change stupid default runs line
|
||||||
|
$cmd = "cp $StupidName $FILENAME; perl -pi -e 's/runs.*?(?=\n)/$NewRunLine/s' $FILENAME";
|
||||||
|
$pid = open(FTO,"$cmd 2>&1 |");
|
||||||
|
print $cmd."\n";
|
||||||
|
while (<FTO>) {
|
||||||
|
this->{ui}->fitTextOutput->append("$_");
|
||||||
}
|
}
|
||||||
}
|
close(FTO);
|
||||||
}
|
# feed in values of parameters if they exist
|
||||||
elsif ( $All{"FitAsyType"} eq "SingleHist" ) {
|
|
||||||
my ($Full_T_Block,$Paramcomp_ref,$FullMSRFile)= MSR::CreateMSRSingleHist(\%All);
|
|
||||||
# Open output file FILENAME.msr
|
|
||||||
open( OUTF,q{>},"$FILENAME" );
|
|
||||||
print OUTF ("$FullMSRFile");
|
|
||||||
close(OUTF);
|
|
||||||
}
|
}
|
||||||
UpdateMSRFileInitTable();
|
UpdateMSRFileInitTable();
|
||||||
}
|
}
|
||||||
@ -614,7 +617,8 @@ sub UpdateMSRFileInitTable()
|
|||||||
# if it is last element or there are two more = positive error, check $#Param=5/7
|
# if it is last element or there are two more = positive error, check $#Param=5/7
|
||||||
# if there is only one more = minimum, check $#Param=6
|
# if there is only one more = minimum, check $#Param=6
|
||||||
|
|
||||||
# To summarize, check the value of $#Param
|
# To summarize, check the value of $#Param
|
||||||
|
my $name=$Param[2];
|
||||||
my $value=1.0*$Param[3];
|
my $value=1.0*$Param[3];
|
||||||
my $error = 1.0*$Param[4];
|
my $error = 1.0*$Param[4];
|
||||||
my $minvalue=0.0;
|
my $minvalue=0.0;
|
||||||
@ -640,6 +644,8 @@ sub UpdateMSRFileInitTable()
|
|||||||
$QTable->setItem($PCount,1,Qt::TableWidgetItem());
|
$QTable->setItem($PCount,1,Qt::TableWidgetItem());
|
||||||
$QTable->setItem($PCount,2,Qt::TableWidgetItem());
|
$QTable->setItem($PCount,2,Qt::TableWidgetItem());
|
||||||
$QTable->setItem($PCount,3,Qt::TableWidgetItem());
|
$QTable->setItem($PCount,3,Qt::TableWidgetItem());
|
||||||
|
# Set also label or row
|
||||||
|
$QTable->verticalHeaderItem($PCount)->setText($name);
|
||||||
$QTable->item($PCount,0)->setText($value);
|
$QTable->item($PCount,0)->setText($value);
|
||||||
$QTable->item($PCount,1)->setText($error);
|
$QTable->item($PCount,1)->setText($error);
|
||||||
$QTable->item($PCount,2)->setText($minvalue);
|
$QTable->item($PCount,2)->setText($minvalue);
|
||||||
@ -710,7 +716,7 @@ sub ActivateShComp()
|
|||||||
my $Parameters=$Paramcomp[$Component-1];
|
my $Parameters=$Paramcomp[$Component-1];
|
||||||
my @Params = split( /\s+/, $Parameters );
|
my @Params = split( /\s+/, $Parameters );
|
||||||
|
|
||||||
if ( $Component == 1 && $All{"FitAsyType"} eq "Asymmetry" ) {
|
if ( $Component == 1 && ($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB")) {
|
||||||
unshift( @Params, "Alpha" );
|
unshift( @Params, "Alpha" );
|
||||||
}
|
}
|
||||||
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||||
@ -821,7 +827,7 @@ sub GoFit()
|
|||||||
# Check here is the number of histograms makes sense
|
# Check here is the number of histograms makes sense
|
||||||
# other wise give error.
|
# other wise give error.
|
||||||
my @Hists = split( /,/, $All{"LRBF"} );
|
my @Hists = split( /,/, $All{"LRBF"} );
|
||||||
if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) {
|
if (($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB") && $#Hists != 1) {
|
||||||
# we have a problem here send error message
|
# we have a problem here send error message
|
||||||
my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!";
|
my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!";
|
||||||
my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning);
|
my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning);
|
||||||
@ -856,7 +862,7 @@ sub GoPlot()
|
|||||||
# Check here is the number of histograms makes sense
|
# Check here is the number of histograms makes sense
|
||||||
# other wise give error.
|
# other wise give error.
|
||||||
my @Hists = split( /,/, $All{"LRBF"} );
|
my @Hists = split( /,/, $All{"LRBF"} );
|
||||||
if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) {
|
if (($All{"FitAsyType"} eq "Asymmetry" || $All{"FitAsyType"} eq "AsymmetryGLB") && $#Hists != 1) {
|
||||||
# we have a problem here send error message
|
# we have a problem here send error message
|
||||||
my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!";
|
my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!";
|
||||||
my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning);
|
my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning);
|
||||||
@ -1019,7 +1025,7 @@ sub InitializeFunctions()
|
|||||||
my @Params = split( /\s+/, $Parameters );
|
my @Params = split( /\s+/, $Parameters );
|
||||||
|
|
||||||
# Alpha, No 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" || $All{"FitAsyType"} eq "AsymmetryGLB" )) {
|
||||||
unshift( @Params, "Alpha" );
|
unshift( @Params, "Alpha" );
|
||||||
}
|
}
|
||||||
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
elsif ( $Component == 1 && $All{"FitAsyType"} eq "SingleHist" ) {
|
||||||
|
9
src/external/MuSRFitGUI/MuSRFit4.ui
vendored
9
src/external/MuSRFitGUI/MuSRFit4.ui
vendored
@ -231,7 +231,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Asymmetry</string>
|
<string>Asymmetry GLB</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -241,12 +241,7 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Asymmetry GLB</string>
|
<string>Asymmetry</string>
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Single Hist GLB</string>
|
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
|
7
src/external/MuSRFitGUI/Ui_MuSRFit4.pm
vendored
7
src/external/MuSRFitGUI/Ui_MuSRFit4.pm
vendored
@ -5,7 +5,7 @@
|
|||||||
#################################################################################
|
#################################################################################
|
||||||
## Form generated from reading UI file 'MuSRFit4.ui'
|
## Form generated from reading UI file 'MuSRFit4.ui'
|
||||||
##
|
##
|
||||||
## Created: Mon Jan 29 14:11:03 2018
|
## Created: Mon Feb 5 15:38:20 2018
|
||||||
## by: Qt User Interface Compiler version 4.8.7
|
## by: Qt User Interface Compiler version 4.8.7
|
||||||
##
|
##
|
||||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
@ -3199,10 +3199,9 @@ sub retranslateUi {
|
|||||||
$self->{browse}->setWhatsThis( Qt::Application::translate( 'MuSRFit4', "Browse to select data files for fitting.", undef, Qt::Application::UnicodeUTF8() ) );
|
$self->{browse}->setWhatsThis( Qt::Application::translate( 'MuSRFit4', "Browse to select data files for fitting.", undef, Qt::Application::UnicodeUTF8() ) );
|
||||||
$self->{browse}->setText( Qt::Application::translate( 'MuSRFit4', "Browse", undef, Qt::Application::UnicodeUTF8() ) );
|
$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->{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() ),
|
$self->{fitAsyType}->insertItems(0, [Qt::Application::translate( 'MuSRFit4', "Asymmetry GLB", undef, Qt::Application::UnicodeUTF8() ),
|
||||||
Qt::Application::translate( 'MuSRFit4', "Single Hist", 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', "Asymmetry", 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->{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->{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->{runsAuto}->setTitle( Qt::Application::translate( 'MuSRFit4', "RUN Numbers", undef, Qt::Application::UnicodeUTF8() ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user