Export using msr2data when appropriate

This commit is contained in:
salman 2018-02-12 15:42:46 +01:00
parent 4a16cbe5d3
commit c62e4c1df6
2 changed files with 168 additions and 117 deletions

View File

@ -56,7 +56,7 @@ sub CreateMSRUni {
# #
# Input in %All # Input in %All
# Required: # Required:
# $All{"FitType1/2/3"} - Function types, 3 components # $All{"FitTypei"} - Function types, i components
# $All{"LRBF"} - Histograms, comma separated # $All{"LRBF"} - Histograms, comma separated
# $All{"Tis"} # $All{"Tis"}
# $All{"Tfs"} # $All{"Tfs"}
@ -86,10 +86,11 @@ sub CreateMSRUni {
my $DEBUG = ""; my $DEBUG = "";
# Start with empty array # Start with empty array
my @FitTypes = (); my @FitTypes = ();
# loop over fitTypes
foreach ($All{"FitType1"},$All{"FitType2"},$All{"FitType3"}) { if (!defined($All{"numComps"})) {$All{"numComps"}=3;}
if ($_ ne "None") { for (my $i=1;$i<=$All{"numComps"};$i++) {
@FitTypes=(@FitTypes,$_); if ( defined($All{"FitType$i"}) &&$All{"FitType$i"} ne "None" ) {
push( @FitTypes, $All{"FitType$i"} );
} }
} }
@ -1047,10 +1048,15 @@ sub PrepParamTable {
} }
my @Hists = split( /,/, $All{"LRBF"} ); my @Hists = split( /,/, $All{"LRBF"} );
my @FitTypes =(); my @FitTypes = ();
foreach my $FitType ($All{"FitType1"}, $All{"FitType2"}, $All{"FitType3"}) { # loop over fitTypes
if ( $FitType ne "None" ) { push( @FitTypes, $FitType ); } if (!defined($All{"numComps"})) {$All{"numComps"}=3;}
for (my $i=1;$i<=$All{"numComps"};$i++) {
if ( defined($All{"FitType$i"}) &&$All{"FitType$i"} ne "None" ) {
push( @FitTypes, $All{"FitType$i"} );
}
} }
# Get theory block to determine the size of the table # Get theory block to determine the size of the table
my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateTheory(@FitTypes); my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateTheory(@FitTypes);
# For now the line below does not work. Why? # For now the line below does not work. Why?
@ -1239,10 +1245,15 @@ sub ExportParams {
} }
my @Hists = split( /,/, $All{"LRBF"} ); my @Hists = split( /,/, $All{"LRBF"} );
my @FitTypes =(); my @FitTypes = ();
foreach my $FitType ($All{"FitType1"}, $All{"FitType2"}, $All{"FitType3"}) { # loop over fitTypes
if ( $FitType ne "None" ) { push( @FitTypes, $FitType ); } if (!defined($All{"numComps"})) {$All{"numComps"}=3;}
for (my $i=1;$i<=$All{"numComps"};$i++) {
if ( defined($All{"FitType$i"}) &&$All{"FitType$i"} ne "None" ) {
push( @FitTypes, $All{"FitType$i"} );
}
} }
# Get theory block to determine the size of the table # Get theory block to determine the size of the table
my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateTheory(@FitTypes); my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateTheory(@FitTypes);
# For now the line below does not work. Why? # For now the line below does not work. Why?

View File

