Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:27:44

0001 #!/bin/csh
0002 
0003 # SJDK - 07/03/22 - New script which takes in a whole bunch of inputs to create jobs/config files. Note that I'm not 100% happy with the pathing in this file so it should be tweaked and optimised at some point
0004 # This version is intended for use on the JLab iFarm. Pathing is set up for this purpose and is NOT relative.
0005 
0006 # Tested on the iFarm - produces output
0007 
0008 # Set path depending upon hostname. Change or add more as needed  
0009 if ( "$HOSTNAME" =~ *farm* ) then
0010     set DEMPGENPath="/group/eic/users/${USER}/DEMPgen"
0011     module use /cvmfs/oasis.opensciencegrid.org/jlab/scicomp/sw/el9/modulefiles
0012     module load root/6.30.06-gcc11.4.0
0013 else if ( "$HOSTNAME" =~ *qcd* ) then
0014     set DEMPGENPath="/group/eic/users/${USER}/DEMPgen"
0015     module use /cvmfs/oasis.opensciencegrid.org/jlab/scicomp/sw/el9/modulefiles
0016     module load root/6.30.06-gcc11.4.0
0017 else
0018     set DEMPGENPath=$PWD
0019 endif
0020 
0021 cd "$DEMPGENPath"
0022 
0023 # This is effectively a copy of setup.csh - Set the DEMPgen environment variable for subsequent use
0024 setenv DEMPgen $DEMPGENPath
0025 if ( ! ($?LD_LIBRARY_PATH) ) then
0026    setenv LD_LIBRARY_PATH ""
0027 endif
0028 # Check if DYLD_LIBRARY_PATH is defined
0029 if ( ! ($?DYLD_LIBRARY_PATH) ) then
0030    setenv DYLD_LIBRARY_PATH ""
0031 endif
0032 setenv LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${DEMPgen}"
0033 
0034 echo""
0035 echo "This file is intended to be run as part of a batch job submission, however, you can also run it on its own."
0036 echo "Expected input is - FileNumber NumberOfEvents ElectronBeamEnergy HadronBeamEnergy RandomSeed OutputType IP Ejectile Recoil_Hadron(Optional, for K+)"
0037 echo "Please see the README for more info."
0038 echo ""
0039 
0040 if ($#argv != 8 && $#argv != 9) then
0041     echo "! ERROR !"
0042     echo "! ERROR ! - Expected 8 or 9 arguments, please see the opening information - ! ERROR !"
0043     echo "! ERROR !"
0044     exit 1
0045 endif
0046 
0047 set FileNum=$1
0048 set NumEvents=$2
0049 set EBeamE=$3
0050 set HBeamE=$4
0051 set RandomSeed=$5
0052 set OutputType=$6
0053 set InteractionPoint=$7
0054 set Ejectile=$8
0055 
0056 if ($Ejectile == "K+" && $#argv == 8 ) then
0057     echo "! WARNING !"
0058     echo "! WARNING ! - For K+ production expect a recoil hadron specified, defaulting to Lambda - ! WARNING !"
0059     echo "! WARNING !"
0060     set RecoilHadron="Lambda"
0061 else if ($Ejectile == "K+" && $#argv == 9 ) then
0062     set RecoilHadron=$9
0063 else 
0064     set RecoilHadron=""
0065 endif
0066 
0067 echo "Running file $FileNum with $NumEvents events per file for $EBeamE GeV e- on $HBeamE GeV p using random seed $RandomSeed, using $OutputType format output for $Ejectile $RecoilHadron events."
0068     
0069 # Set the config file name based upon inputs
0070 set ConfigFilename = $DEMPGENPath'/Config_EIC_'$EBeamE'on'$HBeamE'_'$InteractionPoint'_'$Ejectile$RecoilHadron'_'$NumEvents'_'$FileNum'.json'
0071 
0072 # Copy the default config file to our constructed filename
0073 cp "$DEMPGENPath/Config_EIC.json" $ConfigFilename
0074 
0075 # Use sed commands to change our config file based upon inputs
0076 sed -i 's/"file_name" \:.*/"file_name" \: "DEMPgen_'$EBeamE'on'$HBeamE'_'$InteractionPoint'_'$Ejectile$RecoilHadron'_'$NumEvents'_'$FileNum'",/' $ConfigFilename
0077 sed -i 's/"n_events" \:.*/"n_events" \: '$NumEvents',/' $ConfigFilename
0078 sed -i 's/"generator_seed"\:.*/"generator_seed" \: '$RandomSeed',/' $ConfigFilename
0079 sed -i 's/"ebeam"\:.*/"ebeam" \: '$EBeamE',/' $ConfigFilename
0080 sed -i 's/"hbeam"\:.*/"hbeam" \: '$HBeamE',/' $ConfigFilename
0081 sed -i 's/"ejectile"\:.*/"ejectile" \: "'$Ejectile'",/' $ConfigFilename
0082 sed -i 's/"recoil_hadron"\:.*/"recoil_hadron" \: "'$RecoilHadron'",/' $ConfigFilename
0083 sed -i 's/"det_location"\:.*/"det_location" \: "'$InteractionPoint'",/' $ConfigFilename
0084 sed -i 's/"OutputType"\:.*/"OutputType"\: "'$OutputType'",/' $ConfigFilename
0085 
0086 # Run our new config file
0087 eval $DEMPGENPath/build/DEMPgen $ConfigFilename
0088 sleep 5
0089 
0090 # Filename as it's created is a bit odd, so rename it
0091 set OriginalOutput = $DEMPGENPath'/data/output/eic_input_DEMPgen_'$EBeamE'on'$HBeamE'_'$InteractionPoint'_'$Ejectile$RecoilHadron'_'$NumEvents'_'$FileNum'.dat'
0092 set RenamedOutput =  $DEMPGENPath'/data/output/eic_DEMPgen_'$EBeamE'on'$HBeamE'_'$InteractionPoint'_'$Ejectile$RecoilHadron'_'$NumEvents'_'$FileNum'.dat'
0093 
0094 mv $OriginalOutput $RenamedOutput
0095 
0096 rm -rf $ConfigFilename
0097 
0098 exit 0