862 lines
25 KiB
C
862 lines
25 KiB
C
/****************************************************************************
|
|
** ui.h extension file, included from the uic-generated form implementation.
|
|
**
|
|
** If you want to add, delete, or rename functions or slots, use
|
|
** Qt Designer to update this file, preserving your code.
|
|
**
|
|
** You should not define a constructor or destructor in this file.
|
|
** Instead, write your code in functions called init() and destroy().
|
|
** These will automatically be called by the form's constructor and
|
|
** destructor.
|
|
*****************************************************************************/
|
|
|
|
# This file is part of TrimSPGUI.
|
|
#
|
|
# TrimSPGUI is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# TrimSPGUI is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with TrimSPGUI. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Copyright 2009 by Zaher Salman and the LEM Group.
|
|
# <zaher.salman@psi.ch>
|
|
|
|
void TrimSPGUI::ToggleScanSingle()
|
|
{
|
|
# Toggle between scan/single run mode
|
|
|
|
# First collect some information
|
|
my %All=();
|
|
$All{"ScanSeq"}=ScanSeq->isChecked();
|
|
$All{"ERadio"}=ERadio->isChecked();
|
|
$All{"SigERadio"}=SigERadio->isChecked();
|
|
$All{"NProjRadio"}=NProjRadio->isChecked();
|
|
$All{"dRadio"}=dRadio->isChecked();
|
|
$All{"ScandL"}=ScandL->text();
|
|
$All{"ListRadio"}=ListRadio->isChecked();
|
|
$All{"LoopRadio"}=LoopRadio->isChecked();
|
|
|
|
# Enable everything
|
|
E->setDisabled(0);
|
|
# E->setText("2000");
|
|
SigE->setDisabled(0);
|
|
# SigE->setText("450");
|
|
NProj->setDisabled(0);
|
|
# NProj->setText("10000");
|
|
for (my $i=1;$i<=7;$i++) {
|
|
my $LayerName = "L".$i."d";
|
|
my $LayerAttrib = child($LayerName);
|
|
$LayerAttrib->setDisabled(0);
|
|
}
|
|
|
|
# Enable depth increment for Energy scan only
|
|
if ($All{"ERadio"} & $All{"ListRadio"}) {
|
|
dzListLabel->setHidden(0);
|
|
ScanListdz->setHidden(0);
|
|
dzListLabel->setDisabled(0);
|
|
ScanListdz->setDisabled(0);
|
|
} else {
|
|
dzListLabel->setHidden(1);
|
|
ScanListdz->setHidden(1);
|
|
dzListLabel->setDisabled(1);
|
|
ScanListdz->setDisabled(1);
|
|
}
|
|
|
|
if ($All{"ScanSeq"}==1) {
|
|
# But if we are in scan mode disable the appropriate box
|
|
if ($All{"ERadio"}) {
|
|
E->setDisabled(1);
|
|
# E->setText("");
|
|
} elsif ($All{"SigERadio"}) {
|
|
SigE->setDisabled(1);
|
|
# SigE->setText("");
|
|
} elsif ($All{"NProjRadio"}) {
|
|
NProj->setDisabled(1);
|
|
# NProj->setText("");
|
|
} elsif($All{"dRadio"}) {
|
|
my $LayerName = "L".$All{"ScandL"}."d";
|
|
my $LayerAttrib = child($LayerName);
|
|
$LayerAttrib->setDisabled(1);
|
|
# $LayerAttrib->setText("");
|
|
}
|
|
# and change title of tab to say enabled
|
|
tabs->changeTab( ScansTab, trUtf8("Scans (Enabled)") );
|
|
} else {
|
|
# Otherwise the title of the tab says disabled
|
|
tabs->changeTab( ScansTab, trUtf8("Scans (Disabled)") );
|
|
}
|
|
}
|
|
|
|
|
|
void TrimSPGUI::PrepLayers()
|
|
{
|
|
my %All=();
|
|
$All{"NL"}=NL->text();
|
|
|
|
# Enable layers up to required and disable the rest
|
|
for (my $i=1;$i<=7;$i++) {
|
|
my $LayerName = "BoxL".$i;
|
|
my $LayerAttrib = child($LayerName);
|
|
if ($i<=$All{"NL"}) {
|
|
$LayerAttrib->setDisabled(0);
|
|
} else {
|
|
$LayerAttrib->setDisabled(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void TrimSPGUI::ProjSmartDefaults()
|
|
{
|
|
my %All=();
|
|
# Get typeof projectile
|
|
$All{"ProjType"}=ProjType->currentText();
|
|
|
|
if ($All{"ProjType"} eq "Muon") {
|
|
# For a muon set Sigma E=450 eV and Sigman angle=15 degrees by default
|
|
SigE->setText("450");
|
|
SigAngle->setText("15");
|
|
} elsif ( $All{"ProjType"} eq "Li8") {
|
|
# For Li8 set Sigma E=0 eV and Sigam angle=0 degrees by default
|
|
SigE->setText("0");
|
|
SigAngle->setText("0");
|
|
}
|
|
}
|
|
|
|
|
|
void TrimSPGUI::OpenHelpWindow()
|
|
{
|
|
my $HelpText="
|
|
This is a GUI that uses the Trim.SP simulation binary to calculate the
|
|
implantation profiles if implanted projectiles in a multilayer thin film
|
|
structures.
|
|
|
|
Usage:
|
|
|
|
Initially define your multilayer structure. This can be formed of a maximum
|
|
of 7 layers. Each layer is defined by giving its chemical formula, its
|
|
density in units of g/cm^3, and its thickness in Ångstrom.
|
|
|
|
Next, choose the type of projectile to be implanted in the structure from
|
|
the drop-down menu. Set the 'Number of projectiles' to be implanted, were
|
|
a higher number will give better statistics. Finally define the rest of the pro-
|
|
jectile parameters such as implantation energy, energy spread, etc.
|
|
|
|
In the 'File names prefix' give a string which will be used to construct the
|
|
input/output file names of the simulation. These files will be collected and
|
|
saved in the subdirectory provided in 'Save in subdirectory' box.
|
|
|
|
The 'Additional Parameters' tab allows you to change additional parameters
|
|
In the simulation. Change these only if you know what you are doing, and have
|
|
read the original documentation of the Trim.SP simulation.
|
|
|
|
The 'Scans' tabs provides the ability to change the value of a certain
|
|
parameter in the simulation, such as implantation energy, spread in energy,
|
|
number of implanted projectiles, and the thickness of one layer. The values of
|
|
this parameter can be changed by a regualr step size ('Loop' checkbox and
|
|
parameters), or following a set of values ('List of values' checkbox and the
|
|
comma separated values).
|
|
|
|
For more details click on the question mark on the top right corner, and then
|
|
click on the item you want to lear about.
|
|
|
|
Copyright 2009 (C) by Zaher Salman and the LEM Group
|
|
Version 14 Sep. 2009
|
|
";
|
|
my $HelpWindow = Qt::MessageBox::information( this, "TrimSP GUI Help Window",$HelpText);
|
|
}
|
|
|
|
void TrimSPGUI::CollectValues()
|
|
{
|
|
# This subroutine returns a hash with all the values collected from the GUI.
|
|
my %All=();
|
|
$All{"NL"}=NL->text();
|
|
# Collect layers parameters
|
|
for (my $i=1;$i<=$All{"NL"};$i++) {
|
|
my $LComp = "L".$i."Comp";
|
|
my $Lrho="L".$i."rho";
|
|
my $Ld="L".$i."d";
|
|
my $LCompAttrib = child($LComp);
|
|
my $LrhoAttrib=child($Lrho);
|
|
my $LdAttrib=child($Ld);
|
|
$All{"$LComp"}=$LCompAttrib->text();
|
|
$All{"$Lrho"}=$LrhoAttrib->text();
|
|
$All{"$Ld"}=$LdAttrib->text();
|
|
}
|
|
|
|
# Collect projectile parameters
|
|
$All{"ProjType"}=ProjType->currentText();
|
|
$All{"NProj"}=NProj->text();
|
|
if ($All{"NProj"}==0) {
|
|
$All{"NProj"}=10000;
|
|
NProj->setText("10000");
|
|
}
|
|
$All{"z0"}=z0->text();
|
|
$All{"dz"}=dz->text();
|
|
$All{"E"}=E->text();
|
|
$All{"SigE"}=SigE->text();
|
|
$All{"Angle"}=Angle->text();
|
|
$All{"SigAngle"}=SigAngle->text();
|
|
$All{"Seed"}=Seed->text();
|
|
# Format projectile parameters
|
|
$All{"NProj"}=sprintf("%8d",$All{"NProj"});
|
|
$All{"z0"}=sprintf("%6.2f",$All{"z0"});
|
|
$All{"dz"}=sprintf("%6.2f",$All{"dz"});
|
|
$All{"E"}=sprintf("%11.2f",$All{"E"});
|
|
$All{"SigE"}=sprintf("%8.2f",$All{"SigE"});
|
|
$All{"Angle"}=sprintf("%8.2f",$All{"Angle"});
|
|
$All{"SigAngle"}=sprintf("%8.2f",$All{"SigAngle"});
|
|
$All{"Seed"}=sprintf("%6.0f.",$All{"Seed"});
|
|
|
|
|
|
# Collect the additional parameters
|
|
$All{"EF"}=EF->text();
|
|
$All{"ESB"}=ESB->text();
|
|
$All{"SHEATH"}=SHEATH->text();
|
|
$All{"ERC"}=ERC->text();
|
|
$All{"RD"}=RD->text();
|
|
$All{"CA"}=CA->text();
|
|
$All{"KK0"}=KK0->text();
|
|
$All{"KK0R"}=KK0R->text();
|
|
$All{"KDEE1"}=KDEE1->text();
|
|
$All{"KDEE2"}=KDEE2->text();
|
|
$All{"IPOT"}=IPOT->text();
|
|
$All{"IPOTR"}=IPOTR->text();
|
|
$All{"IRL"}=IRL->text();
|
|
# format additional parameters
|
|
$All{"EF"}=sprintf("%8.2f",$All{"EF"});
|
|
$All{"ESB"}=sprintf("%8.2f",$All{"ESB"});
|
|
$All{"SHEATH"}=sprintf("%8.2f",$All{"SHEATH"});
|
|
$All{"ERC"}=sprintf("%8.2f",$All{"ERC"});
|
|
$All{"RD"}=sprintf("%5.0f.",$All{"RD"});
|
|
$All{"CA"}=sprintf("%6.2f",$All{"CA"});
|
|
$All{"KK0"}=sprintf("%3d",$All{"KK0"});
|
|
$All{"KK0R"}=sprintf("%3d",$All{"KK0R"});
|
|
$All{"KDEE1"}=sprintf("%3d",$All{"KDEE1"});
|
|
$All{"KDEE2"}=sprintf("%3d",$All{"KDEE2"});
|
|
$All{"IPOT"}=sprintf("%3d",$All{"IPOT"});
|
|
$All{"IPOTR"}=sprintf("%3d",$All{"IPOTR"});
|
|
$All{"IRL"}=sprintf("%2d",$All{"IRL"});
|
|
|
|
# Filenames etc.
|
|
$All{"FNPre"}=FNPre->text();
|
|
$All{"Path"}=Path->text();
|
|
|
|
# Scan parameters only if selected
|
|
$All{"ScanSeq"}=ScanSeq->isChecked();
|
|
# if ($All{"ScanSeq"}) {
|
|
$All{"ERadio"}=ERadio->isChecked();
|
|
$All{"SigERadio"}=SigERadio->isChecked();
|
|
$All{"NProjRadio"}=NProjRadio->isChecked();
|
|
$All{"dRadio"}=dRadio->isChecked();
|
|
$All{"ScandL"}=ScandL->text();
|
|
$All{"ListRadio"}=ListRadio->isChecked();
|
|
$All{"LoopRadio"}=LoopRadio->isChecked();
|
|
$All{"ScanList"}=ScanList->text();
|
|
$All{"ScanListdz"}=ScanListdz->text();
|
|
$All{"SFrom"}=SFrom->text();
|
|
$All{"STo"}=STo->text();
|
|
$All{"SStep"}=SStep->text();
|
|
# }
|
|
|
|
# Return values to caller
|
|
return %All;
|
|
}
|
|
|
|
|
|
void TrimSPGUI::CreateInpFile()
|
|
{
|
|
# use lib '$ENV{HOME}/Projects/TrimSPGUI/Chem';
|
|
# push @INC, "$ENV{HOME}/Projects/TrimSPGUI";
|
|
use Chem;
|
|
# The proper way I think is not to have scan sequences implimented here
|
|
# but rather call this multiple times to generate the scan
|
|
# To resolve this, the function CreateInpFile will expect a unique thickness for each layer,
|
|
# one energy value, one energy sigma and one projectile number.
|
|
# These will be stored in keys L1/2/3/4/5/6/7d, E, SigE and NProj, respectively.
|
|
|
|
# Chemical formulas will be parsed on the fly for each layer. However, we will check if
|
|
# all the layers have inputs for composition, thickness and density. If not fail and crash :)
|
|
|
|
# Values of Z,A as well as other needed parameters are obtained from Chem.pm.
|
|
|
|
# This is the form of the input file:
|
|
my $TemplateFile=
|
|
" ProjZ ProjAM E SigE Angle SigAngle EF ESB SHEATH ERC
|
|
NProj Seed Seed Seed z0 RD dz CA KK0 KK0R KDEE1 KDEE2 IPOT IPOTR IRL
|
|
L1d L2d L3d L4d L5d L6d L7d L1rho L2rho L3rho L4rho L5rho L6rho L7rho L1CK L2CK L3CK L4CK L5CK L6CK L7CK
|
|
L1ELZ1 L1ELZ2 L1ELZ3 L1ELZ4 L1ELZ5
|
|
L1ELW1 L1ELW2 L1ELW3 L1ELW4 L1ELW5
|
|
L1ELC1 L1ELC2 L1ELC3 L1ELC4 L1ELC5
|
|
L1ELE1 L1ELE2 L1ELE3 L1ELE4 L1ELE5
|
|
L10301 L10302 L10303 L10304 L10305
|
|
0.0000 0.0000 0.0000 0.0000 0.0000
|
|
L1ELST11 L1ELST21 L1ELST31 L1ELST41 L1ELST51
|
|
L1ELST12 L1ELST22 L1ELST32 L1ELST42 L1ELST52
|
|
L1ELST13 L1ELST23 L1ELST33 L1ELST43 L1ELST53
|
|
L1ELST14 L1ELST24 L1ELST34 L1ELST44 L1ELST54
|
|
L1ELST15 L1ELST25 L1ELST35 L1ELST45 L1ELST55
|
|
L2ELZ1 L2ELZ2 L2ELZ3 L2ELZ4 L2ELZ5
|
|
L2ELW1 L2ELW2 L2ELW3 L2ELW4 L2ELW5
|
|
L2ELC1 L2ELC2 L2ELC3 L2ELC4 L2ELC5
|
|
L2ELE1 L2ELE2 L2ELE3 L2ELE4 L2ELE5
|
|
L20301 L20302 L20303 L20304 L20305
|
|
0.0000 0.0000 0.0000 0.0000 0.0000
|
|
L2ELST11 L2ELST21 L2ELST31 L2ELST41 L2ELST51
|
|
L2ELST12 L2ELST22 L2ELST32 L2ELST42 L2ELST52
|
|
L2ELST13 L2ELST23 L2ELST33 L2ELST43 L2ELST53
|
|
L2ELST14 L2ELST24 L2ELST34 L2ELST44 L2ELST54
|
|
L2ELST15 L2ELST25 L2ELST35 L2ELST45 L2ELST55
|
|
L3ELZ1 L3ELZ2 L3ELZ3 L3ELZ4 L3ELZ5
|
|
L3ELW1 L3ELW2 L3ELW3 L3ELW4 L3ELW5
|
|
L3ELC1 L3ELC2 L3ELC3 L3ELC4 L3ELC5
|
|
L3ELE1 L3ELE2 L3ELE3 L3ELE4 L3ELE5
|
|
L30301 L30302 L30303 L30304 L30305
|
|
0.0000 0.0000 0.0000 0.0000 0.0000
|
|
L3ELST11 L3ELST21 L3ELST31 L3ELST41 L3ELST51
|
|
L3ELST12 L3ELST22 L3ELST32 L3ELST42 L3ELST52
|
|
L3ELST13 L3ELST23 L3ELST33 L3ELST43 L3ELST53
|
|
L3ELST14 L3ELST24 L3ELST34 L3ELST44 L3ELST54
|
|
L3ELST15 L3ELST25 L3ELST35 L3ELST45 L3ELST55
|
|
L4ELZ1 L4ELZ2 L4ELZ3 L4ELZ4 L4ELZ5
|
|
L4ELW1 L4ELW2 L4ELW3 L4ELW4 L4ELW5
|
|
L4ELC1 L4ELC2 L4ELC3 L4ELC4 L4ELC5
|
|
L4ELE1 L4ELE2 L4ELE3 L4ELE4 L4ELE5
|
|
L40301 L40302 L40303 L40304 L40305
|
|
0.0000 0.0000 0.0000 0.0000 0.0000
|
|
L4ELST11 L4ELST21 L4ELST31 L4ELST41 L4ELST51
|
|
L4ELST12 L4ELST22 L4ELST32 L4ELST42 L4ELST52
|
|
L4ELST13 L4ELST23 L4ELST33 L4ELST43 L4ELST53
|
|
L4ELST14 L4ELST24 L4ELST34 L4ELST44 L4ELST54
|
|
L4ELST15 L4ELST25 L4ELST35 L4ELST45 L4ELST55
|
|
L5ELZ1 L5ELZ2 L5ELZ3 L5ELZ4 L5ELZ5
|
|
L5ELW1 L5ELW2 L5ELW3 L5ELW4 L5ELW5
|
|
L5ELC1 L5ELC2 L5ELC3 L5ELC4 L5ELC5
|
|
L5ELE1 L5ELE2 L5ELE3 L5ELE4 L5ELE5
|
|
L50301 L50302 L50303 L50304 L50305
|
|
0.0000 0.0000 0.0000 0.0000 0.0000
|
|
L5ELST11 L5ELST21 L5ELST31 L5ELST41 L5ELST51
|
|
L5ELST12 L5ELST22 L5ELST32 L5ELST42 L5ELST52
|
|
L5ELST13 L5ELST23 L5ELST33 L5ELST43 L5ELST53
|
|
L5ELST14 L5ELST24 L5ELST34 L5ELST44 L5ELST54
|
|
L5ELST15 L5ELST25 L5ELST35 L5ELST45 L5ELST55
|
|
L6ELZ1 L6ELZ2 L6ELZ3 L6ELZ4 L6ELZ5
|
|
L6ELW1 L6ELW2 L6ELW3 L6ELW4 L6ELW5
|
|
L6ELC1 L6ELC2 L6ELC3 L6ELC4 L6ELC5
|
|
L6ELE1 L6ELE2 L6ELE3 L6ELE4 L6ELE5
|
|
L60301 L60302 L60303 L60304 L60305
|
|
0.0000 0.0000 0.0000 0.0000 0.0000
|
|
L6ELST11 L6ELST21 L6ELST31 L6ELST41 L6ELST51
|
|
L6ELST12 L6ELST22 L6ELST32 L6ELST42 L6ELST52
|
|
L6ELST13 L6ELST23 L6ELST33 L6ELST43 L6ELST53
|
|
L6ELST14 L6ELST24 L6ELST34 L6ELST44 L6ELST54
|
|
L6ELST15 L6ELST25 L6ELST35 L6ELST45 L6ELST55
|
|
L7ELZ1 L7ELZ2 L7ELZ3 L7ELZ4 L7ELZ5
|
|
L7ELW1 L7ELW2 L7ELW3 L7ELW4 L7ELW5
|
|
L7ELC1 L7ELC2 L7ELC3 L7ELC4 L7ELC5
|
|
L7ELE1 L7ELE2 L7ELE3 L7ELE4 L7ELE5
|
|
L70301 L70302 L70303 L70304 L70305
|
|
0.0000 0.0000 0.0000 0.0000 0.0000
|
|
L7ELST11 L7ELST21 L7ELST31 L7ELST41 L7ELST51
|
|
L7ELST12 L7ELST22 L7ELST32 L7ELST42 L7ELST52
|
|
L7ELST13 L7ELST23 L7ELST33 L7ELST43 L7ELST53
|
|
L7ELST14 L7ELST24 L7ELST34 L7ELST44 L7ELST54
|
|
L7ELST15 L7ELST25 L7ELST35 L7ELST45 L7ELST55
|
|
";
|
|
|
|
# Get values from form
|
|
my %All = CollectValues();
|
|
my $ProjType=$All{"ProjType"};
|
|
$All{"ProjZ"}=sprintf("%6.2f",Chem::Zof($ProjType));
|
|
$All{"ProjAM"}=sprintf("%6.2f",Chem::Massof($ProjType));
|
|
|
|
my $Check=0;
|
|
# Loop over layers an create appropriate values
|
|
for (my $i=1;$i<=7;$i++){
|
|
$Check=0;
|
|
# Composition of layers
|
|
my $LComp="L".$i."Comp";
|
|
my $LCompAttrib = child($LComp);
|
|
my $Comp = $LCompAttrib->text();
|
|
my %LElComp=Chem::parse_formula($Comp);
|
|
if ($Comp eq "") {$Check++;}
|
|
|
|
# Densities of layers
|
|
my $Lrho="L".$i."rho";
|
|
my $LrhoAttrib = child($Lrho);
|
|
my $rho = $LrhoAttrib->text();
|
|
$All{$Lrho}=sprintf("%6.2f",$rho);
|
|
if ($rho eq "") {$Check++;}
|
|
|
|
# Thickness of layers
|
|
my $Ld ="L".$i."d";
|
|
my $LdAttrib = child($Ld);
|
|
my $d = $LdAttrib->text();
|
|
$All{$Ld}=sprintf("%8.2f",$d);
|
|
if ($d eq "") {$Check++;}
|
|
|
|
# Sanity check, is the layer supposed to have value? are they all there?
|
|
if ($Check!=0 && $i<=$All{"NL"}) {
|
|
my $ErrMsg="Error: Layer $i is empty. Expecting it to be defined!\n";
|
|
print STDERR $ErrMsg;
|
|
my $HelpWindow = Qt::MessageBox::information( this, "Error!",$ErrMsg);
|
|
# my $ErrorDialog = Qt::ErrorMessage(TrimSPGUI);
|
|
# $ErrorDialog->message($ErrMsg);
|
|
return "ERROR";
|
|
}
|
|
|
|
my $tmp = "L".$i."CK";
|
|
$All{$tmp}=sprintf("%6.2f",1.0);
|
|
|
|
my $Sum = 0;
|
|
foreach (keys %LElComp) {
|
|
$Sum=$Sum+$LElComp{$_};
|
|
}
|
|
if ($Sum==0) {$Sum=1;}
|
|
|
|
# print STDOUT "Layer: ".$i."\n";
|
|
# print STDOUT "Composition: ".$Comp."\n";
|
|
|
|
my @Els = keys %LElComp;
|
|
|
|
for (my $NEl=1;$NEl<=5;$NEl++) {
|
|
my $El = $Els[$NEl-1];
|
|
my $LEkey = "L".$i."EL";
|
|
my $ElZ = Chem::Zof($El);
|
|
my $ElW = Chem::Massof($El);
|
|
my $ElC = $LElComp{$El}/$Sum;
|
|
my $ElE = Chem::Elastof($El);
|
|
my $El030 = 30;
|
|
if ($El eq "") { $El030 = 0.0;}
|
|
# print STDOUT "$El, ElC=$ElC ElZ=$ElZ ElW=$ElW ElE=$ElE\n";
|
|
$All{$LEkey."Z".$NEl}=sprintf("%8.4f",$ElZ);
|
|
$All{$LEkey."W".$NEl}=sprintf("%8.4f",$ElW);
|
|
$All{$LEkey."C".$NEl}=sprintf("%8.4f",$ElC);
|
|
$All{$LEkey."E".$NEl}=sprintf("%8.4f",$ElE);
|
|
$All{"L".$i."030".$NEl}=sprintf("%8.4f",$El030);
|
|
|
|
my $ElST = Chem::Stopicru($El);
|
|
my @ElSTs = split (/,/,$ElST);
|
|
my $j=1;
|
|
foreach (@ElSTs) {
|
|
$LEkey = "L".$i."ELST".$NEl.$j;
|
|
$j++;
|
|
$All{$LEkey}=sprintf("%11.6f",$_);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach my $key (keys %All) {
|
|
# print $key,$All{$key},"\n";
|
|
if ($All{$key} ne ""){
|
|
$TemplateFile =~ s/$key/$All{$key}/;
|
|
# Seed repeats three times
|
|
if ($key eq "Seed") { $TemplateFile =~ s/$key/$All{$key}/g;}
|
|
}
|
|
}
|
|
return $TemplateFile;
|
|
}
|
|
|
|
|
|
void TrimSPGUI::StartSequenceOne()
|
|
{
|
|
my %All = CollectValues();
|
|
my @SValues=();
|
|
my @SdzValues=();
|
|
my $cmd="";
|
|
|
|
# Cleanup from old files
|
|
if (-e "ausgabe1.inp") {
|
|
system("rm -f ausgabe*");
|
|
}
|
|
|
|
my $Progress=0;
|
|
if ($All{"ScanSeq"}) {
|
|
# For a scan
|
|
$All{"ERadio"}=ERadio->isChecked();
|
|
$All{"SigERadio"}=SigERadio->isChecked();
|
|
$All{"NProjRadio"}=NProjRadio->isChecked();
|
|
$All{"dRadio"}=dRadio->isChecked();
|
|
$All{"ScandL"}=ScandL->text();
|
|
$All{"ListRadio"}=ListRadio->isChecked();
|
|
$All{"LoopRadio"}=LoopRadio->isChecked();
|
|
$All{"ScanList"}=ScanList->text();
|
|
$All{"ScanListdz"}=ScanListdz->text();
|
|
$All{"SFrom"}=SFrom->text();
|
|
$All{"STo"}=STo->text();
|
|
$All{"SStep"}=SStep->text();
|
|
|
|
if ($All{"ListRadio"}) {
|
|
@SValues=split(/,/,$All{"ScanList"});
|
|
@SdzValues=split(/,/,$All{"ScanListdz"});
|
|
if ($#SValues == $#SdzValues) {$All{"SdzFlag"}=1;}
|
|
} elsif ($All{"LoopRadio"}) {
|
|
for (my $Val=$All{"SFrom"};$Val<=$All{"STo"};$Val=$Val+$All{"SStep"}) {
|
|
@SValues=(@SValues,$Val);
|
|
}
|
|
}
|
|
|
|
my $ScanName = "";
|
|
if ($All{"ERadio"}) {
|
|
$ScanName = "E";
|
|
} elsif ($All{"SigERadio"}) {
|
|
$ScanName = "SigE";
|
|
} elsif ($All{"NProjRadio"}) {
|
|
$ScanName = "NProj";
|
|
} elsif ($All{"dRadio"}) {
|
|
$ScanName = "Ld".$All{"ScandL"};
|
|
}
|
|
|
|
my $ScanAttrib = child($ScanName);
|
|
my $iScan=0;
|
|
foreach (@SValues) {
|
|
$ScanAttrib->setText($_);
|
|
if ( $All{"SdzFlag"} == 1) {
|
|
dz->setText($SdzValues[$iScan]);
|
|
}
|
|
my $eingabe1=CreateInpFile();
|
|
if ($eingabe1 eq "ERROR") {return 0;}
|
|
my $FILENAME=$All{"FNPre"}."_".$ScanName.$_;
|
|
open (INPF,q{>}, "$FILENAME.inp" );
|
|
print INPF $eingabe1;
|
|
close(INPF);
|
|
# Use windoz version
|
|
# system("cp $FILENAME.inp eingabe1.inp; wine TrimSP7L.exe");
|
|
# Use Linux version
|
|
$Progress=$Progress+90/$#SValues;
|
|
Progress->setProgress($Progress);
|
|
Progress->update();
|
|
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
|
|
system($cmd);
|
|
|
|
foreach ("err","out","rge") {
|
|
system("mv -f ausgabe1.$_ $FILENAME.$_");
|
|
}
|
|
# Not needed if work path is changed
|
|
# $cmd="mv -f $FILENAME.* ".$All{"Path"};
|
|
# system($cmd);
|
|
$iScan++;
|
|
}
|
|
} else {
|
|
# For a single run
|
|
my $eingabe1=CreateInpFile();
|
|
if ($eingabe1 eq "ERROR") {return 0;}
|
|
my $FILENAME=$All{"FNPre"};
|
|
open (INPF,q{>}, "$FILENAME.inp" );
|
|
print INPF $eingabe1;
|
|
close(INPF);
|
|
$Progress=20;
|
|
Progress->setProgress($Progress);
|
|
|
|
# Use windoz version
|
|
# system("cp $FILENAME.inp eingabe1.inp; wine TrimSP7L.exe");
|
|
# Use Linux version
|
|
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
|
|
system($cmd);
|
|
foreach ("err","out","rge") {
|
|
system("mv -f ausgabe1.$_ $FILENAME.$_");
|
|
}
|
|
$Progress=90;
|
|
Progress->setProgress($Progress);
|
|
# If we change work directory this is not needed
|
|
# $cmd="mv -f $FILENAME.* ".$All{"Path"};
|
|
# system($cmd);
|
|
}
|
|
# Move the fort.33 file into the subdirectory and change its name
|
|
$cmd="rm -f eingabe1.inp; mv -f fort.33 ".$All{"Path"}."/".$All{"FNPre"}."_Seq_Results.dat";
|
|
system($cmd);
|
|
$Progress=100;
|
|
Progress->setProgress($Progress);
|
|
return 1;
|
|
}
|
|
|
|
|
|
void TrimSPGUI::DirectoryBrowse()
|
|
{
|
|
my $FileBrowser = Qt::FileDialog::getExistingDirectory("./",this,"get existing directory","Choose a directory",1);
|
|
if ($FileBrowser eq "") {$FileBrowser="./";}
|
|
Path->setText($FileBrowser);
|
|
|
|
# Create a subdirectory where all input/output files are saved
|
|
my $cmd="";
|
|
if (-d $FileBrowser) {
|
|
# Directory exists, do nothing
|
|
} else {
|
|
$cmd="mkdir $FileBrowser";
|
|
system($cmd);
|
|
}
|
|
# Change work directory accordingly
|
|
chdir ("$FileBrowser");
|
|
}
|
|
|
|
|
|
void TrimSPGUI::ConfirmQuit()
|
|
{
|
|
my $Ans = Qt::MessageBox::question( this, "Quit?","Are you sure you want to quit?","&Yes","&No","",0,1);
|
|
if ($Ans==0) {
|
|
# Then quit
|
|
Qt::Application::exit( 0 );
|
|
}
|
|
# Otherwize go back
|
|
# print STDOUT $ENV{'TRIMBIN'}."\n";
|
|
}
|
|
|
|
|
|
|
|
void TrimSPGUI::PlotProfiles()
|
|
{
|
|
my $files_ref=Qt::FileDialog::getOpenFileNames(
|
|
"RGE Files (*.rge)",
|
|
"./",
|
|
this,
|
|
"Select RGE files dialog",
|
|
"Choose RGE file to plot");
|
|
my @files = @$files_ref;
|
|
my $filenames=join(",",@files);
|
|
|
|
if ($filenames ne "" ) {
|
|
# my $Warning = Qt::MessageBox::information( this, "Big Fat Warning",
|
|
# "Warning:\nClose the plot using the menu FILE -> Quit ROOT\nDO NOT CLOSE USING X.");
|
|
my $TrimPath = $ENV{'PERLLIB'};
|
|
# Now that we have the file list send it to root macro for plotting.
|
|
my $cmd='root -n -l "'.$TrimPath.'/plotRge.C(\"'.$filenames.'\")"&';
|
|
|
|
# my $pid = open(FTO,"$cmd");
|
|
# my $pid = open(FTO,"$cmd 2>&1 |");
|
|
# print "PID=$pid\n";
|
|
# while (<FTO>) {
|
|
# print "$_";
|
|
# }
|
|
# close(FTO);
|
|
my $pid=system($cmd);
|
|
}
|
|
}
|
|
|
|
|
|
void TrimSPGUI::PlotFraction()
|
|
{
|
|
|
|
}
|
|
|
|
void TrimSPGUI::OpenAboutWindow()
|
|
{
|
|
my $HelpText="TrimSPGUI is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
TrimSPGUI is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with TrimSPGUI. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
Copyright 2009 by Zaher Salman and the LEM Group.
|
|
<zaher.salman\@psi.ch>
|
|
";
|
|
my $HelpWindow = Qt::MessageBox::about( this, "About TrimSP GUI",$HelpText);
|
|
}
|
|
|
|
|
|
void TrimSPGUI::OpenFile()
|
|
{
|
|
# Types of different input
|
|
my %Types = ();
|
|
# 0 - text (this is default), 1 - spin box, 2 - radio button, 3 - combo box
|
|
$Types{"NL"}=1 ;
|
|
$Types{"ProjType"}= 3;
|
|
$Types{"ScanSeq"}= 2;
|
|
$Types{"ERadio"}= 2;
|
|
$Types{"SigERadio"}= 2;
|
|
$Types{"NProjRadio"}= 2;
|
|
$Types{"dRadio"}= 2;
|
|
$Types{"ScandL"}= 1;
|
|
$Types{"ListRadio"}= 2;
|
|
$Types{"ScanListdz"}= 0;
|
|
$Types{"LoopRadio"}= 2;
|
|
|
|
|
|
my $file=Qt::FileDialog::getOpenFileName(
|
|
".",
|
|
"Initialization file (.* *.*)",
|
|
this,
|
|
"open file dialog",
|
|
"Choose an initialization file");
|
|
|
|
# If the user gave a valid filename try to read it
|
|
if ($file ne "") {
|
|
open (INF,q{<},"$file" );
|
|
my @lines = <INF>;
|
|
close(INF);
|
|
my $Attrib="";
|
|
foreach my $line (@lines) {
|
|
my @InitPar = split (/=/,$line);
|
|
# Check it is not empty or title line
|
|
if ($InitPar[0] ne "" && $InitPar[1] ne "") {
|
|
$Attrib = child($InitPar[0]);
|
|
if ($Types{$InitPar[0]} == 1) {
|
|
$Attrib->setValue($InitPar[1]);
|
|
} elsif ($Types{$InitPar[0]} == 2 ) {
|
|
if($InitPar[1] == 1) {
|
|
$Attrib->setChecked(1);
|
|
} else {
|
|
$Attrib->setChecked(0);
|
|
}
|
|
} elsif ($Types{$InitPar[0]} == 3) {
|
|
$Attrib-> setCurrentText($InitPar[1]);
|
|
} else {
|
|
$Attrib->setText($InitPar[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void TrimSPGUI::SaveFile()
|
|
{
|
|
my %All = CollectValues();
|
|
my $InitFile="
|
|
[Layers]
|
|
NL=$All{'NL'}
|
|
L1Comp=$All{'L1Comp'}
|
|
L1rho=$All{'L1rho'}
|
|
L1d=$All{'L1d'}
|
|
L2Comp=$All{'L2Comp'}
|
|
L2rho=$All{'L2rho'}
|
|
L2d=$All{'L2d'}
|
|
L3Comp=$All{'L3Comp'}
|
|
L3rho=$All{'L3rho'}
|
|
L3d=$All{'L3d'}
|
|
L4Comp=$All{'L4Comp'}
|
|
L4rho=$All{'L4rho'}
|
|
L4d=$All{'L4d'}
|
|
L5Comp=$All{'L5Comp'}
|
|
L5rho=$All{'L5rho'}
|
|
L5d=$All{'L5d'}
|
|
L6Comp=$All{'L6Comp'}
|
|
L6rho=$All{'L6rho'}
|
|
L6d=$All{'L6d'}
|
|
L7Comp=$All{'L7Comp'}
|
|
L7rho=$All{'L7rho'}
|
|
L7d=$All{'L7d'}
|
|
|
|
[ProjectileParameters]
|
|
ProjType=$All{'ProjType'}
|
|
NProj=$All{'NProj'}
|
|
z0=$All{'z0'}
|
|
dz=$All{'dz'}
|
|
E=$All{'E'}
|
|
SigE=$All{'SigE'}
|
|
Angle=$All{'Angle'}
|
|
SigAngle=$All{'SigAngle'}
|
|
Seed=$All{'Seed'}
|
|
|
|
[Files]
|
|
FNPre=$All{'FNPre'}
|
|
Path=$All{'Path'}
|
|
|
|
[ScanSequence]
|
|
ScanSeq=$All{'ScanSeq'}
|
|
ERadio=$All{'ERadio'}
|
|
SigERadio=$All{'SigERadio'}
|
|
NProjRadio=$All{'NProjRadio'}
|
|
dRadio=$All{'dRadio'}
|
|
ListRadio=$All{'ListRadio'}
|
|
ScanList=$All{'ScanList'}
|
|
ScanListdz=$All{'ScanListdz'}
|
|
LoopRadio=$All{'LoopRadio'}
|
|
SFrom=$All{'SFrom'}
|
|
STo=$All{'STo'}
|
|
SStep=$All{'SStep'}
|
|
";
|
|
|
|
# Save to default file name "TriumSP.cfg"
|
|
my $file = "TrimSP.cfg";
|
|
open (OUTF,q{>},"$file" );
|
|
print OUTF (" $InitFile");
|
|
close(OUTF);
|
|
}
|
|
|
|
|
|
void TrimSPGUI::SaveFileAs()
|
|
{
|
|
my %All = CollectValues();
|
|
my $InitFile="
|
|
[Layers]
|
|
NL=$All{'NL'}
|
|
L1Comp=$All{'L1Comp'}
|
|
L1rho=$All{'L1rho'}
|
|
L1d=$All{'L1d'}
|
|
L2Comp=$All{'L2Comp'}
|
|
L2rho=$All{'L2rho'}
|
|
L2d=$All{'L2d'}
|
|
L3Comp=$All{'L3Comp'}
|
|
L3rho=$All{'L3rho'}
|
|
L3d=$All{'L3d'}
|
|
L4Comp=$All{'L4Comp'}
|
|
L4rho=$All{'L4rho'}
|
|
L4d=$All{'L4d'}
|
|
L5Comp=$All{'L5Comp'}
|
|
L5rho=$All{'L5rho'}
|
|
L5d=$All{'L5d'}
|
|
L6Comp=$All{'L6Comp'}
|
|
L6rho=$All{'L6rho'}
|
|
L6d=$All{'L6d'}
|
|
L7Comp=$All{'L7Comp'}
|
|
L7rho=$All{'L7rho'}
|
|
L7d=$All{'L7d'}
|
|
|
|
[ProjectileParameters]
|
|
ProjType=$All{'ProjType'}
|
|
NProj=$All{'NProj'}
|
|
z0=$All{'z0'}
|
|
dz=$All{'dz'}
|
|
E=$All{'E'}
|
|
SigE=$All{'SigE'}
|
|
Angle=$All{'Angle'}
|
|
SigAngle=$All{'SigAngle'}
|
|
Seed=$All{'Seed'}
|
|
|
|
[Files]
|
|
FNPre=$All{'FNPre'}
|
|
Path=$All{'Path'}
|
|
|
|
[ScanSequence]
|
|
ScanSeq=$All{'ScanSeq'}
|
|
ERadio=$All{'ERadio'}
|
|
SigERadio=$All{'SigERadio'}
|
|
NProjRadio=$All{'NProjRadio'}
|
|
dRadio=$All{'dRadio'}
|
|
ListRadio=$All{'ListRadio'}
|
|
ScanList=$All{'ScanList'}
|
|
ScanListdz=$All{'ScanListdz'}
|
|
LoopRadio=$All{'LoopRadio'}
|
|
SFrom=$All{'SFrom'}
|
|
STo=$All{'STo'}
|
|
SStep=$All{'SStep'}
|
|
";
|
|
my $file=Qt::FileDialog::getSaveFileName(
|
|
"TrimSP.cfg",
|
|
"TrimSP GUI Initialization file (*.cfg)",
|
|
this,
|
|
"save file dialog",
|
|
"Choose a filename to save under");
|
|
|
|
# If the user gave a filename the copy to it
|
|
if ($file ne "") {
|
|
open (OUTF,q{>},"$file" );
|
|
print OUTF (" $InitFile");
|
|
close(OUTF);
|
|
}
|
|
}
|