| 1 | #!/bin/sh
|
|---|
| 2 | #
|
|---|
| 3 | # ========================================================================
|
|---|
| 4 | #
|
|---|
| 5 | # *
|
|---|
| 6 | # * This file is part of CheObs, the Modular Analysis and Reconstruction
|
|---|
| 7 | # * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 9 | # * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 10 | # *
|
|---|
| 11 | # * Permission to use, copy, modify and distribute this software and its
|
|---|
| 12 | # * documentation for any purpose is hereby granted without fee,
|
|---|
| 13 | # * provided that the above copyright notice appears in all copies and
|
|---|
| 14 | # * that both that copyright notice and this permission notice appear
|
|---|
| 15 | # * in supporting documentation. It is provided "as is" without express
|
|---|
| 16 | # * or implied warranty.
|
|---|
| 17 | # *
|
|---|
| 18 | #
|
|---|
| 19 | #
|
|---|
| 20 | # Author(s): Daniela Dorner 01/2009 <mailto:daniela.dorner@unige.ch>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: CheObs Software Development, 2000-2009
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | # This script runs corsika and simtelarray.
|
|---|
| 28 | #
|
|---|
| 29 |
|
|---|
| 30 | source `dirname $0`/sourcefile
|
|---|
| 31 | printprocesslog "INFO starting $0"
|
|---|
| 32 | program=corsikasimtel
|
|---|
| 33 | column=fCorsikaSimTelarray
|
|---|
| 34 |
|
|---|
| 35 | # todo:
|
|---|
| 36 | # evtl trennung v corsika u simtel
|
|---|
| 37 |
|
|---|
| 38 | set -C
|
|---|
| 39 | # set write permission for group
|
|---|
| 40 | umask 002
|
|---|
| 41 |
|
|---|
| 42 | simdir=$mcpath/software/simtel
|
|---|
| 43 |
|
|---|
| 44 | export CORSIKA_PATH=$simdir/corsika-6970/run/
|
|---|
| 45 | export SIM_TELARRAY_PATH=$simdir/sim_telarray
|
|---|
| 46 | #export SIM_TELARRAY_PATH=$simdir
|
|---|
| 47 | export SIM_TELARRAY_RUN_PATH=$simdir/sim_telarray
|
|---|
| 48 | export MCDATA_PATH=$mcpath
|
|---|
| 49 | export CORSIKA_DATA="${MCDATA_PATH}/corsika"
|
|---|
| 50 | export SIM_TELARRAY_DATA="${MCDATA_PATH}/simtel"
|
|---|
| 51 | export LD_LIBRARY_PATH=$simdir/hessioxxx/lib/
|
|---|
| 52 |
|
|---|
| 53 | # printing input card to stdout
|
|---|
| 54 | function printinputcard()
|
|---|
| 55 | {
|
|---|
| 56 | # Run number
|
|---|
| 57 | echo "RUNNR "$run
|
|---|
| 58 | # Number of simulated events
|
|---|
| 59 | echo "NSHOW "$numevts
|
|---|
| 60 | # Seed values for simulation
|
|---|
| 61 | echo "SEED "$run" 0 0 "
|
|---|
| 62 | echo "SEED "$run" 0 0 "
|
|---|
| 63 | echo "SEED "$run" 0 0 "
|
|---|
| 64 | echo "SEED "$run" 0 0 "
|
|---|
| 65 | # Observation level
|
|---|
| 66 | echo "OBSLEV "$obslev".E2"
|
|---|
| 67 | # output directory
|
|---|
| 68 | echo "DIRECT "$outpath"/ "
|
|---|
| 69 | cat $inputcardpart
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | # get hostname
|
|---|
| 74 | prodhost=`echo $HOSTNAME | sed -e 's/compute-0-//' -e 's/[.]local//'`
|
|---|
| 75 |
|
|---|
| 76 | diskusage=( `df $mcpath | grep $mcpath ` )
|
|---|
| 77 | # continue only if more than 90 GB are left on /state/cta
|
|---|
| 78 | if [ ${diskusage[2]} -lt 90000000 ]
|
|---|
| 79 | then
|
|---|
| 80 | printprocesslog "WARN less than 90 GB left on $mcpath on node $prodhost "
|
|---|
| 81 | finish
|
|---|
| 82 | else
|
|---|
| 83 | printprocesslog "INFO still ${diskusage[3]} left on $mcpath on node $prodhost "
|
|---|
| 84 | fi
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | # get sequence #
|
|---|
| 88 | gettodo "1"
|
|---|
| 89 | run=${primaries[0]}
|
|---|
| 90 |
|
|---|
| 91 | # lock sequ
|
|---|
| 92 | lockfile=$lockpath/lock-$table-$column-$run.txt
|
|---|
| 93 | checklock
|
|---|
| 94 |
|
|---|
| 95 | printprocesslog "INFO starting $program for run $run"
|
|---|
| 96 |
|
|---|
| 97 | # get values for inputcard
|
|---|
| 98 | query="SELECT fParticleTypeName FROM MCRunData LEFT JOIN ParticleType using (fParticleTypeKEY) where fMCRunNumber="$run
|
|---|
| 99 | primparticle=`sendquery`
|
|---|
| 100 | query="SELECT fNumEvents FROM MCRunData where fMCRunNumber="$run
|
|---|
| 101 | numevts=`sendquery`
|
|---|
| 102 |
|
|---|
| 103 | # get observation level for the script to be begun for sim_telarray
|
|---|
| 104 | query="SELECT fObsLevel FROM MCRunData WHERE fMCRunNumber="$run
|
|---|
| 105 | obslev=`sendquery`
|
|---|
| 106 | # export $OBSLEVEL for the script sim_telarray/cta-ultra2_run.sh or sim_telarray/cta-ultra2-moon_run.sh
|
|---|
| 107 | export OBSLEVEL=$obslev
|
|---|
| 108 |
|
|---|
| 109 | # get moon condition for the script to be begun for sim_telarray
|
|---|
| 110 | query="SELECT fMoonConditionKEY FROM MCRunData where fMCRunNumber="$run
|
|---|
| 111 | mooncase=`sendquery`
|
|---|
| 112 | # export $moon for the script sim_telarray/multi/multi_cta-ultra3.cfg
|
|---|
| 113 | case $mooncase in
|
|---|
| 114 | 0) export moon=''
|
|---|
| 115 | ;;
|
|---|
| 116 | 1) export moon="-moon"
|
|---|
| 117 | ;;
|
|---|
| 118 | *) printprocesslog "ERROR $program failed to retrieve the moon condition"
|
|---|
| 119 | finish
|
|---|
| 120 | ;;
|
|---|
| 121 | esac
|
|---|
| 122 |
|
|---|
| 123 | # for MC for 5at5
|
|---|
| 124 | if [ "$obslev" == "5000" ]
|
|---|
| 125 | then
|
|---|
| 126 | export moon="-5at5"
|
|---|
| 127 | inputcardpart=$setuppath/INPUTS_CTA_ULTRA3_${primparticle}_part_5at5
|
|---|
| 128 | else
|
|---|
| 129 | inputcardpart=$setuppath/INPUTS_CTA_ULTRA3_${primparticle}_part
|
|---|
| 130 | fi
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | # path and logs
|
|---|
| 134 | outpath=$mcpath"/corsika/"`printf %06d $run`
|
|---|
| 135 | logfile=$outpath/$program"-"`printf %06d $run`".log"
|
|---|
| 136 | inputcard=$outpath/$program"-"`printf %06d $run`".card"
|
|---|
| 137 | makedir $outpath
|
|---|
| 138 |
|
|---|
| 139 | # insert host into db
|
|---|
| 140 | query="UPDATE MCRunProcessStatus set fProductionHostKEY=$prodhost where fMCRunNumber="$run
|
|---|
| 141 | if ! sendquery $query
|
|---|
| 142 | then
|
|---|
| 143 | printprocesslog "inserting host failed"
|
|---|
| 144 | finish
|
|---|
| 145 | fi
|
|---|
| 146 |
|
|---|
| 147 | setstatus "start"
|
|---|
| 148 |
|
|---|
| 149 | cd $CORSIKA_PATH
|
|---|
| 150 |
|
|---|
| 151 | printprocesslog "INFO create inputcard for run $run"
|
|---|
| 152 |
|
|---|
| 153 | #
|
|---|
| 154 | # starting corsika with pipe to simtelarray
|
|---|
| 155 | # in the inputcard the path to the script is defined:
|
|---|
| 156 | # ${SIM_TELARRAY_PATH}/run_sim_cta-ultra3 (i.e. run_sim_hessarray_generic)
|
|---|
| 157 | # in this script a setup file is chosen:
|
|---|
| 158 | # multicfg="multi/multi_${cfg}.cfg"
|
|---|
| 159 | # in multi/multi_cta-ultra3.cfg one can choose whether to store
|
|---|
| 160 | # the corsika files:
|
|---|
| 161 | # gzip > ${CORSIKA_DATA}/run${CORSIKA_RUN}.corsika.gz
|
|---|
| 162 | # and multi/multi_cta-ultra3.cfg starts the script
|
|---|
| 163 | # ${SIM_TELARRAY_PATH}/cta-ultra2_run.sh (i.e. generic_run.sh)
|
|---|
| 164 | # in which e.g. path and file name are set
|
|---|
| 165 | #
|
|---|
| 166 | printinputcard >| $inputcard
|
|---|
| 167 | #./corsika < $inputcard >| $logfile 2>&1
|
|---|
| 168 | ./corsika6970Linux_QGSII_urqmd < $inputcard >| $logfile 2>&1
|
|---|
| 169 | check1=$?
|
|---|
| 170 |
|
|---|
| 171 | case $check1 in
|
|---|
| 172 | 0) printprocesslog "INFO finished corsika and simtelarray without error (check1=$check1) "
|
|---|
| 173 | if ! grep 'END OF RUN' $logfile
|
|---|
| 174 | then
|
|---|
| 175 | printprocesslog "ERROR could not find 'END OF RUN' in $logfile => unknown error for run $run"
|
|---|
| 176 | com=$Fcorsikasimtel
|
|---|
| 177 | check=2
|
|---|
| 178 | else
|
|---|
| 179 | printprocesslog "INFO $program finished successfully for mc run number $run"
|
|---|
| 180 | fi
|
|---|
| 181 | ;;
|
|---|
| 182 | *) printprocesslog "ERROR $program failed for mc run number $run (check1=$check1)"
|
|---|
| 183 | com=$Fcorsikasimtel
|
|---|
| 184 | check=$check1
|
|---|
| 185 | ;;
|
|---|
| 186 | esac
|
|---|
| 187 |
|
|---|
| 188 | setstatus "stop"
|
|---|
| 189 |
|
|---|
| 190 | finish
|
|---|
| 191 |
|
|---|