| 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 |  | 
|---|
| 40 | simdir=/home/dorner/cta_mc | 
|---|
| 41 |  | 
|---|
| 42 | export CORSIKA_PATH=$simdir/corsika-6735/run/ | 
|---|
| 43 | export SIM_TELARRAY_PATH=$simdir/sim_telarray | 
|---|
| 44 | export MCDATA_PATH=$mcpath | 
|---|
| 45 | export CORSIKA_DATA="${MCDATA_PATH}/corsika" | 
|---|
| 46 | export SIM_TELARRAY_DATA="${MCDATA_PATH}/simtel" | 
|---|
| 47 |  | 
|---|
| 48 | # printing input card to stdout | 
|---|
| 49 | function printinputcard() | 
|---|
| 50 | { | 
|---|
| 51 | # Run number | 
|---|
| 52 | echo "RUNNR "$run | 
|---|
| 53 | # Number of simulated events | 
|---|
| 54 | echo "NSHOW "$numevts | 
|---|
| 55 | # Seed values for simulation | 
|---|
| 56 | echo "SEED "$run" 0 0 " | 
|---|
| 57 | echo "SEED "$run" 0 0 " | 
|---|
| 58 | echo "SEED "$run" 0 0 " | 
|---|
| 59 | echo "SEED "$run" 0 0 " | 
|---|
| 60 | # output directory | 
|---|
| 61 | echo "DIRECT "$outpath"/ " | 
|---|
| 62 | inputcardpart=$setuppath/INPUTS_CTA_ULTRA3_${primparticle}_part | 
|---|
| 63 | cat $inputcardpart | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 |  | 
|---|
| 67 | # get hostname | 
|---|
| 68 | prodhost=`echo $HOSTNAME | sed -e 's/compute-0-//' -e 's/[.]local//'` | 
|---|
| 69 |  | 
|---|
| 70 | diskusage=( `df $mcpath | grep $mcpath` ) | 
|---|
| 71 | # continue only if more than 90 GB are left on /state/cta | 
|---|
| 72 | if [ ${diskusage[3]} -lt 90000000 ] | 
|---|
| 73 | then | 
|---|
| 74 | printprocesslog "WARN less than 90 GB left on /state/cta on node $prodhost " | 
|---|
| 75 | finish | 
|---|
| 76 | else | 
|---|
| 77 | printprocesslog "INFO still ${diskusage[3]} left on /state/cta on node $prodhost " | 
|---|
| 78 | fi | 
|---|
| 79 |  | 
|---|
| 80 |  | 
|---|
| 81 | # get sequence # | 
|---|
| 82 | gettodo "1" | 
|---|
| 83 | run=${primaries[0]} | 
|---|
| 84 |  | 
|---|
| 85 | # lock sequ | 
|---|
| 86 | lockfile=$lockpath/lock-$table-$column-$run.txt | 
|---|
| 87 | checklock | 
|---|
| 88 |  | 
|---|
| 89 | printprocesslog "INFO starting $program for run $run" | 
|---|
| 90 |  | 
|---|
| 91 | # get values for inputcard | 
|---|
| 92 | query="SELECT fParticleTypeName FROM MCRunData LEFT JOIN ParticleType using (fParticleTypeKEY) where fMCRunNumber="$run | 
|---|
| 93 | primparticle=`sendquery` | 
|---|
| 94 | query="SELECT fNumEvents FROM MCRunData where fMCRunNumber="$run | 
|---|
| 95 | numevts=`sendquery` | 
|---|
| 96 |  | 
|---|
| 97 | # path and logs | 
|---|
| 98 | outpath=$mcpath"/corsika/"`printf %06d $run` | 
|---|
| 99 | logfile=$outpath/$program"-"`printf %06d $run`".log" | 
|---|
| 100 | inputcard=$outpath/$program"-"`printf %06d $run`".card" | 
|---|
| 101 | makedir $outpath | 
|---|
| 102 |  | 
|---|
| 103 | # insert host into db | 
|---|
| 104 | query="UPDATE MCRunProcessStatus set fProductionHostKEY=$prodhost where fMCRunNumber="$run | 
|---|
| 105 | if ! sendquery $query | 
|---|
| 106 | then | 
|---|
| 107 | printprocesslog "inserting host failed" | 
|---|
| 108 | finish | 
|---|
| 109 | fi | 
|---|
| 110 |  | 
|---|
| 111 | setstatus "start" | 
|---|
| 112 |  | 
|---|
| 113 | cd $CORSIKA_PATH | 
|---|
| 114 |  | 
|---|
| 115 | printprocesslog "INFO create inputcard for run $run" | 
|---|
| 116 |  | 
|---|
| 117 | # | 
|---|
| 118 | # starting corsika with pipe to simtelarray | 
|---|
| 119 | #  in the inputcard the path to the script is defined: | 
|---|
| 120 | #     ${SIM_TELARRAY_PATH}/run_sim_cta-ultra3 (i.e. run_sim_hessarray_generic) | 
|---|
| 121 | #  in this script a setup file is chosen: | 
|---|
| 122 | #     multicfg="multi/multi_${cfg}.cfg" | 
|---|
| 123 | #  in multi/multi_cta-ultra3.cfg one can choose whether to store | 
|---|
| 124 | #     the corsika files: | 
|---|
| 125 | #     gzip > ${CORSIKA_DATA}/run${CORSIKA_RUN}.corsika.gz | 
|---|
| 126 | #  and multi/multi_cta-ultra3.cfg starts the script | 
|---|
| 127 | #     ${SIM_TELARRAY_PATH}/cta-ultra2_run.sh (i.e. generic_run.sh) | 
|---|
| 128 | #     in which e.g. path and file name are set | 
|---|
| 129 | # | 
|---|
| 130 | printinputcard >| $inputcard | 
|---|
| 131 | #./corsika < $inputcard >| $logfile 2>&1 | 
|---|
| 132 | ./corsika6735Linux_QGSJET_urqmd < $inputcard >| $logfile 2>&1 | 
|---|
| 133 | check1=$? | 
|---|
| 134 |  | 
|---|
| 135 | case $check1 in | 
|---|
| 136 | 0)   printprocesslog "INFO finished corsika and simtelarray without error (check1=$check1) " | 
|---|
| 137 | if ! grep 'END OF RUN' $logfile | 
|---|
| 138 | then | 
|---|
| 139 | printprocesslog "ERROR could not find 'END OF RUN' in $logfile => unknown error for run $run" | 
|---|
| 140 | com=$Fcorsikasimtel | 
|---|
| 141 | check=2 | 
|---|
| 142 | else | 
|---|
| 143 | printprocesslog "INFO $program finished successfully for mc run number $run" | 
|---|
| 144 | fi | 
|---|
| 145 | ;; | 
|---|
| 146 | *)   printprocesslog "ERROR $program failed for mc run number $run (check1=$check1)" | 
|---|
| 147 | com=$Fcorsikasimtel | 
|---|
| 148 | check=$check1 | 
|---|
| 149 | ;; | 
|---|
| 150 | esac | 
|---|
| 151 |  | 
|---|
| 152 | setstatus "stop" | 
|---|
| 153 |  | 
|---|
| 154 | finish | 
|---|
| 155 |  | 
|---|