Fixed bug when handling a wrong chemical formula (issue MUSR-303).
This commit is contained in:
parent
9609ebe149
commit
efd0f35f54
@ -83,9 +83,8 @@ sub internal_formula_parser {
|
|||||||
sub add_formula_strings {
|
sub add_formula_strings {
|
||||||
my ($formula, $coef, %elements) = @_;
|
my ($formula, $coef, %elements) = @_;
|
||||||
|
|
||||||
# print "Getting Formula of $formula\n";
|
if ($formula =~ /^(?:([A-Z][a-z]*)(\d+\.?\d*)?)+$/o) {
|
||||||
$formula =~ /^(?:([A-Z][a-z]*)(\d+\.?\d*)?)+$/o # XXX new
|
# or die "Invalid Portion of Formula $formula";
|
||||||
or die "Invalid Portion of Formula $formula";
|
|
||||||
while ($formula =~ m/([A-Z][a-z]*)(\d+\.?\d*)?/go) { # XXX new
|
while ($formula =~ m/([A-Z][a-z]*)(\d+\.?\d*)?/go) { # XXX new
|
||||||
my ($elm, $count) = ($1, $2);
|
my ($elm, $count) = ($1, $2);
|
||||||
$count = 1 unless defined $count;
|
$count = 1 unless defined $count;
|
||||||
@ -96,6 +95,7 @@ sub add_formula_strings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return %elements;
|
return %elements;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ParensBalanced {
|
sub ParensBalanced {
|
||||||
|
@ -31,7 +31,6 @@ use QtCore4::slots
|
|||||||
SaveFileAs => [];
|
SaveFileAs => [];
|
||||||
use Ui_TrimSPGUI4;
|
use Ui_TrimSPGUI4;
|
||||||
|
|
||||||
|
|
||||||
sub NEW {
|
sub NEW {
|
||||||
my ( $class, $parent ) = @_;
|
my ( $class, $parent ) = @_;
|
||||||
$class->SUPER::NEW($parent);
|
$class->SUPER::NEW($parent);
|
||||||
@ -52,7 +51,7 @@ sub child {
|
|||||||
sub CollectValues
|
sub CollectValues
|
||||||
{
|
{
|
||||||
my %All=();
|
my %All=();
|
||||||
$All{"numLayer"}=this->{ui}->numLayer->value();
|
$All{"numLayer"}= this->{ui}->numLayer->value();
|
||||||
# Collect layers parameters
|
# Collect layers parameters
|
||||||
for (my $i=1;$i<=$All{"numLayer"};$i++) {
|
for (my $i=1;$i<=$All{"numLayer"};$i++) {
|
||||||
my $LComp = "L".$i."Comp";
|
my $LComp = "L".$i."Comp";
|
||||||
@ -353,7 +352,9 @@ sub CreateInpFile
|
|||||||
my $Comp = this->{ui}->layerTable->item($i-1,0)->text();
|
my $Comp = this->{ui}->layerTable->item($i-1,0)->text();
|
||||||
$All{$LComp} = $Comp;
|
$All{$LComp} = $Comp;
|
||||||
my %LElComp=Chem::parse_formula($Comp);
|
my %LElComp=Chem::parse_formula($Comp);
|
||||||
|
foreach my $key (keys %LElComp) {if ($key eq "") {$Check++;}}
|
||||||
if ($Comp eq "") {$Check++;}
|
if ($Comp eq "") {$Check++;}
|
||||||
|
# Write composition to results file header
|
||||||
|
|
||||||
# Densities of layers
|
# Densities of layers
|
||||||
my $Lrho="L".$i."rho";
|
my $Lrho="L".$i."rho";
|
||||||
@ -369,7 +370,7 @@ sub CreateInpFile
|
|||||||
|
|
||||||
# Sanity check, is the layer supposed to have value? are they all there?
|
# Sanity check, is the layer supposed to have value? are they all there?
|
||||||
if ($Check!=0) {
|
if ($Check!=0) {
|
||||||
my $ErrMsg="Error: Layer $i is empty. Expecting it to be defined!\n";
|
my $ErrMsg="Error: Layer $i is empty or bad chemical formula.\nPleach check!\n";
|
||||||
print STDERR $ErrMsg;
|
print STDERR $ErrMsg;
|
||||||
my $HelpWindow = Qt::MessageBox::information( this, "Error!",$ErrMsg);
|
my $HelpWindow = Qt::MessageBox::information( this, "Error!",$ErrMsg);
|
||||||
return("ERROR");
|
return("ERROR");
|
||||||
@ -417,10 +418,9 @@ sub CreateInpFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach my $key (keys %All) {
|
foreach my $key (keys %All) {
|
||||||
# print $key,$All{$key},"\n";
|
|
||||||
if ($All{$key} ne ""){
|
if ($All{$key} ne ""){
|
||||||
$TemplateFile =~ s/$key/$All{$key}/;
|
$TemplateFile =~ s/$key/$All{$key}/;
|
||||||
# Seed repeats three times
|
# Seed repeats three times
|
||||||
if ($key eq "ranSeed") { $TemplateFile =~ s/$key/$All{$key}/g;}
|
if ($key eq "ranSeed") { $TemplateFile =~ s/$key/$All{$key}/g;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -477,6 +477,8 @@ sub StartSequenceOne
|
|||||||
my @SdzValues=();
|
my @SdzValues=();
|
||||||
my $cmd="";
|
my $cmd="";
|
||||||
|
|
||||||
|
my @called = caller;
|
||||||
|
print "pck=".$called[0]." fln=".$called[1]." line=".$called[2];
|
||||||
if (!$ENV{'TRIMBIN'}) {
|
if (!$ENV{'TRIMBIN'}) {
|
||||||
# If trim.sp binary is not defined give warning and return
|
# If trim.sp binary is not defined give warning and return
|
||||||
my $Warning = Qt::MessageBox::information( this, "Warning!",
|
my $Warning = Qt::MessageBox::information( this, "Warning!",
|
||||||
@ -492,7 +494,9 @@ sub StartSequenceOne
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $Progress=0;
|
my $Progress=0;
|
||||||
|
$All{"SdzFlag"}=0;
|
||||||
if ($All{"scanSeq"}) {
|
if ($All{"scanSeq"}) {
|
||||||
|
# For multiple runs or a scan
|
||||||
if ($All{"radioList"}) {
|
if ($All{"radioList"}) {
|
||||||
@SValues=split(/,/,$All{"scanList"});
|
@SValues=split(/,/,$All{"scanList"});
|
||||||
@SdzValues=split(/,/,$All{"scanListdz"});
|
@SdzValues=split(/,/,$All{"scanListdz"});
|
||||||
@ -522,7 +526,7 @@ sub StartSequenceOne
|
|||||||
$ScanAttrib = child("Qt::LineEdit","numberProj");
|
$ScanAttrib = child("Qt::LineEdit","numberProj");
|
||||||
} elsif ($All{"comboScan"}==5) {
|
} elsif ($All{"comboScan"}==5) {
|
||||||
$ScanName = "Ld".$All{"scandL"};
|
$ScanName = "Ld".$All{"scandL"};
|
||||||
$ScanAttrib = this->{ui}->layerTable->item($All{"ScandL"}-1,2);
|
$ScanAttrib = this->{ui}->layerTable->item($All{"scandL"}-1,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $iScan=0;
|
my $iScan=0;
|
||||||
@ -541,17 +545,26 @@ sub StartSequenceOne
|
|||||||
open (INPF,q{>}, "$FILENAME.inp" );
|
open (INPF,q{>}, "$FILENAME.inp" );
|
||||||
print INPF $eingabe1;
|
print INPF $eingabe1;
|
||||||
close(INPF);
|
close(INPF);
|
||||||
# Use Linux version
|
# Use Linux version
|
||||||
$Progress=$Progress+90/$#SValues;
|
$Progress=$Progress+90/$#SValues;
|
||||||
this->{ui}->progress->setValue($Progress);
|
this->{ui}->progress->setValue($Progress);
|
||||||
this->{ui}->progress->update();
|
this->{ui}->progress->update();
|
||||||
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
|
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
|
||||||
system($cmd);
|
my $pid = fork();
|
||||||
|
die "Unable to fork: $!" unless defined($pid);
|
||||||
|
if (!$pid) { # child
|
||||||
|
exec($cmd);
|
||||||
|
die "Unable to exec: $!";
|
||||||
|
}
|
||||||
|
while (wait () != -1){}
|
||||||
|
#system($cmd);
|
||||||
|
|
||||||
foreach ("err","out","rge") {
|
foreach ("err","out","rge") {
|
||||||
system("mv -f ausgabe1.$_ $FILENAME.$_");
|
system("mv -f ausgabe1.$_ $FILENAME.$_");
|
||||||
}
|
}
|
||||||
$iScan++;
|
$iScan++;
|
||||||
|
print "iScan=".$iScan."\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# For a single run
|
# For a single run
|
||||||
@ -563,25 +576,38 @@ sub StartSequenceOne
|
|||||||
close(INPF);
|
close(INPF);
|
||||||
$Progress=20;
|
$Progress=20;
|
||||||
this->{ui}->progress->setValue($Progress);
|
this->{ui}->progress->setValue($Progress);
|
||||||
|
this->{ui}->progress->update();
|
||||||
|
|
||||||
# Use Linux version
|
# Use Linux version
|
||||||
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
|
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
|
||||||
system($cmd);
|
my $pid = fork();
|
||||||
|
die "Unable to fork: $!" unless defined($pid);
|
||||||
|
if (!$pid) { # child
|
||||||
|
exec($cmd);
|
||||||
|
die "Unable to exec: $!";
|
||||||
|
}
|
||||||
|
while (wait () != -1){}
|
||||||
|
#system($cmd);
|
||||||
foreach ("err","out","rge") {
|
foreach ("err","out","rge") {
|
||||||
system("mv -f ausgabe1.$_ $FILENAME.$_");
|
system("mv -f ausgabe1.$_ $FILENAME.$_");
|
||||||
}
|
}
|
||||||
$Progress=90;
|
$Progress=90;
|
||||||
this->{ui}->progress->setValue($Progress);
|
this->{ui}->progress->setValue($Progress);
|
||||||
|
this->{ui}->progress->update();
|
||||||
|
sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Move the fort.33 file into the subdirectory and change its name
|
# Move the fort.33 file into the subdirectory and change its name
|
||||||
$cmd="rm -f eingabe1.inp; mv -f fort.33 ".$All{"workPath"}."/".$All{"fileNamePrefix"}."_Seq_Results.dat";
|
$cmd="rm -f eingabe1.inp; mv -f fort.33 ".$All{"workPath"}."/".$All{"fileNamePrefix"}."_Seq_Results.dat";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
$Progress=100;
|
$Progress=100;
|
||||||
this->{ui}->progress->setValue($Progress);
|
this->{ui}->progress->setValue($Progress);
|
||||||
|
this->{ui}->progress->update();
|
||||||
undef %All;
|
undef %All;
|
||||||
undef $cmd;
|
undef $cmd;
|
||||||
print "at end\n";
|
print "at end\n";
|
||||||
return(1);
|
sleep(10);
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -790,7 +816,13 @@ sub PlotProfiles
|
|||||||
my $TrimPath = $ENV{'PERLLIB'};
|
my $TrimPath = $ENV{'PERLLIB'};
|
||||||
# Now that we have the file list send it to root macro for plotting.
|
# Now that we have the file list send it to root macro for plotting.
|
||||||
my $cmd='root -n -l "'.$TrimPath.'/../plotRge.C(\"'.$filenames.'\")"&';
|
my $cmd='root -n -l "'.$TrimPath.'/../plotRge.C(\"'.$filenames.'\")"&';
|
||||||
my $pid=system($cmd);
|
my $pid = fork();
|
||||||
|
die "Unable to fork: $!" unless defined($pid);
|
||||||
|
if (!$pid) { # child
|
||||||
|
exec($cmd);
|
||||||
|
die "Unable to exec: $!";
|
||||||
|
}
|
||||||
|
# my $pid=system($cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,7 +841,13 @@ sub PlotFraction
|
|||||||
my $TrimPath = $ENV{'PERLLIB'};
|
my $TrimPath = $ENV{'PERLLIB'};
|
||||||
# Now that we have the file name send it to root macro for plotting.
|
# Now that we have the file name send it to root macro for plotting.
|
||||||
my $cmd='root -n -l "'.$TrimPath.'/../plotFrc.C(\"'.$file.'\")"&';
|
my $cmd='root -n -l "'.$TrimPath.'/../plotFrc.C(\"'.$file.'\")"&';
|
||||||
my $pid=system($cmd);
|
my $pid = fork();
|
||||||
|
die "Unable to fork: $!" unless defined($pid);
|
||||||
|
if (!$pid) { # child
|
||||||
|
exec($cmd);
|
||||||
|
die "Unable to exec: $!";
|
||||||
|
}
|
||||||
|
# my $pid=system($cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,7 +865,13 @@ sub PlotMean
|
|||||||
my $TrimPath = $ENV{'PERLLIB'};
|
my $TrimPath = $ENV{'PERLLIB'};
|
||||||
# Now that we have the file name send it to root macro for plotting.
|
# Now that we have the file name send it to root macro for plotting.
|
||||||
my $cmd='root -n -l "'.$TrimPath.'/../plotMean.C(\"'.$file.'\")"&';
|
my $cmd='root -n -l "'.$TrimPath.'/../plotMean.C(\"'.$file.'\")"&';
|
||||||
my $pid=system($cmd);
|
my $pid = fork();
|
||||||
|
die "Unable to fork: $!" unless defined($pid);
|
||||||
|
if (!$pid) { # child
|
||||||
|
exec($cmd);
|
||||||
|
die "Unable to exec: $!";
|
||||||
|
}
|
||||||
|
# my $pid=system($cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ void plotFrc(char *FileName)
|
|||||||
gr1->SetMarkerStyle(20);
|
gr1->SetMarkerStyle(20);
|
||||||
gr1->SetMarkerColor(TColor::kRed);
|
gr1->SetMarkerColor(TColor::kRed);
|
||||||
gr1->SetLineColor(TColor::kRed);
|
gr1->SetLineColor(TColor::kRed);
|
||||||
|
// Preferably get the chemical formula from header
|
||||||
legend->AddEntry(gr1,"Layer 1");
|
legend->AddEntry(gr1,"Layer 1");
|
||||||
mg->Add(gr1);
|
mg->Add(gr1);
|
||||||
}
|
}
|
||||||
@ -164,6 +165,7 @@ void plotFrc(char *FileName)
|
|||||||
gr2->SetMarkerColor(TColor::kGreen);
|
gr2->SetMarkerColor(TColor::kGreen);
|
||||||
gr2->SetLineColor(TColor::kGreen);
|
gr2->SetLineColor(TColor::kGreen);
|
||||||
// gr2->Draw("PC");
|
// gr2->Draw("PC");
|
||||||
|
// Preferably get the chemical formula from header
|
||||||
legend->AddEntry(gr2,"Layer 2");
|
legend->AddEntry(gr2,"Layer 2");
|
||||||
mg->Add(gr2);
|
mg->Add(gr2);
|
||||||
}
|
}
|
||||||
@ -174,6 +176,7 @@ void plotFrc(char *FileName)
|
|||||||
gr3->SetMarkerColor(TColor::kBlue);
|
gr3->SetMarkerColor(TColor::kBlue);
|
||||||
gr3->SetLineColor(TColor::kBlue);
|
gr3->SetLineColor(TColor::kBlue);
|
||||||
// gr3->Draw("PC");
|
// gr3->Draw("PC");
|
||||||
|
// Preferably get the chemical formula from header
|
||||||
legend->AddEntry(gr3,"Layer 3");
|
legend->AddEntry(gr3,"Layer 3");
|
||||||
mg->Add(gr3);
|
mg->Add(gr3);
|
||||||
}
|
}
|
||||||
@ -184,6 +187,7 @@ void plotFrc(char *FileName)
|
|||||||
gr4->SetMarkerColor(TColor::kMagenta);
|
gr4->SetMarkerColor(TColor::kMagenta);
|
||||||
gr4->SetLineColor(TColor::kMagenta);
|
gr4->SetLineColor(TColor::kMagenta);
|
||||||
// gr4->Draw("PC");
|
// gr4->Draw("PC");
|
||||||
|
// Preferably get the chemical formula from header
|
||||||
legend->AddEntry(gr4,"Layer 4");
|
legend->AddEntry(gr4,"Layer 4");
|
||||||
mg->Add(gr4);
|
mg->Add(gr4);
|
||||||
}
|
}
|
||||||
@ -194,6 +198,7 @@ void plotFrc(char *FileName)
|
|||||||
gr5->SetMarkerColor(TColor::kOrange);
|
gr5->SetMarkerColor(TColor::kOrange);
|
||||||
gr5->SetLineColor(TColor::kOrange);
|
gr5->SetLineColor(TColor::kOrange);
|
||||||
// gr5->Draw("PC");
|
// gr5->Draw("PC");
|
||||||
|
// Preferably get the chemical formula from header
|
||||||
legend->AddEntry(gr5,"Layer 5");
|
legend->AddEntry(gr5,"Layer 5");
|
||||||
mg->Add(gr5);
|
mg->Add(gr5);
|
||||||
}
|
}
|
||||||
@ -204,6 +209,7 @@ void plotFrc(char *FileName)
|
|||||||
gr6->SetMarkerColor(TColor::kViolet);
|
gr6->SetMarkerColor(TColor::kViolet);
|
||||||
gr6->SetLineColor(TColor::kViolet);
|
gr6->SetLineColor(TColor::kViolet);
|
||||||
// gr6->Draw("PC");
|
// gr6->Draw("PC");
|
||||||
|
// Preferably get the chemical formula from header
|
||||||
legend->AddEntry(gr6,"Layer 6");
|
legend->AddEntry(gr6,"Layer 6");
|
||||||
mg->Add(gr6);
|
mg->Add(gr6);
|
||||||
}
|
}
|
||||||
@ -214,6 +220,7 @@ void plotFrc(char *FileName)
|
|||||||
gr7->SetMarkerColor(TColor::kAzure+7);
|
gr7->SetMarkerColor(TColor::kAzure+7);
|
||||||
gr7->SetLineColor(TColor::kAzure+7);
|
gr7->SetLineColor(TColor::kAzure+7);
|
||||||
// gr7->Draw("PC");
|
// gr7->Draw("PC");
|
||||||
|
// Preferably get the chemical formula from header
|
||||||
legend->AddEntry(gr7,"Layer 7");
|
legend->AddEntry(gr7,"Layer 7");
|
||||||
mg->Add(gr7);
|
mg->Add(gr7);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user