Difference between revisions of "BUILD GEMC SIMULATION.sh"

From New IAC Wiki
Jump to navigation Jump to search
(Created page with "<pre> #!/bin/bash bold=`tput bold` normal=`tput sgr0` echo "+------------------------------------------------------+" echo "|...")
 
(Blanked the page)
Tag: Blanking
 
Line 1: Line 1:
<pre>
 
#!/bin/bash
 
bold=`tput bold`
 
normal=`tput sgr0`
 
echo "+------------------------------------------------------+"
 
echo "|                                                      |"
 
echo "|  GEMC Simulations with root  V1.0                    |"
 
echo "|  Daniel VanWasshenova                                |"
 
echo "|                                                      |"
 
echo "+------------------------------------------------------+"
 
#Source root for c++ programs
 
source /home/lds/src/ROOT/root/bin/thisroot.sh
 
#Get Conditions
 
echo "********************************************************"
 
echo "Target material (${bold}LH2${normal}, NH3, NO) ?"
 
read TargetMaterial
 
echo "Solenoid Field (-1 to ${bold}1${normal}, NO) ?"
 
read SolenoidField
 
echo "Torus Field (${bold}-1${normal} to 1) ?"
 
read TorusField
 
echo "Incident Electron Energy (GeV) ?"
 
read IncidentEnergy
 
echo "Phi Distribution (${bold}Isotropic${normal} or set value) ?"
 
read PhiDistribution
 
echo "GEMC Version (4 or ${bold}6${normal}) ?"
 
read GEMCversion
 
echo "Shield Status (${bold}In${normal}/Out) ?"
 
read ShieldStatus
 
if [ $ShieldStatus = "In" ]
 
then
 
echo "FT Status (ON/${bold}OFF${normal}) ?"
 
read FTStatus
 
echo "Beamline Status (${bold}In${normal}/Out) ?"
 
read BeamlineStatus
 
echo "VacuumLine Status (${bold}In${normal}/Out) ?"
 
read VacuumLineStatus
 
echo "CadBeamline Status (${bold}In${normal}/Out) ?"
 
read CadBeamlineStatus
 
nameOFpath="${TargetMaterial}"Tar_"${SolenoidField}"Sol_"${TorusField}"Tor_"${IncidentEnergy}"GeV_"${PhiDistribution}"Phi_v2_"${GEMCversion}"_Shield"${ShieldStatus}"_FT"${FTStatus}"_Beamline"${BeamlineStatus}"_VacuumLine"${VacuumLineStatus}"_CadBeamline"${CadBeamlineStatus}"
 
fi
 
if [ $ShieldStatus = "Out" ]
 
then
 
nameOFpath="${TargetMaterial}"Tar_"${SolenoidField}"Sol_"${TorusField}"Tor_"${IncidentEnergy}"GeV_"${PhiDistribution}"Phi_v2_"${GEMCversion}"_Shield"${ShieldStatus}"
 
FTStatus="x"
 
BeamlineStatus="x"
 
VacuumLineStatus="x"
 
CadBeamlineStatus="x"
 
fi
 
#Make directory
 
echo "Creating directory "${nameOFpath}
 
mkdir ${nameOFpath}
 
echo "*********************************************************"
 
  
#Copy needed files to directory
 
cp gcard_builder.C ${nameOFpath}
 
cp LUND_Spread_IsotropicPhi.C ${nameOFpath}
 
cp Block_builder.C ${nameOFpath}
 
cp submit_builder.C ${nameOFpath}
 
 
#Move into directory
 
cd ${nameOFpath}
 
 
#Execute LUND creation file
 
echo "Creating LUND files......"
 
root -l -b -q LUND_Spread_IsotropicPhi.C
 
 
#Move LUND file into directory named path
 
mv LUND_Spread_IsotropicPhi.LUND ${nameOFpath}.LUND
 
 
#Split LUND file
 
split -d -l 3000 -a 3 ${nameOFpath}.LUND ${nameOFpath}_
 
#Name these components LUND files
 
find . -type f  ! -name "*.*" -exec mv {} {}.LUND \;
 
#Place the LUND files in individual directories
 
find . -name "*.LUND" -exec sh -c 'mkdir "${1%.*}" ; mv "$1" "${1%.*}" ' _ {} \;
 
#Execute gcard builder and place gcards in each directory
 
echo "*********************************************************"
 
echo "Building specific gcards....."
 
root -l -b -q 'gcard_builder.C("'${TargetMaterial}'","'${SolenoidField}'","'${TorusField}'","'${IncidentEnergy}'","'${PhiDistribution}'","'${GEMCversion}'","'${ShieldStatus}'","'${FTStatus}'","'${BeamlineStatus}'","'${VacuumLineStatus}'","'${CadBeamlineStatus}'")'
 
echo "Creating submit files........"
 
mkdir submit
 
root -l -b -q 'submit_builder.C("'${nameOFpath}'")'
 
root -l -b -q Block_builder.C
 
cd submit
 
echo "Changed directory to:${PWD}"
 
chmod +x submit*
 
chmod +x Block*
 
 
#Open screen enviroments to run GEMC for each Block(10 sets of submits at 1000 events each)
 
echo ""
 
echo "*********************************************************"
 
screen -dmS zeroth tcsh
 
screen -dmS first tcsh
 
screen -dmS second tcsh
 
screen -dmS third tcsh
 
if [ $PhiDistribution = "Isotropic" ]
 
then
 
screen -dmS fourth tcsh
 
screen -dmS fifth tcsh
 
screen -dmS sixth tcsh
 
screen -dmS seventh tcsh
 
screen -dmS eighth tcsh
 
screen -dmS ninth tcsh
 
screen -dmS tenth tcsh
 
fi
 
#Allow enough time for screens to open
 
sleep 10
 
screen -S zeroth -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S first -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S second -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S third -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
if [ $PhiDistribution = "Isotropic" ]
 
then
 
screen -S fourth -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S fifth -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S sixth -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S seventh -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S eighth -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S ninth -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
screen -S tenth -X stuff "source ~/src/CLAS/GEMC/setup
 
"
 
fi
 
#Allow time for setup to finish
 
sleep 10
 
echo "CREATING SCREEN: Name"
 
echo "screen: zeroth"
 
screen -S zeroth -X stuff "./Block000.csh
 
"
 
echo "screen: first"
 
screen -S first -X stuff "./Block001.csh
 
"
 
echo "screen: second"
 
screen -S second -X stuff "./Block002.csh
 
"
 
echo "screen: third"
 
screen -S third -X stuff "./Block003.csh
 
"
 
if [ $PhiDistribution = "Isotropic" ]
 
then
 
echo "screen: fourth"
 
screen -S fourth -X stuff "./Block004.csh
 
"
 
echo "screen: fifth"
 
screen -S fifth -X stuff "./Block005.csh
 
"
 
echo "screen: sixth"
 
screen -S sixth -X stuff "./Block006.csh
 
"
 
echo "screen: seventh"
 
screen -S seventh -X stuff "./Block007.csh
 
"
 
echo "screen: eighth"
 
screen -S eighth -X stuff "./Block008.csh
 
"
 
echo "screen: ninth"
 
screen -S ninth -X stuff "./Block009.csh
 
"
 
echo "screen: tenth"
 
screen -S tenth -X stuff "./Block010.csh
 
"
 
fi
 
echo "Creating evio files!"
 
touch count.txt
 
 
Completed=$(numsum count.txt)
 
loopcounter="0"
 
if [ $PhiDistribution = "Isotropic" ]
 
then
 
NumberOfFiles=106
 
fi
 
if [ $PhiDistribution != "Isotropic" ]
 
then
 
NumberOfFiles=34
 
fi
 
echo -n "[$Completed %] finished"
 
while [ $Completed -ne $NumberOfFiles ]
 
do
 
Completed=$(numsum count.txt)
 
loopcounter=$((loopcounter+1))     
 
sleep 10
 
if [ $((loopcounter%5)) -eq 0 ]
 
then
 
Pcent=$( echo "scale=1 ; $Completed / $NumberOfFiles / .01" | bc -l)
 
echo -n "[$Pcent %] finished"
 
fi
 
echo -n "."
 
done
 
echo $Completed" GEMC evio files created"
 
echo "Closing screens"
 
killall screen
 
echo "***********************************************************"
 
echo ""
 
echo "Creating virtual folder on lds2"
 
sshpass -p 'c0d/\2.0' ssh -o StrictHostKeyChecking=no lds@lds2.physics.isu.edu "./first_commands.tcsh"
 
echo "Run evio2Root"
 
sleep 2
 
sshpass -p 'c0d/\2.0' ssh -o StrictHostKeyChecking=no lds@lds2.physics.isu.edu "./second_commands.tcsh $nameOFpath"
 
sleep 2
 
sshpass -p 'c0d/\2.0' ssh -o StrictHostKeyChecking=no lds@lds2.physics.isu.edu "./last_commands.tcsh"
 
echo "GEMC Program finished!"
 
</pre>
 

Latest revision as of 21:43, 23 August 2018