@ -43,10 +43,12 @@ use QtCore4::slots
t0UpdateClicked => []; t0UpdateClicked => [];
use Ui_MuSRFit4; use Ui_MuSRFit4;
my $self = "";
sub NEW { sub NEW {
my ( $class, $parent ) = @_; my ( $class, $parent ) = @_;
$class->SUPER::NEW($parent); $class->SUPER::NEW($parent);
this->{ui} = Ui_MuSRFit4->setupUi(this); $self = Ui_MuSRFit4->setupUi(this);
my %All=CreateAllInput(); my %All=CreateAllInput();
} }
@ -141,9 +143,18 @@ sub parametersExport()
# Exports the fit parameters for a table format file # Exports the fit parameters for a table format file
# This works only after a fit call, i.e. a plot call is not sufficient! # This works only after a fit call, i.e. a plot call is not sufficient!
my %All=CreateAllInput(); my %All=CreateAllInput();
my @RUNS = ();
if ($All{"RUNSType"} ) {
@RUNS = split( /,/, $All{"RunFiles"});
} else {
$All{"RunNumbers"} =~ s/[\ \.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g;
@RUNS = split( /,/, MSR::ExpandRunNumbers($All{"RunNumbers"}) );
}
# Add also a flag for header # Add also a flag for header
$All{"Header"}=1; $All{"Header"}=1;
my $StupidName = $RUNS[0]."+global_tmpl.msr";
my $FILENAME=$All{"FILENAME"}.".dat"; my $FILENAME=$All{"FILENAME"}.".dat";
my $MSR = $All{"FILENAME"}.".msr";
my $file=Qt::FileDialog::getSaveFileName( my $file=Qt::FileDialog::getSaveFileName(
this, this,
"Export parameters to file", "Export parameters to file",
@ -152,10 +163,21 @@ sub parametersExport()
# If the user gave a filename the copy to it # If the user gave a filename the copy to it
if ($file ne "") { if ($file ne "") {
my $Text = MSR::ExportParams(\%All); if ($All{"FitAsyType"} eq "Asymmetry") {
open( DATF,q{>},"$file" ); # my style
print DATF $Text; my $Text = MSR::ExportParams(\%All);
close(DATF); open( DATF,q{>},"$file" );
print DATF $Text;
close(DATF);
} else {
# msr2data style
my $RunList = join(" ",@RUNS);
my $cmd = "cp $MSR $StupidName; msr2data \[".$RunList."\] "." _tmpl new global data -o $file";
my $pid = open(FTO,"$cmd 2>&1 |");
while (<FTO>) {
$self->fitTextOutput->append("$_");
}
}
} }
} }
@ -165,9 +187,18 @@ sub parametersAppend()
# Appends the fit parameters for a table format file # Appends the fit parameters for a table format file
# This works only after a fit call, i.e. a plot call is not sufficient! # This works only after a fit call, i.e. a plot call is not sufficient!
my %All=CreateAllInput(); my %All=CreateAllInput();
my @RUNS = ();
if ($All{"RUNSType"} ) {
@RUNS = split( /,/, $All{"RunFiles"});
} else {
$All{"RunNumbers"} =~ s/[\ \.\~\/\&\*\[\;\>\<\^\$\(\)\`\|\]\'\@]/,/g;
@RUNS = split( /,/, MSR::ExpandRunNumbers($All{"RunNumbers"}) );
}
# Add also a flag for header # Add also a flag for header
$All{"Header"}=0; $All{"Header"}=0;
my $StupidName = $RUNS[0]."+global_tmpl.msr";
my $FILENAME=$All{"FILENAME"}.".dat"; my $FILENAME=$All{"FILENAME"}.".dat";
my $MSR = $All{"FILENAME"}.".msr";
my $file=Qt::FileDialog::getOpenFileName( my $file=Qt::FileDialog::getOpenFileName(
this, this,
"Append parameters to file", "Append parameters to file",
@ -176,10 +207,21 @@ sub parametersAppend()
# If the user gave a filename the copy to it # If the user gave a filename the copy to it
if ($file ne "") { if ($file ne "") {
my $Text = MSR::ExportParams(\%All); if ($All{"FitAsyType"} eq "Asymmetry") {
open( DATF,q{>>},"$file" ); my $Text = MSR::ExportParams(\%All);
print DATF $Text; open( DATF,q{>>},"$file" );
close(DATF); print DATF $Text;
close(DATF);
} else {
# msr2data style
my $RunList = join(" ",@RUNS);
my $cmd = "cp $MSR $StupidName; msr2data \[".$RunList."\] "." _tmpl global data -o $file";
my $pid = open(FTO,"$cmd 2>&1 |");
while (<FTO>) {
$self->fitTextOutput->append("$_");
}
close(FTO);
}
} }
} }
@ -261,47 +303,47 @@ sub CreateAllInput()
# From RUNS Tab # From RUNS Tab
# Run data file # Run data file
$All{"RunNumbers"} = this->{ui}->runNumbers->text(); $All{"RunNumbers"} = $self->runNumbers->text();
$All{"RunFiles"} = this->{ui}->runFiles->text(); $All{"RunFiles"} = $self->runFiles->text();
$All{"BeamLine"} = this->{ui}->beamLine->currentText; $All{"BeamLine"} = $self->beamLine->currentText;
$All{"RUNSType"} = this->{ui}->manualFile->isChecked(); $All{"RUNSType"} = $self->manualFile->isChecked();
$All{"YEAR"} = this->{ui}->year->currentText; $All{"YEAR"} = $self->year->currentText;
if (!defined($All{"YEAR"}) || $All{"YEAR"} eq "") { if (!defined($All{"YEAR"}) || $All{"YEAR"} eq "") {
# If year combobox is empty fill it up from 2004 up to current year # 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 ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
my $current_year = 1900 + $yearOffset; my $current_year = 1900 + $yearOffset;
# my @years = ($current_year..2004); # my @years = ($current_year..2004);
# this->{ui}->year->addItems(@years); # $self->year->addItems(@years);
for (my $i=$current_year;$i>=2004;$i--) { for (my $i=$current_year;$i>=2004;$i--) {
this->{ui}->year->addItem($i); $self->year->addItem($i);
} }
} }
# Time range and BINS # Time range and BINS
$All{"Tis"} = this->{ui}->tis->text; $All{"Tis"} = $self->tis->text;
$All{"Tfs"} = this->{ui}->tfs->text; $All{"Tfs"} = $self->tfs->text;
$All{"BINS"} = this->{ui}->bins->text; $All{"BINS"} = $self->bins->text;
$All{"FitAsyType"} = this->{ui}->fitAsyType->currentText; $All{"FitAsyType"} = $self->fitAsyType->currentText;
$All{"FitAsyType"} =~ s/ //g; $All{"FitAsyType"} =~ s/ //g;
$All{"LRBF"} = this->{ui}->histsLRBF->text; $All{"LRBF"} = $self->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 "SingleHist" ) { if ( $All{"FitAsyType"} eq "SingleHist" ) {
this->{ui}->ltc->setHidden(0); $self->ltc->setHidden(0);
$All{"fittype"}=0; $All{"fittype"}=0;
} else { } else {
this->{ui}->ltc->setHidden(1); $self->ltc->setHidden(1);
$All{"fittype"}=2; $All{"fittype"}=2;
} }
# From Fitting Tab # From Fitting Tab
# Plot range # Plot range
$All{"Xi"}=this->{ui}->xi->text; $All{"Xi"}=$self->xi->text;
$All{"Xf"}=this->{ui}->xf->text; $All{"Xf"}=$self->xf->text;
$All{"Yi"}=this->{ui}->yi->text; $All{"Yi"}=$self->yi->text;
$All{"Yf"}=this->{ui}->yf->text; $All{"Yf"}=$self->yf->text;
$All{"ViewBin"}=this->{ui}->viewBin->text; $All{"ViewBin"}=$self->viewBin->text;
# Life time correction # Life time correction
if (this->{ui}->ltc->isChecked()) { if ($self->ltc->isChecked()) {
$All{"ltc"}="y"; $All{"ltc"}="y";
} else { } else {
$All{"ltc"}="n"; $All{"ltc"}="n";
@ -311,11 +353,11 @@ sub CreateAllInput()
$All{"go"}="PLOT"; $All{"go"}="PLOT";
} }
# Get minimization process # Get minimization process
$All{"Minimization"} = this->{ui}->minimization->currentText(); $All{"Minimization"} = $self->minimization->currentText();
$All{"go"}=$All{"Minimization"}; $All{"go"}=$All{"Minimization"};
# Get Error calculation process # Get Error calculation process
$All{"ErrorCalc"} = this->{ui}->errorCalc->currentText(); $All{"ErrorCalc"} = $self->errorCalc->currentText();
$All{"go"}=$All{"ErrorCalc"}; $All{"go"}=$All{"ErrorCalc"};
# Commands block # Commands block
@ -331,23 +373,23 @@ sub CreateAllInput()
} }
# From MSR File Tab # From MSR File Tab
$All{"TITLE"}= this->{ui}->title->text; $All{"TITLE"}= $self->title->text;
$All{"FILENAME"}= this->{ui}->fileName->text; $All{"FILENAME"}= $self->fileName->text;
# From Fourier Tab # From Fourier Tab
$All{"FUNITS"}= this->{ui}->funits->currentText; $All{"FUNITS"}= $self->funits->currentText;
$All{"FAPODIZATION"}= this->{ui}->fapodization->currentText; $All{"FAPODIZATION"}= $self->fapodization->currentText;
$All{"FPLOT"}= this->{ui}->fplot->currentText; $All{"FPLOT"}= $self->fplot->currentText;
$All{"FPHASE"}=this->{ui}->fphase->text; $All{"FPHASE"}=$self->fphase->text;
# Fourier range # Fourier range
$All{"FrqMin"}=this->{ui}->frqMin->text; $All{"FrqMin"}=$self->frqMin->text;
$All{"FrqMax"}=this->{ui}->frqMax->text; $All{"FrqMax"}=$self->frqMax->text;
# Rotating reference frame parameters # Rotating reference frame parameters
$All{"RRFFrq"}=this->{ui}->rrfFrq->text; $All{"RRFFrq"}=$self->rrfFrq->text;
$All{"RRFPack"}=this->{ui}->rrfPack->text; $All{"RRFPack"}=$self->rrfPack->text;
$All{"RRFPhase"}=this->{ui}->rrfPhase->text; $All{"RRFPhase"}=$self->rrfPhase->text;
$All{"RRFUnits"}=this->{ui}->rrfUnits->currentText; $All{"RRFUnits"}=$self->rrfUnits->currentText;
# Get values of t0 and Bg/Data bins if given # Get values of t0 and Bg/Data bins if given
my $NHist = 1; my $NHist = 1;
@ -393,10 +435,10 @@ sub CreateAllInput()
my $FT3=0; my $FT3=0;
my @FitTypes =(); my @FitTypes =();
my $FT=0; my $FT=0;
if (defined(this->{ui}->numComps)) { if (defined($self->numComps)) {
# new style, check the number of components # new style, check the number of components
$numComps = this->{ui}->numComps->value; $numComps = $self->numComps->value;
if ($numComps != this->{ui}->columnView->count() ) { if ($numComps != $self->columnView->count() ) {
addFitType(); addFitType();
} }
} else { } else {
@ -425,12 +467,12 @@ sub CreateAllInput()
my @Paramcomp = @$Paramcomp_ref; my @Paramcomp = @$Paramcomp_ref;
# Functions block # Functions block
$All{"FunctionsBlock"}=this->{ui}->functionsBlock->toPlainText; $All{"FunctionsBlock"}=$self->functionsBlock->toPlainText;
# and the associated theory block # and the associated theory block
$All{"Func_T_Block"}=this->{ui}->theoryBlock->toPlainText; $All{"Func_T_Block"}=$self->theoryBlock->toPlainText;
# Shared settings are detected here # Shared settings are detected here
$All{"EnableSharing"} = this->{ui}->buttonGroupSharing->isChecked(); $All{"EnableSharing"} = $self->buttonGroupSharing->isChecked();
# Make sure all sharing boxes exist # Make sure all sharing boxes exist
#addSharingComp(); #addSharingComp();
@ -515,7 +557,7 @@ sub CreateAllInput()
my $erradd = "d"; my $erradd = "d";
my $minadd = "_min"; my $minadd = "_min";
my $maxadd = "_max"; my $maxadd = "_max";
my $QTable=this->{ui}->initParamTable; my $QTable=$self->initParamTable;
# TODO: Should not go over all rows, only on parameters. # TODO: Should not go over all rows, only on parameters.
if ($NParam > 0) { if ($NParam > 0) {
# Set appropriate number of rows # Set appropriate number of rows
@ -543,7 +585,7 @@ sub CallMSRCreate()
my %All=CreateAllInput(); my %All=CreateAllInput();
# Check if the option for checking for existing files is selected # Check if the option for checking for existing files is selected
my $FileExistCheck= this->{ui}->fileExistCheck->isChecked(); my $FileExistCheck= $self->fileExistCheck->isChecked();
my $FILENAME=$All{"FILENAME"}.".msr"; my $FILENAME=$All{"FILENAME"}.".msr";
my $Answer=0; my $Answer=0;
if ($All{"RunNumbers"} ne "" || $All{"RunFiles"} ne "") { if ($All{"RunNumbers"} ne "" || $All{"RunFiles"} ne "") {
@ -595,7 +637,7 @@ sub CallMSRCreate()
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("$_"); $self->fitTextOutput->append("$_");
} }
close(FTO); close(FTO);
# change the stupid name # change the stupid name
@ -603,9 +645,8 @@ sub CallMSRCreate()
# change stupid default runs line # change stupid default runs line
$cmd = "cp $StupidName $FILENAME; perl -pi -e 's/runs.*?(?=\n)/$NewRunLine/s' $FILENAME"; $cmd = "cp $StupidName $FILENAME; perl -pi -e 's/runs.*?(?=\n)/$NewRunLine/s' $FILENAME";
$pid = open(FTO,"$cmd 2>&1 |"); $pid = open(FTO,"$cmd 2>&1 |");
print $cmd."\n";
while (<FTO>) { while (<FTO>) {
this->{ui}->fitTextOutput->append("$_"); $self->fitTextOutput->append("$_");
} }
close(FTO); close(FTO);
# feed in values of parameters if they exist # feed in values of parameters if they exist
@ -650,9 +691,9 @@ sub UpdateMSRFileInitTable()
@lines = <MSRF>; @lines = <MSRF>;
close(MSRF); close(MSRF);
} }
this->{ui}->textMSROutput->setText(""); $self->textMSROutput->setText("");
foreach my $line (@lines) { foreach my $line (@lines) {
this->{ui}->textMSROutput->insertPlainText("$line"); $self->textMSROutput->insertPlainText("$line");
} }
(my $TBlock_ref, my $FPBlock_ref)=MSR::ExtractBlks(@lines); (my $TBlock_ref, my $FPBlock_ref)=MSR::ExtractBlks(@lines);
@ -692,7 +733,7 @@ sub UpdateMSRFileInitTable()
$maxvalue=1.0*$Param[7]; $maxvalue=1.0*$Param[7];
} }
# Now update the initialization tabel # Now update the initialization tabel
my $QTable = this->{ui}->initParamTable; my $QTable = $self->initParamTable;
# print "PCount=$PCount and value=$value\n"; # print "PCount=$PCount and value=$value\n";
if (defined($QTable->item($PCount,0)) & defined($QTable->item($PCount,1)) & defined($QTable->item($PCount,2)) & defined($QTable->item($PCount,3))) { if (defined($QTable->item($PCount,0)) & defined($QTable->item($PCount,1)) & defined($QTable->item($PCount,2)) & defined($QTable->item($PCount,3))) {
$QTable->setItem($PCount,0,Qt::TableWidgetItem()); $QTable->setItem($PCount,0,Qt::TableWidgetItem());
@ -745,7 +786,7 @@ sub ActivateShComp()
# Make sure all sharing boxes exist # Make sure all sharing boxes exist
addSharingComp(); addSharingComp();
my $NShComps = this->{ui}->horizontalLayout->count(); my $NShComps = $self->horizontalLayout->count();
my $sharingComp = ""; my $sharingComp = "";
my $i = 1; my $i = 1;
# Hide all sharing components # Hide all sharing components
@ -827,7 +868,7 @@ sub ActivateShComp()
sub InitializeTab() sub InitializeTab()
{ {
my %All=CreateAllInput(); my %All=CreateAllInput();
my $QTable = this->{ui}->initParamTable; my $QTable = $self->initParamTable;
my $NRows = $QTable->rowCount(); my $NRows = $QTable->rowCount();
# Remove any rows in table # Remove any rows in table
@ -875,7 +916,7 @@ sub TabChanged()
{ {
# TODO: First check if there are some runs given, otherwise disbale # TODO: First check if there are some runs given, otherwise disbale
my %All=CreateAllInput(); my %All=CreateAllInput();
my $curTab = this->{ui}->musrfit_tabs->currentIndex(); my $curTab = $self->musrfit_tabs->currentIndex();
if ($curTab >= 2 && $curTab <= 4) { if ($curTab >= 2 && $curTab <= 4) {
# First make sure we have sharing initialized # First make sure we have sharing initialized
ActivateShComp(); ActivateShComp();
@ -906,7 +947,7 @@ sub GoFit()
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);
} else { } else {
this->{ui}->musrfit_tabs->setCurrentIndex(1); $self->musrfit_tabs->setCurrentIndex(1);
my $Answer=CallMSRCreate(); my $Answer=CallMSRCreate();
my $FILENAME=$All{"FILENAME"}.".msr"; my $FILENAME=$All{"FILENAME"}.".msr";
if ($Answer) { if ($Answer) {
@ -914,13 +955,13 @@ sub GoFit()
my $cmd="musrfit -t $FILENAME; musrview $FILENAME &"; my $cmd="musrfit -t $FILENAME; musrview $FILENAME &";
my $pid = open(FTO,"$cmd 2>&1 |"); my $pid = open(FTO,"$cmd 2>&1 |");
while (<FTO>) { while (<FTO>) {
this->{ui}->fitTextOutput->insertPlainText("$_"); $self->fitTextOutput->insertPlainText("$_");
} }
close(FTO); close(FTO);
} else { } else {
this->{ui}->fitTextOutput->insertPlainText("Cannot find MSR file!"); $self->fitTextOutput->insertPlainText("Cannot find MSR file!");
} }
this->{ui}->fitTextOutput->insertPlainText("-----------------------------------------------------------------------------------------------------------------------------"); $self->fitTextOutput->insertPlainText("-----------------------------------------------------------------------------------------------------------------------------");
# update MSR File tab and initialization table # update MSR File tab and initialization table
UpdateMSRFileInitTable(); UpdateMSRFileInitTable();
} }
@ -947,8 +988,8 @@ sub GoPlot()
my $cmd="musrview $FILENAME &"; my $cmd="musrview $FILENAME &";
my $pid = system($cmd); my $pid = system($cmd);
} else { } else {
this->{ui}->fitTextOutput->insertPlainText("Cannot find MSR file!"); $self->fitTextOutput->insertPlainText("Cannot find MSR file!");
this->{ui}->fitTextOutput->insertPlainText("-----------------------------------------------------------------------------------------------------------------------------"); $self->fitTextOutput->insertPlainText("-----------------------------------------------------------------------------------------------------------------------------");
} }
} }
} }
@ -960,7 +1001,7 @@ sub ShowMuSRT0()
{ {
# Open musrt0 to check and adjust t0 , Bg and Data bins # Open musrt0 to check and adjust t0 , Bg and Data bins
my %All=CreateAllInput(); my %All=CreateAllInput();
this->{ui}->musrfit_tabs->setCurrentIndex(6); $self->musrfit_tabs->setCurrentIndex(6);
# Create MSR file and then run musrt0 # Create MSR file and then run musrt0
my $Answer=CallMSRCreate(); my $Answer=CallMSRCreate();
@ -969,7 +1010,7 @@ sub ShowMuSRT0()
if (-e $FILENAME) { if (-e $FILENAME) {
my $cmd="musrt0 $FILENAME &"; my $cmd="musrt0 $FILENAME &";
my $pid = system($cmd); my $pid = system($cmd);
this->{ui}->t0Update->setEnabled(1) $self->t0Update->setEnabled(1)
} else { } else {
print STDERR "Cannot find MSR file!\n"; print STDERR "Cannot find MSR file!\n";
} }
@ -1000,28 +1041,28 @@ sub t0Update()
sub RunSelectionToggle() sub RunSelectionToggle()
{ {
my $ManualFile= this->{ui}->manualFile->isChecked(); my $ManualFile= $self->manualFile->isChecked();
if ($ManualFile) { if ($ManualFile) {
# Manual RUN selection # Manual RUN selection
this->{ui}->runsMan->setEnabled(1); $self->runsMan->setEnabled(1);
this->{ui}->runsMan->setHidden(0); $self->runsMan->setHidden(0);
this->{ui}->runNumbers->setText(""); $self->runNumbers->setText("");
this->{ui}->runsAuto->setEnabled(0); $self->runsAuto->setEnabled(0);
this->{ui}->runsAuto->setHidden(1); $self->runsAuto->setHidden(1);
} else { } else {
# Auto RUN selection # Auto RUN selection
this->{ui}->runsMan->setEnabled(0); $self->runsMan->setEnabled(0);
this->{ui}->runsMan->setHidden(1); $self->runsMan->setHidden(1);
this->{ui}->runFiles->setText(""); $self->runFiles->setText("");
this->{ui}->runsAuto->setEnabled(1); $self->runsAuto->setEnabled(1);
this->{ui}->runsAuto->setHidden(0); $self->runsAuto->setHidden(0);
} }
} }
sub fileBrowse() sub fileBrowse()
{ {
my $RunFiles=this->{ui}->runFiles->text(); my $RunFiles=$self->runFiles->text();
print "Runs:$RunFiles\n"; print "Runs:$RunFiles\n";
my $files_ref=Qt::FileDialog::getOpenFileNames( my $files_ref=Qt::FileDialog::getOpenFileNames(
"Data files (*.root *.bin)", "Data files (*.root *.bin)",
@ -1037,33 +1078,33 @@ sub fileBrowse()
# Add files to existing list # Add files to existing list
$RunFiles=join(",",$RunFiles,@files); $RunFiles=join(",",$RunFiles,@files);
} }
this->{ui}->runFiles->setText($RunFiles); $self->runFiles->setText($RunFiles);
} }
sub AppendToFunctions() sub AppendToFunctions()
{ {
my $ParName=this->{ui}->cParamsCombo->currentText(); my $ParName=$self->cParamsCombo->currentText();
my $Full_T_Block=""; my $Full_T_Block="";
my $Constraint=""; my $Constraint="";
if (defined(this->{ui}->theoryBlock->toPlainText)) { if (defined($self->theoryBlock->toPlainText)) {
$Full_T_Block=this->{ui}->theoryBlock->toPlainText; $Full_T_Block=$self->theoryBlock->toPlainText;
} }
if (defined(this->{ui}->constraintLine->text)) { if (defined($self->constraintLine->text)) {
$Constraint=this->{ui}->constraintLine->text; $Constraint=$self->constraintLine->text;
} }
# Then clear the text # Then clear the text
this->{ui}->constraintLine->setText(""); $self->constraintLine->setText("");
# Check how many constraints (lines) in FUNCTIONS Block # Check how many constraints (lines) in FUNCTIONS Block
# my $i=this->{ui}->functionsBlock->blockCount(); # my $i=$self->functionsBlock->blockCount();
my $fun_lines=this->{ui}->functionsBlock->toPlainText(); my $fun_lines=$self->functionsBlock->toPlainText();
my $i= ($fun_lines =~ tr/\n//)+1; my $i= ($fun_lines =~ tr/\n//)+1;
my $ConstLine="fun$i = $Constraint\n"; my $ConstLine="fun$i = $Constraint\n";
this->{ui}->functionsBlock->insertPlainText($ConstLine); $self->functionsBlock->insertPlainText($ConstLine);
# Replace parameter in theory block with fun$i # Replace parameter in theory block with fun$i
$Full_T_Block=~ s/$ParName/fun$i/; $Full_T_Block=~ s/$ParName/fun$i/;
this->{ui}->theoryBlock->setText($Full_T_Block); $self->theoryBlock->setText($Full_T_Block);
} }
sub InitializeFunctions() sub InitializeFunctions()
@ -1086,10 +1127,10 @@ sub InitializeFunctions()
# Initialize Parameters List in function block (constraints). # Initialize Parameters List in function block (constraints).
my $ParametersList=""; my $ParametersList="";
this->{ui}->parametersList->setText(""); $self->parametersList->setText("");
# Counter for function block (with out Alpha etc.) # Counter for function block (with out Alpha etc.)
my $ParCount=0; my $ParCount=0;
this->{ui}->cParamsCombo->clear(); $self->cParamsCombo->clear();
# Possibly use the parameters block to axtract names for the dropdown menu # Possibly use the parameters block to axtract names for the dropdown menu
# this makes sense if we can use fun in map line. Check! # this makes sense if we can use fun in map line. Check!
@ -1122,22 +1163,22 @@ sub InitializeFunctions()
if (defined($Params[$i-1])) { if (defined($Params[$i-1])) {
my $CParam = $Params[$i-1]."_".$Component; my $CParam = $Params[$i-1]."_".$Component;
if ($Params[$i-1] ne "Alpha" && $Params[$i-1] ne "No" && $Params[$i-1] ne "NBg") { if ($Params[$i-1] ne "Alpha" && $Params[$i-1] ne "No" && $Params[$i-1] ne "NBg") {
this->{ui}->cParamsCombo->addItem($CParam); $self->cParamsCombo->addItem($CParam);
$Full_T_Block=~ s/\b$Params[$i-1]\b/$CParam/; $Full_T_Block=~ s/\b$Params[$i-1]\b/$CParam/;
} }
# also enumerate the parameters as should be used in the FUNCTIONS Block # also enumerate the parameters as should be used in the FUNCTIONS Block
$ParCount++; $ParCount++;
$ParametersList=$ParametersList."$CParam \t is \t par$ParCount\n"; $ParametersList=$ParametersList."$CParam \t is \t par$ParCount\n";
this->{ui}->parametersList->setText($ParametersList); $self->parametersList->setText($ParametersList);
} }
} }
$Component++; $Component++;
} }
# Set theory block in Constraints # Set theory block in Constraints
this->{ui}->theoryBlock->setText($Full_T_Block); $self->theoryBlock->setText($Full_T_Block);
# Then clear the text # Then clear the text
this->{ui}->constraintLine->setText(""); $self->constraintLine->setText("");
this->{ui}->functionsBlock->setText(""); $self->functionsBlock->setText("");
} }
@ -1177,7 +1218,7 @@ sub t0UpdateClicked()
} }
# Finally, disable the update button # Finally, disable the update button
this->{ui}->t0Update->setEnabled(0); $self->t0Update->setEnabled(0);
# t0Update->setText("musrt0") # t0Update->setText("musrt0")
} }
@ -1199,18 +1240,18 @@ sub child {
sub addFitType { sub addFitType {
# Input number of components # Input number of components
my $numComps = this->{ui}->numComps->value; my $numComps = $self->numComps->value;
# count number of exisitng components # count number of exisitng components
my $NButtons = this->{ui}->columnView->count(); my $NButtons = $self->columnView->count();
# create ComboBox in theoryFunction parent # create ComboBox in theoryFunction parent
my $fitType = Qt::ComboBox( this->{ui}->theoryFunction ); my $fitType = Qt::ComboBox( $self->theoryFunction );
# do we have less components that we need # do we have less components that we need
if ($numComps > $NButtons) { if ($numComps > $NButtons) {
# add as needed # add as needed
for (my $i=$NButtons+1;$i<=$numComps;$i++) { for (my $i=$NButtons+1;$i<=$numComps;$i++) {
my $nameComp = "fitType$i"; my $nameComp = "fitType$i";
this->{ui}->columnView->addWidget( $fitType ); $self->columnView->addWidget( $fitType );
$fitType->setObjectName( $nameComp ); $fitType->setObjectName( $nameComp );
$fitType->setMinimumSize( Qt::Size(0, 25) ); $fitType->setMinimumSize( Qt::Size(0, 25) );
$fitType->setMaximumSize( Qt::Size(255, 25) ); $fitType->setMaximumSize( Qt::Size(255, 25) );
@ -1245,16 +1286,15 @@ sub addFitType {
} else { } else {
for (my $i=$NButtons;$i > $numComps ;$i--) { for (my $i=$NButtons;$i > $numComps ;$i--) {
# component is there, delete it # component is there, delete it
my $widget = this->{ui}->columnView->itemAt($i-1)->widget(); my $widget = $self->columnView->itemAt($i-1)->widget();
$widget -> hide(); $widget -> hide();
this->{ui}->columnView->removeWidget($widget); $self->columnView->removeWidget($widget);
undef $widget; undef $widget;
} }
} }
} }
sub addSharingComp { sub addSharingComp {
my $self = this->{ui};
# Input number of components # Input number of components
my $numComps = $self->numComps->value; my $numComps = $self->numComps->value;
# count number of exisitng components # count number of exisitng components