12 if [ "${HORN}" != "FHC" ] && [ "${HORN}" != "RHC" ]; then
13 echo "Invalid beam mode ${HORN}"
14 echo "Must be FHC or RHC"
20 if [ "${HORN}" = "RHC" ]; then
25 if [ "${NPOT}" = "" ]; then
26 echo "POT not specified, using 1E16"
30 if [ "${FIRST}" = "" ]; then
31 echo "First run number not specified, using 0"
35 if [ "${OFFAXIS}" = "" ]; then
36 echo "Off axis position not specified, assuming on-axis"
40 if [ "${FLUX}" = "" ]; then
41 echo "Flux not specified, using dk2nu"
45 if [ "${FLUX}" = "dk2nu" ]; then
47 FLUXDIR="/pnfs/dune/persistent/users/ljf26/fluxfiles/g4lbne/v3r5p4/QGSP_BERT"
49 if [ "${FLUX}" = "gsimple" ]; then
51 FLUXDIR="/pnfs/dune/persistent/users/dbrailsf/flux/nd/gsimple/v2_8_6d"
55 if [ "${TEST}" = "test" ]; then
62 # ifdhc doen't have a mkdir -p equivalent, which is fine
63 # as long as you always remember to include this convenient function in your scripts
67 if [ `ifdh ls $dir 0 $force | wc -l` -gt 0 ]
71 ifdh_mkdir_p `dirname $dir` $force
72 ifdh mkdir $dir $force
77 if [ "${HORN}" = "RHC" ]; then
78 OADIR="${OFFAXIS}mRHC"
81 if [ "${FLUX}" = "gsimple" ] && [ "${HORN}" = "FHC" ]; then
82 OADIR="${OFFAXIS}mgsimple"
85 RUNNO=$((${PROCESS}+${FIRST}))
86 RNDSEED=$((1000000*${OFFAXIS}+${RUNNO}+1000000))
88 # 5E16 is about 15000 events on-axis which runs in ~6 hours
89 NEVENTS="-e ${NPOT}" # -n XXXX number of events, -e XE16 for POT
91 RDIR=$((${RUNNO} / 1000))
92 if [ ${RUNNO} -lt 10000 ]; then
93 RDIR=0$((${RUNNO} / 1000))
96 GEOMETRY="MPD_SPY_LAr"
97 TOPVOL="volArgonCubeActive"
99 TARDIR="/pnfs/dune/persistent/users/LBL_TDR/sw_tarballs"
100 OUTDIR="/pnfs/dune/persistent/users/marshalc/nd_offaxis/v7"
102 # Don't try over and over again to copy a file when it isn't going to work
103 export IFDH_CP_UNLINK_ON_ERROR=1
104 export IFDH_CP_MAXRETRIES=1
107 ##################################################
109 # Setup UPS and required products
110 echo "Setting up software"
111 source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh
113 setup dk2nugenie v01_06_01f -q debug:e15
114 setup genie_xsec v2_12_10 -q DefaultPlusValenciaMEC
115 setup genie_phyopt v2_12_10 -q dkcharmtau
116 setup geant4 v4_10_3_p01b -q e15:prof
118 # edep-sim needs to know where a certain GEANT .cmake file is...
119 G4_cmake_file=`find ${GEANT4_FQ_DIR}/lib64 -name 'Geant4Config.cmake'`
120 export Geant4_DIR=`dirname $G4_cmake_file`
122 # edep-sim needs to have the GEANT bin directory in the path
123 export PATH=$PATH:$GEANT4_FQ_DIR/bin
125 ##################################################
126 # Get the binaries & other files that are needed
127 ${CP} ${TARDIR}/sim_inputs.tar.gz sim_inputs.tar.gz
128 ${CP} ${TARDIR}/edep-sim.tar.gz edep-sim.tar.gz
129 ${CP} ${TARDIR}/nusystematics.tar.gz nusystematics.tar.gz
130 ${CP} ${TARDIR}/nusyst_inputs.tar.gz nusyst_inputs.tar.gz
131 ${CP} ${TARDIR}/DUNE_ND_GeoEff.tar.gz DUNE_ND_GeoEff.tar.gz
134 tar -xzf sim_inputs.tar.gz
135 tar -xzf edep-sim.tar.gz
136 tar -xzf nusystematics.tar.gz
137 tar -xzf nusyst_inputs.tar.gz
138 tar -xzf DUNE_ND_GeoEff.tar.gz
139 mv sim_inputs/* ${PWD}
141 # Get flux files to local node
142 # dk2nu files: /pnfs/dune/persistent/users/ljf26/fluxfiles/g4lbne/v3r5p4/QGSP_BERT/OptimizedEngineeredNov2017/neutrino/flux/dk2nu
143 # gsimple files: /pnfs/dune/persistent/users/dbrailsf/flux/nd/gsimple/v2_8_6d/OptimizedEngineeredNov2017/neutrino/
144 chmod +x copy_dune_ndtf_flux
145 ./copy_dune_ndtf_flux --top ${FLUXDIR} --outpath local_flux_files --flavor ${MODE} --base OptimizedEngineeredNov2017 --maxmb=300 ${FLUXOPT}
147 # GENIE for some reason doesn't recognize *.dk2nu.root as dk2nu format, but it works if dk2nu is at the front?
148 if [ "${FLUX}" = "dk2nu" ]; then
150 for f in *.dk2nu.root
157 ##################################################
159 # Modify GNuMIFlux.xml to the specified off-axis position
160 sed -i "s/<beampos> ( 0.0, 0.05387, 6.66 )/<beampos> ( ${OFFAXIS}, 0.05387, 6.66 )/g" GNuMIFlux.xml
162 export GXMLPATH=${PWD}:${GXMLPATH}
163 export GNUMIXML="GNuMIFlux.xml"
166 echo "Running gevgen"
167 TIME_GENIE=`date +%s`
169 -f local_flux_files/${FLUX}*,DUNEND \
170 -g ${GEOMETRY}.gdml \
177 --message-thresholds Messenger_production.xml \
178 --cross-sections ${GENIEXSECPATH}/gxspl-FNALsmall.xml \
179 --event-record-print-level 0 \
180 --event-generator-list Default+CCMEC
181 #-m ${GEOMETRY}.${TOPVOL}.maxpl.xml \
183 ##################################################
185 # Convert the genie output to rootracker
187 export LD_LIBRARY_PATH=${PWD}/edep-sim/edep-gcc-6.4.0-x86_64-pc-linux-gnu/lib:${LD_LIBRARY_PATH}
188 export PATH=${PWD}/edep-sim/edep-gcc-6.4.0-x86_64-pc-linux-gnu/bin:${PATH}
191 TIME_ROOTRACKER=`date +%s`
192 ${CP} ${MODE}.${RNDSEED}.ghep.root input_file.ghep.root
193 gntpc -i input_file.ghep.root -f rootracker \
194 --event-record-print-level 0 \
195 --message-thresholds Messenger_production.xml
197 # edep-sim wants number of events, but we are doing POT so the files will be slightly different
198 # get the number of events from the GENIE files to pass it to edep-sim
199 NPER=$(echo "std::cout << gtree->GetEntries() << std::endl;" | genie -l -b input_file.ghep.root 2>/dev/null | tail -1)
201 ##################################################
204 echo "Running edep-sim with ${NPER} events."
205 TIME_EDEPSIM=`date +%s`
208 -g ${GEOMETRY}.gdml \
209 -o edep.${RNDSEED}.root \
214 ##################################################
216 # The MakeProject in dumpTree.py won't work if edep-sim is in the library path for reasons unknown
217 # This is a hack, please avert your eyes if you don't want to see my garbage
218 unset LD_LIBRARY_PATH
220 setup dk2nugenie v01_06_01f -q debug:e15
221 setup genie_xsec v2_12_10 -q DefaultPlusValenciaMEC
222 setup genie_phyopt v2_12_10 -q dkcharmtau
223 setup geant4 v4_10_3_p01b -q e15:prof
225 # Add nusystematics to the paths
226 export LD_LIBRARY_PATH=${PWD}/nusystematics/build/Linux/lib:${LD_LIBRARY_PATH}
227 export LD_LIBRARY_PATH=${PWD}/nusystematics/build/nusystematics/artless:${LD_LIBRARY_PATH}
228 export FHICL_FILE_PATH=${PWD}/nusystematics/nusystematics/fcl:${FHICL_FILE_PATH}
230 # add pyGeoEff to pythonpath, and libgeoEff to LD_LIBRARY_PATH
231 export PYTHONPATH=${PWD}/DUNE_ND_GeoEff/lib/:${PYTHONPATH}
232 export LD_LIBRARY_PATH=${PWD}/DUNE_ND_GeoEff/lib:${LD_LIBRARY_PATH}
234 # Run dumpTree to make a root file, you can start reading again if you averted your eyes before
235 TIME_DUMPTREE=`date +%s`
236 python dumpTree.py --infile edep.${RNDSEED}.root --outfile ${HORN}.${RNDSEED}.root --seed ${RNDSEED}
239 TIME_CAFMAKER=`date +%s`
240 ./makeCAF --infile ${HORN}.${RNDSEED}.root --gfile ${MODE}.${RNDSEED}.ghep.root --outfile ${HORN}.${RNDSEED}.CAF.root --fhicl ./fhicl.fcl --seed ${RNDSEED} ${RHC} --oa ${OFFAXIS}
242 ##################################################
243 # Copy the output files
244 echo "It's copy time, here are the files that I have:"
247 ifdh_mkdir_p ${OUTDIR}/genie/${OADIR}/${RDIR}
248 ifdh_mkdir_p ${OUTDIR}/dump/${OADIR}/${RDIR}
249 ifdh_mkdir_p ${OUTDIR}/CAF/${OADIR}/${RDIR}
250 ifdh_mkdir_p ${OUTDIR}/edep/${OADIR}/${RDIR}
252 # GENIE, this is usually small and good idea to save
253 ${CP} ${MODE}.${RNDSEED}.ghep.root ${OUTDIR}/genie/${OADIR}/${RDIR}/${HORN}.${RNDSEED}.ghep.root
255 # G4/edep-sim file is HUGE and probably we can't save it
256 #${CP} edep.${RNDSEED}.root ${OUTDIR}/edep/${OADIR}/${RDIR}/${HORN}.${RNDSEED}.edep.root
258 # "dump" file is useful for various analyses
259 ${CP} ${HORN}.${RNDSEED}.root ${OUTDIR}/dump/${OADIR}/${RDIR}/${HORN}.${RNDSEED}.dump.root
261 ${CP} ${HORN}.${RNDSEED}.CAF.root ${OUTDIR}/CAF/${OADIR}/${RDIR}/${HORN}.${RNDSEED}.CAF.root
264 # Print out a single thing that says the time of each step
265 TIME_S=$((${TIME_GENIE}-${TIME_START}))
266 TIME_G=$((${TIME_ROOTRACKER}-${TIME_GENIE}))
267 TIME_R=$((${TIME_EDEPSIM}-${TIME_ROOTRACKER}))
268 TIME_E=$((${TIME_DUMPTREE}-${TIME_EDEPSIM}))
269 TIME_D=$((${TIME_CAFMAKER}-${TIME_DUMPTREE}))
270 TIME_M=$((${TIME_COPY}-${TIME_CAFMAKER}))
271 TIME_C=$((${TIME_END}-${TIME_COPY}))
272 echo "Start-up time: ${TIME_S}"
273 echo "gevgen time: ${TIME_G}"
274 echo "gntpc time: ${TIME_R}"
275 echo "edep-sim time: ${TIME_E}"
276 echo "dumpTree time: ${TIME_D}"
277 echo "makeCAF time: ${TIME_M}"
278 echo "Copy time: ${TIME_C}"