First running version

This commit is contained in:
salman 2012-04-26 15:08:30 +00:00
parent c994c2489f
commit f694c3feed
4 changed files with 2437 additions and 1474 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@ void QmuSRSim::fileSave()
$InitFile=$InitFile.$key."=".$All{$key}."\n"; $InitFile=$InitFile.$key."=".$All{$key}."\n";
} }
# Save to default file name "TriumSP.cfg" # Save to default file name "musrSim.cfg"
my $file = "musrSim.cfg"; my $file = "musrSim.cfg";
open (OUTF,q{>},"$file" ); open (OUTF,q{>},"$file" );
print OUTF (" $InitFile"); print OUTF (" $InitFile");
@ -179,8 +179,9 @@ void QmuSRSim::helpAbout()
void QmuSRSim::CreateAllInput() void QmuSRSim::CreateAllInput()
{ {
my %All=(); my %All=();
my @AllParams= ("L1","L3","TL","BFIELD","RA_T","RA_B","RA_R","RA_L","SR_B","SR_E","ENERGY", 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"); "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) { foreach my $Param (@AllParams) {
my $Child = child($Param); my $Child = child($Param);
my $Value = $Child->text; my $Value = $Child->text;
@ -196,28 +197,35 @@ void QmuSRSim::CreateAllInput()
void QmuSRSim::StartCalc() void QmuSRSim::StartCalc()
{ {
my %All=CreateAllInput(); my %All=CreateAllInput();
my $Page = Tabs->currentPageIndex;
my %ToReplace=(); # Check if the simulation can run
my @SpaceHolder=(); my $answ = CheckSim();
my $FName="SRBeamLine.mac"; 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. # 0 for spin rotator and 1 for current.
if ($Page == 0) { if ($Page == 0) {
%ToReplace= ( %ToReplace= (
"L1"=>"L1VOLTAGE", "L1"=>"L1VOLTAGE",
"L3"=>"L3VOLTAGE", "L3"=>"L3VOLTAGE",
"TL"=>"TLVOLTAGE", "TL"=>"TLVOLTAGE",
"BFIELD"=>"SAM_BFIELD", "BFIELD"=>"SAM_BFIELD",
"RA_T"=>"RA_TVOL", "RA_T"=>"RA_TVOL",
"RA_B"=>"RA_BVOL", "RA_B"=>"RA_BVOL",
"RA_R"=>"RA_RVOL", "RA_R"=>"RA_RVOL",
"RA_L"=>"RA_LVOL", "RA_L"=>"RA_LVOL",
"SR_B"=>"SR_BFIELD", "SR_B"=>"SR_BFIELD",
"SR_E"=>"SR_EFIELD", "SR_E"=>"SR_EFIELD",
"ENERGY"=>"ENERGY" "NMuon"=>"NMuon",
); "ENERGY"=>"ENERGY"
);
# Use the following template # Use the following template
$FName="SRBeamLine.mac"; $FName="SRBeamLine.mac";
} elsif ($Page == 1) { } elsif ($Page == 1) {
%ToReplace= ( %ToReplace= (
"L1_2"=>"L1VOLTAGE", "L1_2"=>"L1VOLTAGE",
"L2_2"=>"L2VOLTAGE", "L2_2"=>"L2VOLTAGE",
@ -227,32 +235,90 @@ void QmuSRSim::StartCalc()
"RA_B_2"=>"RA_BVOL", "RA_B_2"=>"RA_BVOL",
"RA_R_2"=>"RA_RVOL", "RA_R_2"=>"RA_RVOL",
"RA_L_2"=>"RA_LVOL", "RA_L_2"=>"RA_LVOL",
"NMuon"=>"NMuon",
"ENERGY_2"=>"ENERGY" "ENERGY_2"=>"ENERGY"
); );
# Use the following template # Use the following template
$FName="CBeamLine.mac"; $FName="CBeamLine.mac";
} }
open(MACF,"$FName"); open(MACF,"$FName");
my @lines=<MACF>; my @lines=<MACF>;
close(MACF); close(MACF);
for my $key (keys %ToReplace) { for my $key (keys %ToReplace) {
# Need to check values of replace parameters... # Need to check values of replace parameters...
map(s/$ToReplace{$key}/$All{$key}/, @lines); map(s/$ToReplace{$key}/$All{$key}/, @lines);
print "Replacing \t".$ToReplace{$key}."\t by \t".$All{$key}."\n"; print "Replacing \t".$ToReplace{$key}."\t by \t".$All{$key}."\n";
} }
open(NEWMACF,">1000.mac"); my $NewFile=$All{"MAC"}.".mac";
print NEWMACF @lines; open(NEWMACF,">$NewFile");
close(NEWMACF); print NEWMACF @lines;
close(NEWMACF);
my $DIR=`pwd`; print "Created mac file $NewFile\n";
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 $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;
}

View File

@ -782,5 +782,5 @@
# BEAM ON # BEAM ON
#/run/beamOn 1000000 #/run/beamOn 1000000
#/run/beamOn 10 #/run/beamOn 10
/run/beamOn 1000 /run/beamOn NMuon