3 # Author: bjpjones@fnal.gov from echurch@fnal.gov from dbox@fnal.gov
5 # A script to run the optical library building job
10 # jobsub -X509_USER_PROXY /scratch/[user]/grid/[user].uboone.proxy -N [NoOfJobs] -q OpticalLibraryBuild_Grid.sh `whoami` `pwd`
12 # You will get outputs in the area specified by the "outstage" variable
13 # which is specified below.
15 # The form of the output is one file for each few voxels. These then need
16 # stitching together, which is done after all jobs are done, with a
17 # dedicated stitching script.
23 # Copy arguments into meaningful names.
30 # Directory in which to put the output files.
31 outstage=/uboone/data/users/bjpjones/OpticalProduction
34 # Library building parameters
36 # In each grid job, do this many voxels:
39 # In each voxel, run this many photons:
40 NPhotonsPerVoxel=30000
44 # This works out which voxels this job should focus on:
45 FirstVoxel=`echo "($NVoxelsPerJob * $PROCESS ) % $NTopVoxel" | bc`
46 LastVoxel=`echo "(($NVoxelsPerJob * $PROCESS ) + $NVoxelsPerJob - 1 ) % $NTopVoxel" | bc`
49 # And then tell the user about it:
50 echo "This job will run from voxel $FirstVoxel to $LastVoxel, generating $NPhotonsPerVoxel in each"
53 # Most of what comes next is from echurch's grid submission script.
56 echo "Input arguments:"
57 echo "Cluster: " $cluster
58 echo "Process: " $process
60 echo "SubmitDir: " $submitdir
63 # Do not change this section.
65 TMP=`mktemp -d ${_CONDOR_SCRATCH_DIR:-/var/tmp}/working_dir.XXXXXXXXXX`
66 TMP=${TMP:-${_CONDOR_SCRATCH_DIR:-/var/tmp}/working_dir.$$}
68 { [[ -n "$TMP" ]] && mkdir -p "$TMP"; } || \
69 { echo "ERROR: unable to create temporary directory!" 1>&2; exit 1; }
70 trap "[[ -n \"$TMP\" ]] && { cd ; rm -rf \"$TMP\"; }" 0
72 echo "Temp directory : $TMP"
77 # End of the section you should not change.
80 # Construct the run-time configuration file for this job;
81 # Make the random number seeds a function of the process number.
82 generatorSeed=$(( $process *23 + 31))
83 g4Seed=$(( $process *41 + 37))
86 # Copy fcl file and configure for this process
87 cp /uboone/app/users/bjpjones/GridReadyNew/prodsingle_buildopticallibrary.fcl thisjob.fcl
89 echo "physics.producers.generator.FirstVoxel: $FirstVoxel" >> thisjob.fcl
90 echo "physics.producers.generator.LastVoxel: $LastVoxel" >> thisjob.fcl
91 echo "physics.producers.generator.N: $NPhotonsPerVoxel">> thisjob.fcl
93 # No need to set random seeds - generated from machine state
94 #echo "physics.producers.generator.RandomSeed: $generatorSeed">> thisjob.fcl
95 #echo "physics.producers.largeant.RandomSeed: $g4Seed">> thisjob.fcl
100 # Establish environment and run the job.
102 export EXPERIMENT=uboone
103 export EXTRA_PATH=lar
104 export HOME=/uboone/app/users/bjpjones/GridReadyNew
106 ## This sets all the needed FW and SRT and LD_LIBRARY_PATH envt variables.
107 ## Then we cd back to our TMP area. EC, 23-Nov-2010.
111 # Setup larsoft within the uboone frozen release
112 source /grid/fermiapp/lbne/lar/code/larsoft/releases/S2013.03.11/setup/setup_larsoft_fnal.sh -r S2013.03.11
113 srt_setup SRT_BASE_RELEASE=S2013.03.11
121 lar -c thisjob.fcl -n $NVoxelsPerJob >& thisjob.log
125 # Make sure the user's output staging area exists.
126 test -e $outstage || mkdir $outstage
127 if [ ! -d $outstage ];then
128 echo "File exists but is not a directory."
129 outstage=/grid/data/lbne/outstage/nobody
130 echo "Changing outstage directory to: " $outstage
134 # Make a directory in the outstage area to hold all files from this job.
135 echo "Trying to make directory : ${outstage}/${cluster}_${process} "
136 mkdir ${outstage}/${cluster}_${process}
139 # Copy all files from the working directory to the output staging area.
140 /grid/fermiapp/minos/scripts/cpn *.root ${outstage}/${cluster}_${process}
141 /grid/fermiapp/minos/scripts/cpn *.log ${outstage}/${cluster}_${process}
142 /grid/fermiapp/minos/scripts/cpn *.fcl ${outstage}/${cluster}_${process}
143 # Make sure EXPERIMENTana (under which name the jobs run on the grid)
144 # writes these as group rw, so you can rm 'em, etc.
145 #chmod -R g+rw $outstage