First running version
This commit is contained in:
parent
c994c2489f
commit
f694c3feed
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@ void QmuSRSim::fileSave()
|
||||
$InitFile=$InitFile.$key."=".$All{$key}."\n";
|
||||
}
|
||||
|
||||
# Save to default file name "TriumSP.cfg"
|
||||
# Save to default file name "musrSim.cfg"
|
||||
my $file = "musrSim.cfg";
|
||||
open (OUTF,q{>},"$file" );
|
||||
print OUTF (" $InitFile");
|
||||
@ -179,8 +179,9 @@ void QmuSRSim::helpAbout()
|
||||
void QmuSRSim::CreateAllInput()
|
||||
{
|
||||
my %All=();
|
||||
my @AllParams= ("L1","L3","TL","BFIELD","RA_T","RA_B","RA_R","RA_L","SR_B","SR_E","ENERGY",
|
||||
"L1_2","L2_2","L3_2","BFIELD_2","RA_T_2","RA_B_2","RA_R_2","RA_L_2","ENERGY_2");
|
||||
my @AllParams= ("L1","L3","TL","BFIELD","RA_T","RA_B","RA_R","RA_L","SR_B","SR_E","ENERGY","NMuon",
|
||||
"L1_2","L2_2","L3_2","BFIELD_2","RA_T_2","RA_B_2","RA_R_2","RA_L_2","ENERGY_2",
|
||||
"MAC","musrSim","Geant4","SaveData","ROOTSYS");
|
||||
foreach my $Param (@AllParams) {
|
||||
my $Child = child($Param);
|
||||
my $Value = $Child->text;
|
||||
@ -196,28 +197,35 @@ void QmuSRSim::CreateAllInput()
|
||||
void QmuSRSim::StartCalc()
|
||||
{
|
||||
my %All=CreateAllInput();
|
||||
my $Page = Tabs->currentPageIndex;
|
||||
my %ToReplace=();
|
||||
my @SpaceHolder=();
|
||||
my $FName="SRBeamLine.mac";
|
||||
|
||||
# Check if the simulation can run
|
||||
my $answ = CheckSim();
|
||||
print "Answer=$answ\n";
|
||||
|
||||
if ($answ == 1) {
|
||||
my $Page = Tabs->currentPageIndex;
|
||||
my %ToReplace=();
|
||||
my @SpaceHolder=();
|
||||
my $FName="SRBeamLine.mac";
|
||||
# 0 for spin rotator and 1 for current.
|
||||
if ($Page == 0) {
|
||||
%ToReplace= (
|
||||
"L1"=>"L1VOLTAGE",
|
||||
"L3"=>"L3VOLTAGE",
|
||||
"TL"=>"TLVOLTAGE",
|
||||
"BFIELD"=>"SAM_BFIELD",
|
||||
"RA_T"=>"RA_TVOL",
|
||||
"RA_B"=>"RA_BVOL",
|
||||
"RA_R"=>"RA_RVOL",
|
||||
"RA_L"=>"RA_LVOL",
|
||||
"SR_B"=>"SR_BFIELD",
|
||||
"SR_E"=>"SR_EFIELD",
|
||||
"ENERGY"=>"ENERGY"
|
||||
);
|
||||
if ($Page == 0) {
|
||||
%ToReplace= (
|
||||
"L1"=>"L1VOLTAGE",
|
||||
"L3"=>"L3VOLTAGE",
|
||||
"TL"=>"TLVOLTAGE",
|
||||
"BFIELD"=>"SAM_BFIELD",
|
||||
"RA_T"=>"RA_TVOL",
|
||||
"RA_B"=>"RA_BVOL",
|
||||
"RA_R"=>"RA_RVOL",
|
||||
"RA_L"=>"RA_LVOL",
|
||||
"SR_B"=>"SR_BFIELD",
|
||||
"SR_E"=>"SR_EFIELD",
|
||||
"NMuon"=>"NMuon",
|
||||
"ENERGY"=>"ENERGY"
|
||||
);
|
||||
# Use the following template
|
||||
$FName="SRBeamLine.mac";
|
||||
} elsif ($Page == 1) {
|
||||
$FName="SRBeamLine.mac";
|
||||
} elsif ($Page == 1) {
|
||||
%ToReplace= (
|
||||
"L1_2"=>"L1VOLTAGE",
|
||||
"L2_2"=>"L2VOLTAGE",
|
||||
@ -227,32 +235,90 @@ void QmuSRSim::StartCalc()
|
||||
"RA_B_2"=>"RA_BVOL",
|
||||
"RA_R_2"=>"RA_RVOL",
|
||||
"RA_L_2"=>"RA_LVOL",
|
||||
"NMuon"=>"NMuon",
|
||||
"ENERGY_2"=>"ENERGY"
|
||||
);
|
||||
);
|
||||
# Use the following template
|
||||
$FName="CBeamLine.mac";
|
||||
}
|
||||
|
||||
open(MACF,"$FName");
|
||||
my @lines=<MACF>;
|
||||
close(MACF);
|
||||
open(MACF,"$FName");
|
||||
my @lines=<MACF>;
|
||||
close(MACF);
|
||||
|
||||
for my $key (keys %ToReplace) {
|
||||
for my $key (keys %ToReplace) {
|
||||
# Need to check values of replace parameters...
|
||||
map(s/$ToReplace{$key}/$All{$key}/, @lines);
|
||||
print "Replacing \t".$ToReplace{$key}."\t by \t".$All{$key}."\n";
|
||||
}
|
||||
map(s/$ToReplace{$key}/$All{$key}/, @lines);
|
||||
print "Replacing \t".$ToReplace{$key}."\t by \t".$All{$key}."\n";
|
||||
}
|
||||
|
||||
open(NEWMACF,">1000.mac");
|
||||
print NEWMACF @lines;
|
||||
close(NEWMACF);
|
||||
|
||||
my $DIR=`pwd`;
|
||||
chomp $DIR;
|
||||
my $SimDIR="~/LEM/simulation/geant4/musrSim";
|
||||
my $SYSROOT="/usr/local";
|
||||
my $cmd="cd $SimDIR; . /usr/local/geant4/4.9.3/env.sh; export SYSROOT=$SYSROOT; cd run; $SimDIR/bin/Linux-g++/musrSim $DIR/1000.mac";
|
||||
system("$cmd");
|
||||
my $NewFile=$All{"MAC"}.".mac";
|
||||
open(NEWMACF,">$NewFile");
|
||||
print NEWMACF @lines;
|
||||
close(NEWMACF);
|
||||
print "Created mac file $NewFile\n";
|
||||
|
||||
my $DIR=`pwd`;
|
||||
chomp $DIR;
|
||||
my $musrSim=$All{"musrSim"};
|
||||
my $Geant4=$All{"Geant4"};
|
||||
my $SYSROOT=$All{"SYSROOT"};
|
||||
my $cmd="cd $musrSim; . $Geant4/env.sh; export SYSROOT=$SYSROOT; cd run; cp $DIR/$NewFile $NewFile;$musrSim/bin/Linux-g++/musrSim $NewFile > $NewFile.out ";
|
||||
system("$cmd");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QmuSRSim::GetPATH()
|
||||
{
|
||||
# Which button was clicked?
|
||||
my $sender = sender();
|
||||
# Then find the name of the sender button and convert it to the name of the appropriate lineEdit
|
||||
my $name = $sender->name();
|
||||
$name =~ s/Button//g;
|
||||
|
||||
# Get the requested path
|
||||
my $RETVAL = Qt::FileDialog::getExistingDirectory("./",this,"get existing directory","Choose a directory",1);
|
||||
# Now submit the path into the lineEdit
|
||||
if ($RETVAL ne "") {
|
||||
child($name)->setText($RETVAL);
|
||||
}
|
||||
}
|
||||
|
||||
void QmuSRSim::CheckSim()
|
||||
{
|
||||
# Returns 1 if the simulation can run and 0 if not
|
||||
my $answ=1;
|
||||
my $answtext="";
|
||||
|
||||
my $musrSimPATH= musrSim->text();
|
||||
my $Geant4PATH= Geant4->text();
|
||||
my $SaveDataPATH= SaveData->text();
|
||||
my $ROOTSYSPATH=ROOTSYS->text();
|
||||
|
||||
# Check if any of them is empty or does not exist
|
||||
unless (-d $musrSimPATH) {
|
||||
$answ=0;
|
||||
$answtext=$answtext."musrSim Path \" $musrSimPATH\" is wrong!\n";
|
||||
} else {
|
||||
unless (-e "$Geant4PATH/env.sh") {
|
||||
$answ=0;
|
||||
$answtext=$answtext."Geant4 'env.sh' file does not exist!\n";
|
||||
}
|
||||
}
|
||||
unless (-d $SaveDataPATH) {
|
||||
$answ=0;
|
||||
$answtext=$answtext."Save Data Path is wrong!\n";
|
||||
}
|
||||
unless (-d $ROOTSYSPATH) {
|
||||
$answ=0;
|
||||
$answtext=$answtext."ROOTSYS Path is wrong!\n";
|
||||
}
|
||||
|
||||
if ($answ==0) {
|
||||
print STDERR $answtext;
|
||||
my $HelpWindow = Qt::MessageBox::information( this, "Error!",$answtext);
|
||||
}
|
||||
return $answ;
|
||||
}
|
||||
|
@ -782,5 +782,5 @@
|
||||
# BEAM ON
|
||||
#/run/beamOn 1000000
|
||||
#/run/beamOn 10
|
||||
/run/beamOn 1000
|
||||
/run/beamOn NMuon
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user